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
e986f87e
Commit
e986f87e
authored
Sep 27, 2018
by
Animesh Jain
Committed by
Tianqi Chen
Sep 27, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding source types to C++ reduce functions (#1771)
parent
846d9ce0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
4 deletions
+34
-4
src/lang/ir_operator.cc
+4
-4
tests/python/unittest/test_lang_tensor.py
+30
-0
No files found.
src/lang/ir_operator.cc
View file @
e986f87e
...
...
@@ -9,7 +9,7 @@
namespace
tvm
{
Expr
sum
(
Expr
source
,
Array
<
IterVar
>
rdom
)
{
Var
x
(
"x"
),
y
(
"y"
);
Var
x
(
"x"
,
source
.
type
()),
y
(
"y"
,
source
.
type
()
);
Expr
result
=
ir
::
Add
::
make
(
x
,
y
);
Expr
identity_element
=
make_zero
(
source
.
type
());
ir
::
CommReducer
combiner
=
...
...
@@ -18,7 +18,7 @@ Expr sum(Expr source, Array<IterVar> rdom) {
}
Expr
max
(
Expr
source
,
Array
<
IterVar
>
rdom
)
{
Var
x
(
"x"
),
y
(
"y"
);
Var
x
(
"x"
,
source
.
type
()),
y
(
"y"
,
source
.
type
()
);
Expr
result
=
ir
::
Max
::
make
(
x
,
y
);
Expr
identity_element
=
source
.
type
().
min
();
ir
::
CommReducer
combiner
=
...
...
@@ -27,7 +27,7 @@ Expr max(Expr source, Array<IterVar> rdom) {
}
Expr
min
(
Expr
source
,
Array
<
IterVar
>
rdom
)
{
Var
x
(
"x"
),
y
(
"y"
);
Var
x
(
"x"
,
source
.
type
()),
y
(
"y"
,
source
.
type
()
);
Expr
result
=
ir
::
Min
::
make
(
x
,
y
);
Expr
identity_element
=
source
.
type
().
max
();
ir
::
CommReducer
combiner
=
...
...
@@ -36,7 +36,7 @@ Expr min(Expr source, Array<IterVar> rdom) {
}
Expr
prod
(
Expr
source
,
Array
<
IterVar
>
rdom
)
{
Var
x
(
"x"
),
y
(
"y"
);
Var
x
(
"x"
,
source
.
type
()),
y
(
"y"
,
source
.
type
()
);
Expr
result
=
ir
::
Mul
::
make
(
x
,
y
);
Expr
identity_element
=
make_one
(
source
.
type
());
ir
::
CommReducer
combiner
=
...
...
tests/python/unittest/test_lang_tensor.py
View file @
e986f87e
import
tvm
from
topi.nn.pooling
import
pool
def
test_tensor
():
m
=
tvm
.
var
(
'm'
)
...
...
@@ -185,6 +186,34 @@ def test_tensor_inputs():
assert
tuple
(
y
.
op
.
input_tensors
)
==
(
x
,)
def
test_tensor_pool
():
def
intrin_pool
():
A
=
tvm
.
placeholder
((
64
,
16
,
16
),
name
=
'A'
)
kh
=
tvm
.
reduce_axis
((
0
,
3
),
name
=
'kh'
)
kw
=
tvm
.
reduce_axis
((
0
,
3
),
name
=
'kw'
)
P
=
tvm
.
compute
((
64
,
14
,
14
),
lambda
c
,
oh
,
ow
:
tvm
.
max
(
A
[
c
,
oh
+
kh
,
ow
+
kw
],
axis
=
[
kh
,
kw
]),
name
=
'p'
)
def
intrin_func
(
ins
,
outs
):
dinp
=
ins
[
0
]
dout
=
outs
[
0
]
return
tvm
.
call_packed
(
"op"
,
dinp
,
dout
)
with
tvm
.
build_config
(
offset_factor
=
1
):
return
tvm
.
decl_tensor_intrin
(
P
.
op
,
intrin_func
)
A
=
tvm
.
placeholder
((
1
,
64
,
16
,
16
),
name
=
'A'
)
P
=
pool
(
data
=
A
,
kernel
=
(
3
,
3
),
stride
=
(
1
,
1
),
padding
=
(
0
,
0
,
0
,
0
),
pool_type
=
'max'
)
s
=
tvm
.
create_schedule
(
P
.
op
)
_
,
oh
,
_
,
_
=
P
.
op
.
axis
intrin
=
intrin_pool
()
s
[
P
]
.
tensorize
(
oh
,
intrin
)
tvm
.
lower
(
s
,
[
A
,
P
])
if
__name__
==
"__main__"
:
test_rank_zero
()
test_tensor_inputs
()
...
...
@@ -199,3 +228,4 @@ if __name__ == "__main__":
test_extern_multi_out
()
test_tuple_inputs
()
test_tuple_with_different_deps
()
test_tensor_pool
()
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