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
7cc92ace
Commit
7cc92ace
authored
7 years ago
by
ziheng
Committed by
Tianqi Chen
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[LANG] Expose tvm.cast (#195)
* [LANG] Expose tvm.cast * Update * Add unittest
parent
7c6a71ba
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
python/tvm/api.py
+17
-0
17 additions, 0 deletions
python/tvm/api.py
python/tvm/expr.py
+14
-0
14 additions, 0 deletions
python/tvm/expr.py
src/api/api_ir.cc
+1
-0
1 addition, 0 deletions
src/api/api_ir.cc
tests/python/unittest/test_lang_tensor.py
+2
-0
2 additions, 0 deletions
tests/python/unittest/test_lang_tensor.py
with
34 additions
and
0 deletions
python/tvm/api.py
+
17
−
0
View file @
7cc92ace
...
...
@@ -467,6 +467,23 @@ def reduce_axis(dom, name="rv"):
"""
return
_IterVar
(
dom
,
name
,
2
)
def
cast
(
dtype
,
expr
):
"""
Cast an expression to other type
Parameters
----------
dtype : str, optional
The type of new expression
expr : Expr
The expression
Returns
-------
expr : Expr
Expression with new type
"""
return
_make
.
Cast
(
dtype
,
expr
)
def
select
(
cond
,
t
,
f
):
"""
Construct a select branch
Parameters
...
...
This diff is collapsed.
Click to expand it.
python/tvm/expr.py
+
14
−
0
View file @
7cc92ace
...
...
@@ -89,6 +89,20 @@ class ExprOp(object):
"""
return
_make
.
EQ
(
self
,
other
)
def
astype
(
self
,
dtype
):
"""
Cast the expression to other type
Parameters
----------
dtype : str, optional
The type of new expression
Returns
-------
expr : Expr
Expression with new type
"""
return
_make
.
Cast
(
dtype
,
self
)
class
Expr
(
NodeBase
,
ExprOp
):
"""
Base class of all tvm Expressions
"""
...
...
This diff is collapsed.
Click to expand it.
src/api/api_ir.cc
+
1
−
0
View file @
7cc92ace
...
...
@@ -139,6 +139,7 @@ REGISTER_MAKE_BINARY_OP(Or);
REGISTER_MAKE1
(
Not
);
REGISTER_MAKE3
(
Select
);
REGISTER_MAKE3
(
Ramp
);
REGISTER_MAKE2
(
Cast
);
REGISTER_MAKE2
(
Broadcast
);
REGISTER_MAKE3
(
Let
);
REGISTER_MAKE3
(
LetStmt
);
...
...
This diff is collapsed.
Click to expand it.
tests/python/unittest/test_lang_tensor.py
+
2
−
0
View file @
7cc92ace
...
...
@@ -16,6 +16,8 @@ def test_tensor():
assert
(
T
.
op
.
output
(
0
).
__hash__
()
==
T
.
__hash__
())
d
=
{
T
.
op
.
output
(
0
)
:
1
}
assert
(
d
[
T
]
==
1
)
assert
(
tvm
.
cast
(
'
float16
'
,
T
[
0
][
0
][
0
]).
dtype
==
'
float16
'
)
assert
(
T
[
0
][
0
][
0
].
astype
(
'
float16
'
).
dtype
==
'
float16
'
)
def
test_conv1d
():
...
...
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