Update the onnx Gemm op to FC/FCTransposed logic in caffe2 onnx backend#10108
Update the onnx Gemm op to FC/FCTransposed logic in caffe2 onnx backend#10108JerryShih wants to merge 4 commits intopytorch:masterfrom
Conversation
|
@houseroad @yinghai |
|
@houseroad |
a09df51 to
26520a7
Compare
26520a7 to
c94eb43
Compare
|
@houseroad |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
houseroad
left a comment
There was a problem hiding this comment.
Overall looks pretty good.
Nit: use int instead of bool when calling make_node, since transA, transB, and broadcast are all int.
c94eb43 to
05c571f
Compare
|
@houseroad |
|
@houseroad |
facebook-github-bot
left a comment
There was a problem hiding this comment.
houseroad has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
bddppq
left a comment
There was a problem hiding this comment.
I think what this PR is trying to improve is to use FCTransposed when trans_b is False, this is a good idea. Could you update the pull request's title & summary accordingly?
caffe2/onnx/backend.cc
Outdated
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
caffe2/onnx/backend.cc
Outdated
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
|
A potential follow up change (after getting this merged): Right now, FC only accpet 1d bias, however, we can improve FC's implementation to accept 2d bias. FC's implementation: Same to FCTranspose. When FC accepts 2d bias, we can always turn a Gemm into Scale + FC(Transpose) |
|
@houseroad @bddppq |
|
@houseroad @bddppq |
05c571f to
44ef2af
Compare
Update the _known_opset_version value as the opset_version in 'caffe2/python/onnx/backend.py'.
1. support broadcast by default if the opset version is greater than 6. 2. use FC/FCTransposed if we have broadcast and the input_c's dim matching the FC/FCTransposed's requirement.
If we have broadcast and the input_c's dim is not 1, we still can't use FC for this case. So, remove this wrong test.
1. The opset7 uses broadcast by default. Set the explicit opset version to test the different behavior. 2. Add the new FCTransposed op test case.
44ef2af to
912e3b5
Compare
|
@houseroad @bddppq I update the condition for converting to FC.
In most case, we will use FC. |
|
@houseroad @bddppq "pr/caffe2-py2-cuda9.0-cudnn7-windows-build — Build failed" |
|
I have restarted the build, don’t worry. I will review today later. |
facebook-github-bot
left a comment
There was a problem hiding this comment.
houseroad has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
|
@houseroad |
|
I am running some internal test cases. Will update it soon. |
|
@JerryShih are you interested in improving FC and FCTranspose in Caffe2? |
|
yes, I will do that. |
|
Awesome, if you have any question, feel free to ping on gitter. |
* upstream/master: (147 commits) Support Loading to GPU (pytorch#10710) More changes for hidden visibility (pytorch#10692) Add arguments __repr__ in Distribution base class Add util function from core type to dtype (pytorch#10716) Make ONNX_ATEN_FALLBACK as internal default option Set the BUILD_ENVIRONMENT variable before installing sccache. (pytorch#10640) Avoid shadowing i, j vars in GeneralProposals test (pytorch#10721) Move THNN Reduction to ATen/core. (pytorch#10703) Completely remove build_aten and use_aten (pytorch#10469) Make empty list literals construct empty Tensor[] (pytorch#10705) Soumith's last few patches to v0.4.1 Fix issues link in Caffe2 readme (pytorch#10711) Update the onnx Gemm op to FC/FCTransposed logic in caffe2 onnx backend (pytorch#10108) Adding ATEN_NO_TEST option to root level cmake for propogation to aten Allow method-style casts on tensors (pytorch#10641) Fix pytorch#10698 build failure (pytorch#10704) Add support for Log() Add a bisect percentile operator (pytorch#10563) Fix EnsureCPUOutputOp (pytorch#10651) Nomnigraph - rename some APIs that invole Subtree to Subgraph (pytorch#10551) ...
…nd (pytorch#10108) Summary: The broadcast is used by default when the opset version is greater then 6. Pull Request resolved: pytorch#10108 Reviewed By: bddppq Differential Revision: D9176934 Pulled By: houseroad fbshipit-source-id: b737bd87b0ddc241c657d35856d1273c9950eeba
The broadcast is used by default when the opset version is greater then 6.
#9874