Skip to content

Feature/PWPolyF - #1522

Open
ollycassidy13 wants to merge 5 commits into
Xilinx:devfrom
ollycassidy13:feature/PWPolyF
Open

ollycassidy13 wants to merge 5 commits into
Xilinx:devfrom
ollycassidy13:feature/PWPolyF

Conversation

@ollycassidy13

Copy link
Copy Markdown

FINN needs a Brevitas-side PyTorch activation module that mirrors PWPolyF hardware behavior for common floating-point non-linear activations and can export a graph marker that FINN can lower to its RTL This PR adds a FINN-compatible piecewise-polynomial activation path for GELU, SiLU, sigmoid, and tanh, with QONNX export support through a finn.pwpolyf::PWPolyF custom-op marker.

The new activation:

  • Supports gelu, silu, sigmoid, and tanh.
  • Splits the FP32 input range into FINN/PWPolyF-style exponent and mantissa-derived segments.
  • Fits configurable per-segment polynomial coefficients.
  • Evaluates the approximation with Horner's method.
  • Applies the expected clamp/pass-through behavior for |x| >= 8.
  • Registers coefficients and clamp values as buffers so they are carried with the module.

@nickfraser nickfraser left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, but this PR seems to be mostly vibe-coded and needs a LOT of work before it would be accepted. I will hold off from doing a full review before asking the following:

  • do you really want to upstream this into Brevitas, rather than just using it as an out-of-source extension?
  • if yes, are you willing to take the time to rearchitect this?

If the answer is 'no' to either of the above - please close this PR.

onnx_export_kwargs[key][QONNX_DOMAIN_STRING] = QONNX_DOMAIN_VERSION
else:
onnx_export_kwargs[key] = {QONNX_DOMAIN_STRING: QONNX_DOMAIN_VERSION}
cls.solve_dynamo_export(onnx_export_kwargs)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this.

BrevitasQuantLSTMCellFn]

@classmethod
def solve_dynamo_export(cls, export_kwargs):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this.

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.

2 participants