Commit f397fead by Wuwei Lin Committed by Yizhi Liu

[RELAY] Fix ops in packed layout (#2472)

* [RELAY] Fix ops in packed layout

* Fix style
parent 32549dec
...@@ -83,7 +83,11 @@ bool Pool2DRel(const Array<Type>& types, ...@@ -83,7 +83,11 @@ bool Pool2DRel(const Array<Type>& types,
return false; return false;
} }
std::vector<IndexExpr> oshape({dshape[0], dshape[1], dshape[2], dshape[3]}); std::vector<IndexExpr> oshape;
for (const auto& e : dshape) {
oshape.push_back(e);
}
if (param->ceil_mode) { if (param->ceil_mode) {
oshape[hidx] = ((dshape[hidx] + pad_h - param->pool_size[0] + oshape[hidx] = ((dshape[hidx] + pad_h - param->pool_size[0] +
param->strides[0] - 1) / param->strides[0]) + 1; param->strides[0] - 1) / param->strides[0]) + 1;
......
...@@ -76,7 +76,8 @@ RELAY_REGISTER_OP("cast") ...@@ -76,7 +76,8 @@ RELAY_REGISTER_OP("cast")
.set_support_level(3) .set_support_level(3)
.add_type_rel("Cast", CastRel) .add_type_rel("Cast", CastRel)
.set_attr<FTVMCompute>("FTVMCompute", CastCompute) .set_attr<FTVMCompute>("FTVMCompute", CastCompute)
.set_attr<TOpPattern>("TOpPattern", kElemWise); .set_attr<TOpPattern>("TOpPattern", kElemWise)
.set_attr<FInferCorrectLayout>("FInferCorrectLayout", ElemwiseArbitraryLayout);
// relay.expand_dims // relay.expand_dims
TVM_REGISTER_NODE_TYPE(ExpandDimsAttrs); TVM_REGISTER_NODE_TYPE(ExpandDimsAttrs);
......
...@@ -82,6 +82,8 @@ def test_alter_layout(): ...@@ -82,6 +82,8 @@ def test_alter_layout():
# a useless tuple, which will be eliminated # a useless tuple, which will be eliminated
y = relay.Tuple([y])[0] y = relay.Tuple([y])[0]
y = relay.nn.relu(y) y = relay.nn.relu(y)
y = relay.nn.max_pool2d(y, pool_size=(2, 2))
y = relay.cast(y, 'int32')
y = relay.nn.batch_flatten(y) y = relay.nn.batch_flatten(y)
y = relay.Function(free_vars(y), y) y = relay.Function(free_vars(y), y)
return y return y
...@@ -112,6 +114,8 @@ def test_alter_layout(): ...@@ -112,6 +114,8 @@ def test_alter_layout():
y = relay.add(y, b) y = relay.add(y, b)
y = relay.nn.relu(y) y = relay.nn.relu(y)
y = relay.nn.max_pool2d(y, pool_size=(2, 2), layout="NCHW16c")
y = relay.cast(y, 'int32')
y = relay.layout_transform(y, "NCHW16c", "NCHW") y = relay.layout_transform(y, "NCHW16c", "NCHW")
y = relay.nn.batch_flatten(y) y = relay.nn.batch_flatten(y)
y = relay.Function(free_vars(y), y) y = relay.Function(free_vars(y), y)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment