Repository navigation
[RELAY] Port winograd ops to relay - #2356
Conversation
vinx13
left a comment
There was a problem hiding this comment.
I found an issue that alter_op_layout doesn't work with scalar
e.g. relay.add(relay.nn.conv2d(...), relay.const(1.0)) output of conv2d will fallback to original layout because the inferred layout of constant is undef
|
|
||
| if cfg.pass_enabled("FoldConstant"): | ||
| func = ir_pass.fold_constant(func) | ||
| with _target.create("llvm"): |
There was a problem hiding this comment.
This new target is unnecessary because FoldConstant always creates a new llvm target
There was a problem hiding this comment.
BTW, can you compile inception_v3 with relay?
There was a problem hiding this comment.
I can compile inception v3 without AlterOpLayout, otherwise I got type_infer.cc:314: the function is provided too many arguments (nullptr)
| Array<IndexExpr> kernel_size; | ||
| std::string data_layout; | ||
| std::string weight_layout; | ||
| std::string kernel_layout; |
There was a problem hiding this comment.
Purpose: rename weight_layout to kernel_layout to make relay consistent with nnvm and mxnet
3eaf5d0 to
78eaf0e
Compare
|
|
||
| with tophub_context: | ||
| func = optimize(func, params) | ||
| with target: |
There was a problem hiding this comment.
May I ask why we need to have with target here? Is it used by layout altering? It seems that constant folding is not target dependent because it always uses llvm as the target.
There was a problem hiding this comment.
@zhiics alter_op_layout relies on current target to query autotvm log
There was a problem hiding this comment.
@vinx13 I just saw that. Thanks for your quick response. Can we pass the target to alter layout? I am asking is because for heterogeneous compilation we will pass in multiple targets. It is probably not convenient to know which target to be with here.
There was a problem hiding this comment.
Ok, I passed target as an argument and use it explicitly for target-specific passes. Alter_op_layout calls functions similar to topi compute/topi schedule and will modify the graph, so I think it is not straightforward to port it to heterogeneous compilation.
There was a problem hiding this comment.
@merrymercy Thanks. It doesn't really solve the problem. But I think we can keep it like this first because it at least won't break homogeneous execution. I will think about it later in the heterogeneous pass.
| // NOTE: Do not check weight shape here! | ||
| // Different backend requires different layout to compute | ||
| // the batch gemm stage in winograd efficiently, but we want to | ||
| // make this NNVM symbol work for all backends. |
| }; | ||
|
|
||
| for (auto new_arg : new_args) { | ||
| // NOTE: do not support nested tuple |
There was a problem hiding this comment.
I think we need to generically handle nested tuples, the handling of nested tuples has appeared in multiple places including the execution + optimization of AD.
There was a problem hiding this comment.
I leave it to later PRs..
| ##### REGISTER ALTER OP LAYOUT ##### | ||
| @conv2d_alter_layout.register(["arm_cpu"]) | ||
| def _alter_conv2d_layout_arm(attrs, inputs, tinfos): | ||
| def _alter_conv2d_layout_arm(attrs, inputs, tinfos, F): |
There was a problem hiding this comment.
Could we provide a documentation comment here with information about the parameters including F?
|
Overall looks good, just some minor comments. |
76e9ac4 to
ebcf761
Compare
ebcf761 to
c397933
Compare
|
thanks @merrymercy . |
srkreddy1238
left a comment
There was a problem hiding this comment.
AlterOpLayout changes LGTM.
|
Since this PR fixes some bugs that other PRs are pending on. I am going to merge this in. The proposed change of |
|
Thanks to @merrymercy @jroesch @vinx13 @srkreddy1238 @zhiics @yzhliu |
To make alter_op_layout in TOPI support both NNVM and Relay, a new argument
Fis added, which can be eitherrelay.opornnvm.sym.Know issues: