[Relay][Frontend] Add MXNet test example for relay#2316
Merged
merrymercy merged 2 commits intoapache:masterfrom Dec 20, 2018
Merged
[Relay][Frontend] Add MXNet test example for relay#2316merrymercy merged 2 commits intoapache:masterfrom
merrymercy merged 2 commits intoapache:masterfrom
Conversation
Member
|
I already did type correction in import tvm
from tvm import relay
x = relay.var("x", shape=(1, 64, 56, 56))
bias = relay.var("bias")
bias2 = relay.var("bias")
weight = relay.var("weight")
y = relay.nn.conv2d(x, weight, channels=64, kernel_size=(3, 3), padding=(1, 1))
y = relay.nn.bias_add(y, bias)
y = relay.nn.bias_add(y, bias2)
y = relay.Function(relay.ir_pass.free_vars(y), y)
a = relay.ir_pass.infer_type(y)
a = relay.ir_pass.canonicalize_ops(a)
print(a.astext()) |
Member
Author
|
If you add another stmt in between these two bias_add, it will fail. import tvm
from tvm import relay
x = relay.var("x", shape=(1, 64, 56, 56))
bias = relay.var("bias")
bias2 = relay.var("bias")
weight = relay.var("weight")
weight2 = relay.var("weight")
y = relay.nn.conv2d(x, weight, channels=64, kernel_size=(3, 3), padding=(1, 1))
y = relay.nn.bias_add(y, bias)
y = relay.nn.conv2d(y, weight2, channels=128, kernel_size=(3, 3), padding=(1, 1))
y = relay.nn.bias_add(y, bias2)
y = relay.Function(relay.ir_pass.free_vars(y), y)
a = relay.ir_pass.infer_type(y)
a = relay.ir_pass.canonicalize_ops(a)
print(a.astext()) |
Member
|
Try this one line change! diff --git a/src/relay/pass/canonicalize_ops.cc b/src/relay/pass/canonicalize_ops.cc
index 77cd59e2..4482dc39 100644
--- a/src/relay/pass/canonicalize_ops.cc
+++ b/src/relay/pass/canonicalize_ops.cc
@@ -22,7 +22,7 @@ class BiasAddSimplifier : public ExprMutator {
CHECK_EQ(call->args.size(), 2);
const BiasAddAttrs* param = call->attrs.as<BiasAddAttrs>();
- auto ttype = call->args[0]->type_as<TensorTypeNode>();
+ auto ttype = n->args[0]->type_as<TensorTypeNode>();
size_t n_dim = ttype->shape.size();
Expr expanded_bias = ExpandBiasToMatchAxis(call->args[1], n_dim, {param->axis});
Expr ret = Add(call->args[0], expanded_bias); |
Member
Author
|
Thanks @merrymercy. This change fixed the issue. Updated it this PR. |
merrymercy
approved these changes
Dec 20, 2018
zhiics
pushed a commit
to zhiics/tvm
that referenced
this pull request
Dec 21, 2018
* Add MXNet test example for relay * Fix a bug in BiasAddSimplifier
FrozenGene
pushed a commit
to FrozenGene/tvm
that referenced
this pull request
Dec 27, 2018
* Add MXNet test example for relay * Fix a bug in BiasAddSimplifier
Member
|
This PR seems to be duplicated with https://github.com/dmlc/tvm/tree/master/tests/python/frontend/mxnet should we consolidate everything into one location? |
wweic
pushed a commit
to neo-ai/tvm
that referenced
this pull request
Feb 20, 2019
* Add MXNet test example for relay * Fix a bug in BiasAddSimplifier
wweic
pushed a commit
to neo-ai/tvm
that referenced
this pull request
Feb 20, 2019
* Add MXNet test example for relay * Fix a bug in BiasAddSimplifier
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.