Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tic
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wenyuanbo
tic
Commits
24bca6af
Commit
24bca6af
authored
Mar 02, 2017
by
Tianqi Chen
Committed by
GitHub
Mar 02, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[TEST] Add dot (#61)
parent
2c512ca7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
0 deletions
+54
-0
tests/python/integration/test_dot.py
+54
-0
No files found.
tests/python/integration/test_dot.py
0 → 100644
View file @
24bca6af
import
tvm
import
numpy
as
np
def
lower
(
s
,
args
,
name
=
"mydot"
):
binds
=
{}
arg_list
=
[]
for
x
in
args
:
assert
isinstance
(
x
,
tvm
.
tensor
.
Tensor
)
buf
=
tvm
.
Buffer
(
x
.
shape
,
dtype
=
x
.
dtype
,
name
=
x
.
op
.
name
)
binds
[
x
]
=
buf
arg_list
.
append
(
buf
)
s
.
normalize
()
bounds
=
tvm
.
schedule
.
InferBound
(
s
)
stmt
=
tvm
.
schedule
.
ScheduleOps
(
s
,
bounds
)
stmt
=
tvm
.
ir_pass
.
StorageFlatten
(
stmt
,
binds
)
stmt
=
tvm
.
ir_pass
.
CanonicalSimplify
(
stmt
)
stmt
=
tvm
.
ir_pass
.
Simplify
(
stmt
)
fapi
=
tvm
.
ir_pass
.
MakeAPI
(
stmt
,
name
,
arg_list
,
0
)
return
fapi
def
mybuild
(
fapi
,
target
=
"llvm"
):
return
def
test_dot
():
nn
=
12
n
=
tvm
.
Var
(
'n'
)
A
=
tvm
.
placeholder
((
n
,),
name
=
'A'
)
B
=
tvm
.
placeholder
((
n
,),
name
=
'B'
)
k
=
tvm
.
IterVar
((
0
,
n
),
name
=
'k'
)
C
=
tvm
.
compute
((
1
,),
lambda
_
:
tvm
.
sum
(
A
[
k
]
*
B
[
k
],
axis
=
k
),
name
=
'C'
)
s
=
tvm
.
Schedule
(
C
.
op
)
fapi
=
lower
(
s
,
[
A
,
B
,
C
])
def
verify
(
target
):
if
not
tvm
.
codegen
.
enabled
(
target
):
print
(
"Target
%
s is not enabled"
%
target
)
return
f
=
tvm
.
codegen
.
build
(
fapi
,
target
)
# verify
ctx
=
tvm
.
cpu
(
0
)
a
=
tvm
.
nd
.
array
(
np
.
random
.
uniform
(
size
=
(
nn
,))
.
astype
(
A
.
dtype
),
ctx
)
b
=
tvm
.
nd
.
array
(
np
.
random
.
uniform
(
size
=
(
nn
,))
.
astype
(
B
.
dtype
),
ctx
)
c
=
tvm
.
nd
.
array
(
np
.
zeros
((
1
,),
dtype
=
C
.
dtype
),
ctx
)
f
(
a
,
b
,
c
)
np
.
testing
.
assert_allclose
(
c
.
asnumpy
(),
np
.
dot
(
a
.
asnumpy
(),
b
.
asnumpy
()),
rtol
=
1e-4
)
verify
(
"llvm"
)
if
__name__
==
"__main__"
:
test_dot
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment