kevinthesun commented on a change in pull request #4441: [relay][op] Add shape
func to tile
URL: https://github.com/apache/incubator-tvm/pull/4441#discussion_r352311796
##########
File path: src/relay/op/tensor/transform.cc
##########
@@ -1393,28 +1393,45 @@ bool TileRel(const Array<Type>& types,
reps_shape.reserve(tndim);
if (ndim == rndim) {
for (size_t i = 0; i < tndim; ++i) {
- data_shape.emplace_back(data->shape[i]);
- reps_shape.emplace_back(reps[i]);
+ data_shape.emplace_back(data->shape[i]);
+ reps_shape.emplace_back(reps[i]);
}
} else if (ndim > rndim) {
- for (size_t i = 0; i < ndim; ++i)
- data_shape.emplace_back(data->shape[i]);
- for (size_t i = 0; i < (ndim - rndim); ++i)
- reps_shape.emplace_back(1);
- for (size_t i = 0; i < rndim; ++i)
- reps_shape.emplace_back(reps[i]);
+ for (size_t i = 0; i < ndim; ++i) {
+ data_shape.emplace_back(data->shape[i]);
+ }
+ for (size_t i = 0; i < (ndim - rndim); ++i) {
+ reps_shape.emplace_back(1);
+ }
+ for (size_t i = 0; i < rndim; ++i) {
+ reps_shape.emplace_back(reps[i]);
+ }
} else {
- for (size_t i = 0; i < rndim; ++i)
- reps_shape.emplace_back(reps[i]);
- for (size_t i = 0; i < (rndim - ndim); ++i)
- data_shape.emplace_back(1);
- for (size_t i = 0; i < ndim; ++i)
- data_shape.emplace_back(data->shape[i]);
+ for (size_t i = 0; i < rndim; ++i) {
+ reps_shape.emplace_back(reps[i]);
+ }
+ for (size_t i = 0; i < (rndim - ndim); ++i) {
+ data_shape.emplace_back(1);
+ }
+ for (size_t i = 0; i < ndim; ++i) {
+ data_shape.emplace_back(data->shape[i]);
+ }
}
std::vector<IndexExpr> oshape;
oshape.reserve(tndim);
+ bool is_dynamic_shape = false;
+ for (size_t i = 0; i < data->shape.size(); ++i) {
+ if (!data->shape[i].as<IntImm>()) {
+ is_dynamic_shape = true;
+ break;
+ }
+ }
for (size_t i = 0; i < tndim; ++i) {
- oshape.emplace_back(data_shape[i] * reps_shape[i]);
+ if (is_dynamic_shape) {
Review comment:
Maybe we should check whether each axis is symbolic instead here, and only
return Any for symbolic axes?
----------------------------------------------------------------
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]
With regards,
Apache Git Services