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
ae89afe0
Unverified
Commit
ae89afe0
authored
Apr 30, 2020
by
Zhi
Committed by
GitHub
Apr 30, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Fix] Add ConstantNode to IsAtomic (#5457)
* add constantnode to atomic * Add ToANormalForm to FoldConstant
parent
5d75992d
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
0 deletions
+20
-0
src/relay/transforms/fold_constant.cc
+1
-0
tests/python/relay/test_pass_fold_constant.py
+19
-0
No files found.
src/relay/transforms/fold_constant.cc
View file @
ae89afe0
...
...
@@ -203,6 +203,7 @@ class ConstantFolder : public ExprMutator {
// Constant evaluate a expression.
Expr
ConstEvaluate
(
Expr
expr
)
{
std
::
vector
<
transform
::
Pass
>
passes
=
{
transform
::
FuseOps
(
0
),
transform
::
ToANormalForm
(),
transform
::
InferType
()};
Function
func
;
if
(
expr
.
as
<
FunctionNode
>
())
{
...
...
tests/python/relay/test_pass_fold_constant.py
View file @
ae89afe0
...
...
@@ -32,6 +32,25 @@ def run_opt_pass(expr, opt_pass):
return
entry
if
isinstance
(
expr
,
relay
.
Function
)
else
entry
.
body
def
test_concatenate_const
():
def
before
():
data
=
tvm
.
nd
.
array
(
np
.
array
([
1.0
,
2.0
,
3.0
]))
const
=
relay
.
const
(
data
)
concat
=
relay
.
op
.
concatenate
([
const
,
const
],
axis
=
0
)
func
=
relay
.
Function
([],
concat
)
return
func
def
expected
():
data
=
tvm
.
nd
.
array
(
np
.
array
([
1.0
,
2.0
,
3.0
,
1.0
,
2.0
,
3.0
]))
const
=
relay
.
const
(
data
)
func
=
relay
.
Function
([],
const
)
return
func
zz
=
run_opt_pass
(
before
(),
transform
.
FoldConstant
())
zexpected
=
run_opt_pass
(
expected
(),
transform
.
InferType
())
assert
tvm
.
ir
.
structural_equal
(
zz
,
zexpected
)
def
test_fold_const
():
c_data
=
np
.
array
([
1
,
2
,
3
])
.
astype
(
"float32"
)
t
=
relay
.
TensorType
([
1
,
2
,
3
],
"float32"
)
...
...
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