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
9b274cbb
Unverified
Commit
9b274cbb
authored
Apr 03, 2020
by
Tianqi Chen
Committed by
GitHub
Apr 03, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[PYTHON] Make IntImm more like an integer (#5232)
parent
7de8a539
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
0 deletions
+30
-0
python/tvm/tir/expr.py
+16
-0
tests/python/unittest/test_tir_nodes.py
+14
-0
No files found.
python/tvm/tir/expr.py
View file @
9b274cbb
...
...
@@ -439,6 +439,7 @@ class FloatImm(ConstExpr):
self
.
__init_handle_by_constructor__
(
tvm
.
ir
.
_ffi_api
.
FloatImm
,
dtype
,
value
)
@tvm._ffi.register_object
class
IntImm
(
ConstExpr
):
"""Int constant.
...
...
@@ -455,9 +456,24 @@ class IntImm(ConstExpr):
self
.
__init_handle_by_constructor__
(
tvm
.
ir
.
_ffi_api
.
IntImm
,
dtype
,
value
)
def
__hash__
(
self
):
return
self
.
value
def
__int__
(
self
):
return
self
.
value
def
__nonzero__
(
self
):
return
self
.
value
!=
0
def
__eq__
(
self
,
other
):
return
_ffi_api
.
_OpEQ
(
self
,
other
)
def
__ne__
(
self
,
other
):
return
_ffi_api
.
_OpNE
(
self
,
other
)
def
__bool__
(
self
):
return
self
.
__nonzero__
()
@tvm._ffi.register_object
class
StringImm
(
ConstExpr
):
...
...
tests/python/unittest/test_tir_nodes.py
View file @
9b274cbb
...
...
@@ -302,7 +302,21 @@ def test_buffer_load_store():
assert
isinstance
(
s
,
tvm
.
tir
.
BufferStore
)
def
test_intimm_cond
():
x
=
tvm
.
runtime
.
convert
(
1
)
y
=
tvm
.
runtime
.
convert
(
1
)
s
=
{
x
}
assert
y
in
s
assert
x
==
y
assert
x
<
20
assert
not
(
x
>=
20
)
assert
x
<
10
and
y
<
10
assert
not
tvm
.
runtime
.
convert
(
x
!=
1
)
assert
x
==
1
if
__name__
==
"__main__"
:
test_intimm_cond
()
test_buffer_load_store
()
test_vars
()
test_prim_func
()
...
...
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