You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2020/05/01 17:24:02 UTC
[GitHub] [incubator-tvm] icemelon9 commented on a change in pull request #5429: [RELAY][TF] Support symbolic newshape for Reshape
icemelon9 commented on a change in pull request #5429:
URL: https://github.com/apache/incubator-tvm/pull/5429#discussion_r418644047
##########
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:
This could be incorrect if we have special values like -2, -3, -4.
----------------------------------------------------------------
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:
users@infra.apache.org