lixiaoquan commented on a change in pull request #5429:
URL: https://github.com/apache/incubator-tvm/pull/5429#discussion_r418782618
##########
File path: src/relay/op/tensor/transform.cc
##########
@@ -504,17 +548,38 @@ bool ReshapeRel(const Array<Type>& types,
return false;
}
- const auto* param = attrs.as<ReshapeAttrs>();
+ Array<IndexExpr> oshape;
Array<IndexExpr> data_shape;
Array<Integer> newshape;
- if (param->reverse) {
- data_shape.assign(data->shape.rbegin(), data->shape.rend());
- newshape.assign(param->newshape.rbegin(), param->newshape.rend());
+ const ConstantNode *attr_newshape;
+
+ if ((attr_newshape = param->newshape.as<ConstantNode>())) {
+ Array<Integer> temp;
+
+ CHECK_EQ(attr_newshape->data->ndim, 1);
+ for (int i = 0; i < attr_newshape->data->shape[0]; i++) {
+ temp.push_back(Integer(static_cast<int>(ToScalar(attr_newshape->data,
i))));
+ }
+
+ if (param->reverse) {
+ data_shape.assign(data->shape.rbegin(), data->shape.rend());
+ newshape.assign(temp.rbegin(), temp.rend());
+ } else {
+ data_shape = data->shape;
+ newshape = temp;
+ }
} else {
- data_shape = data->shape;
- newshape = param->newshape;
+ const auto* newshape = types[1].as<TensorTypeNode>();
+
+ // Doesn't support dynamic output rank
+ for (int i = 0; i < newshape->shape[0].as<IntImmNode>()->value; i++) {
Review comment:
If special values are from runtime, we can't know them in ReshapeRel. I
think there is limitation for non constant newshape. As long as output's rank
is the same as newshape, some special values still work
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]