Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tvm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cld
ml
tvm
Commits
d45b6d4b
Commit
d45b6d4b
authored
7 years ago
by
ziheng
Committed by
Tianqi Chen
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[DOC] Add intro to 'comm_reducer' in tutorial; fix doc (#108)
* [DOC] Add intro to 'comm_reducer' in tutorial; fix doc * Fix * Fix
parent
6ab6bb3f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
include/tvm/ir_pass.h
+7
-0
7 additions, 0 deletions
include/tvm/ir_pass.h
python/setup.py
+1
-1
1 addition, 1 deletion
python/setup.py
python/tvm/api.py
+3
-1
3 additions, 1 deletion
python/tvm/api.py
tutorials/python/reduction.py
+18
-0
18 additions, 0 deletions
tutorials/python/reduction.py
with
29 additions
and
2 deletions
include/tvm/ir_pass.h
+
7
−
0
View file @
d45b6d4b
...
...
@@ -84,6 +84,13 @@ Stmt CanonicalSimplify(Stmt stmt);
* \return The converted form.
*/
Stmt
Substitute
(
Stmt
stmt
,
const
Map
<
Var
,
Expr
>&
value_map
);
/*!
* \brief Substitute the var specified in key->var to be value.
* \param expr The source expression to be substituted
* \param value_map The map of new values.
* \return The converted expression.
*/
Expr
Substitute
(
Expr
expr
,
const
Map
<
Var
,
Expr
>&
value_map
);
/*!
...
...
This diff is collapsed.
Click to expand it.
python/setup.py
+
1
−
1
View file @
d45b6d4b
...
...
@@ -70,7 +70,7 @@ setuptools.setup(
],
zip_safe
=
False
,
packages
=
[
'
tvm
'
,
'
tvm.
addon
'
,
'
tvm
'
,
'
tvm.
contrib
'
,
'
tvm._ffi
'
,
'
tvm._ffi._ctypes
'
,
'
tvm._ffi._cy2
'
,
'
tvm._ffi._cy3
'
],
...
...
This diff is collapsed.
Click to expand it.
python/tvm/api.py
+
3
−
1
View file @
d45b6d4b
...
...
@@ -23,10 +23,12 @@ handle = "handle"
def
min_value
(
dtype
):
"""
minimum value of dtype
"""
return
_api_internal
.
_min_value
(
dtype
)
def
max_value
(
dtype
):
"""
maximum value of dtype
"""
return
_api_internal
.
_max_value
(
dtype
)
...
...
@@ -438,7 +440,7 @@ def comm_reducer(fcombine, fidentity, name="reduce"):
-------
reducer : function
A function which creates a reduce expression over axis.
There are two to use it:
There are two
ways
to use it:
1. accept (expr, axis, where) to produce an Reduce Expr on
specified axis;
...
...
This diff is collapsed.
Click to expand it.
tutorials/python/reduction.py
+
18
−
0
View file @
d45b6d4b
...
...
@@ -124,6 +124,23 @@ fcuda(a, b)
np
.
testing
.
assert_allclose
(
b
.
asnumpy
(),
np
.
sum
(
a
.
asnumpy
(),
axis
=
1
),
rtol
=
1e-4
)
######################################################################
# Define General Commutative Reduction Operation
# ----------------------------------------------
# Besides the built-in reduction operations like :any:`tvm.sum`,
# :any:`tvm.min` and :any:`tvm.max`, you can also define your
# commutative reduction operation by :any:`tvm.comm_reducer`.
#
n
=
tvm
.
var
(
'
n
'
)
m
=
tvm
.
var
(
'
m
'
)
product
=
tvm
.
comm_reducer
(
lambda
x
,
y
:
x
*
y
,
lambda
t
:
tvm
.
const
(
1
,
dtype
=
t
),
name
=
"
product
"
)
A
=
tvm
.
placeholder
((
n
,
m
),
name
=
'
A
'
)
k
=
tvm
.
reduce_axis
((
0
,
m
),
name
=
'
k
'
)
B
=
tvm
.
compute
((
n
,),
lambda
i
:
product
(
A
[
i
,
k
],
axis
=
k
),
name
=
'
B
'
)
######################################################################
# Summary
# -------
...
...
@@ -131,3 +148,4 @@ np.testing.assert_allclose(
#
# - Describe reduction with reduce_axis.
# - Use rfactor to factor out axis if we need parallelism.
# - Define new reduction operation by :any:`tvm.comm_reducer`
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment