fix(quantization): export root-module weights in graph CoreML#15
Open
eyupcanakman wants to merge 1 commit into
Open
fix(quantization): export root-module weights in graph CoreML#15eyupcanakman wants to merge 1 commit into
eyupcanakman wants to merge 1 commit into
Conversation
A weight on the root module (a bare nn.Linear) exports with a dot-less get_attr target, which _get_weight_input_names rejected with "Invalid weight target path". Treat a dot-less target as a root-module parameter (module name ""), which _get_weight_module already resolves.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Quantizer.finalize(backend=ExportBackend.CoreML)crashes on a weight that is a parameter of the root module, such as a barenn.Linear._get_weight_input_namessplits the weight'sget_attrtarget into a module name and a parameter name on the last dot. A root-module parameter exports with a dot-less target (weight), so there is no dot to split on and the function raised:A weight on a child module (
conv.weight,layer1.0.weight) splits cleanly and works, and so does the same model in eager mode. The fix treats a dot-less target as a parameter on the root module, returning""as the module name, which_get_weight_modulealready resolves through the""key innamed_modules(). The new test exports a barenn.Linearto Core ML.