Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we verify if flatten is necessary? i.e. check the dimension and only insert the flatten if necessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nishi-t can you act on this comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm trying it, but I have not already done so well. Because, I'm struggling to get the input data's dimension in the
_impl_v1for checking necessity of flatten. I try to use _infer_shape auxiliary function to get the input[0]'s output_shape. But, it does not work when input[0] is pooling. Could you give me some advices?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is strange that you cannot get the output shape when the input[0] is pooling. Maybe can you look into what happens here?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your advice. I analyzed what happened here and found out a few things.
In the stage of
nnvm.frontend.from_onnx, maybe infer_shape does not work completly, because the input's shape may not be decided.When I putted the following code before the flatten and ran it, out_shapes was
[[]]In following lines called from above infer_shape,
dshape.ndim()became 0 and returned false.https://github.com/dmlc/tvm/blob/master/nnvm/src/top/nn/pooling.cc#L33
https://github.com/dmlc/tvm/blob/master/nnvm/src/top/nn/convolution.cc#L62
It seems difficult to use infer_shape for my purpose without making any changes. Please let me know what you think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zhreshold can you comment on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
infer shape is not available because input shape is not ready. Currently I cannot find a way to detect if flatten is necessary as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, maybe an easier way is to add an optimization to remove flatten in nnvm when it is not necessary. I am going to merge this in for now