Uh oh!
There was an error while loading. Please reload this page.
[NNVM][FRONTEND][ONNX] Fix the gemm conversion in onnx frontend - #1241
Conversation
| inputs[0] = _sym.transpose(inputs[0], axes=(1, 0)) | ||
| if not transB: | ||
| inputs[1] = _sym.transpose(inputs[1], axes=(1, 0)) | ||
| inputs[0] = _sym.flatten(inputs[0]) |
There was a problem hiding this comment.
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.
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_v1 for 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.
It is strange that you cannot get the output shape when the input[0] is pooling. Maybe can you look into what happens here?
There was a problem hiding this comment.
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 [[]]
g = _graph.create(inputs[0])
shape_dict = {k: v.shape for k, v in params.items()}
_, out_shapes = graph_util.infer_shape(g, **shape_dict) 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.
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.
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
tqchen
commented
Jun 11, 2018
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 |
| inputs[0] = _sym.transpose(inputs[0], axes=(1, 0)) | ||
| if not transB: | ||
| inputs[1] = _sym.transpose(inputs[1], axes=(1, 0)) | ||
| inputs[0] = _sym.flatten(inputs[0]) |
There was a problem hiding this comment.
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
This PR addressed #1231
I think that the problem caused by passing 4 dimensions no flatten data to
denseoperator. I locally confirmed thatvgg19is compiled successfully. Please review.