Gemm optional bias#2330
Conversation
If missing it defaults to 0. Also added a test case for no bias. Updated the Gemm op to version 11.
|
+some people from SIG operator @ebarsoum, @spandantiwari, @gramalingam for visibility. I personally consider this change reasonable for some reasons below.
To be fair, I also should note that this change is not going to increase the expressiveness of ONNX. |
|
@wschin @JamesAllingham Just curious if this is being tracked for 1.6 release. If not, then we may have to update the opset version number in the PR from 11 to 12. |
It's a nice to have thing in 1.6. If we can't make it on time, we can bump the opset version if you want. |
|
@JamesAllingham, we need a shape inference test as well. |
I've added a test but I wasn't 100% sure what you wanted here so let me know if you wanted something else. |
Ah, my bad. I missed the last file. |
No, I only just added it, you didn't miss anything! |
| auto& first_input_shape = getInputShape(ctx, 0); | ||
| auto& second_input_shape = getInputShape(ctx, 1); | ||
| if (first_input_shape.dim_size() != 2) | ||
| fail_shape_inference("First input does not have rank 2"); |
There was a problem hiding this comment.
nit: Minor point about code style - consider adding braces even for single line scopes to be consistent with coding style in this file.
* Gemm optional bias (#2330) * Made the 'C' input of Gemm (the bias term) optional. If missing it defaults to 0. Also added a test case for no bias. Updated the Gemm op to version 11. * Fixed a typo! * Small tweaks to the Gemm docs. * Added a shape inference test for Gemm with no bias * Tweaked coding style slightly by adding braces to single line scopes. * Fix some backend tests (#2335) * Fix some node tests * PR comments and docs * Update Changelog.md * Update gen_doc script to validate proto3 files (#2122) * Update gen_doc script to validate proto3 files * Update CMakeLists.txt * Update pybind (#2340) * Fix node test case model for Gemm scalar bias case (#2342) * Fix some node tests * PR comments and docs * Update Changelog.md * Fix gemm scalar node test * Clarify behavior in ConvTranspose (#2343) * Fix the wrong behavior in ConvTranspose * Address comments
* Made the 'C' input of Gemm (the bias term) optional. If missing it defaults to 0. Also added a test case for no bias. Updated the Gemm op to version 11. * Fixed a typo! * Small tweaks to the Gemm docs. * Added a shape inference test for Gemm with no bias * Tweaked coding style slightly by adding braces to single line scopes.
As discussed (briefly) in #2060 it would be useful for the bias term (the
'C'input) of the'Gemm'operation to be optional. This PR adds this functionality.Specifically, if the bias is not specified it is assumed to be 0. This is a common behaviour among deep learning frameworks.
This PR:
Updates the definition (in
math/defs.cc) to make the'C'input optional. The version for theGemmoperator is bumped to 11, and the old definition is moved tomath/old.cc. Similarly,operator_sets.his updated to reflect the new version number.Updates the
gemm_reference_implementationto allow for'C'being optional.Adds a test case for no bias term.