Skip to content

fuse_linear_bias: fold a scalar add/sub into the linear bias - #2911

Open
msluszniak wants to merge 1 commit into
apple:mainfrom
msluszniak:fuse-linear-scalar-bias
Open

msluszniak wants to merge 1 commit into
apple:mainfrom
msluszniak:fuse-linear-scalar-bias

Conversation

@msluszniak

Copy link
Copy Markdown

fuse_linear_bias raised IndexError on a 0-d bias (a Python scalar added to a 1-output linear, e.g. F.linear(x * x, w) + eps), and never fused a scalar into a wider linear. A scalar now broadcasts to every output channel.

Test: pytest coremltools/converters/mil/mil/passes/tests/test_passes.py -k TestFuseLinearBias (new test_transform_linear_scalar_bias fails without the fix).

A 0-d constant passed the prod(shape) check when the linear had one output
channel and then raised IndexError on bias.shape[-1]; with more channels it was
never fused. A scalar now broadcasts to every output channel.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant