Skip to content

onnx: Mod with a constant divisor #98

Description

@sbryngelson

Register a Mod handler in aneforge/onnx.py for the case where the divisor is a constant: x - floor(x/c)*c from existing graph ops gives the ONNX integer-Mod (sign follows the divisor); the fmod=1 attribute variant (sign follows the dividend) is x - trunc(x/c)*c, and trunc-toward-zero already exists in the Cast handler as sign(x)*floor(|x|). Reject a tensor divisor loudly.

Handler table via the @onnx_op decorator; test both variants against onnxruntime with positive and negative dividends, following tests/test_onnx.py.

Verifying numerics needs any Apple Silicon Mac (the tests dispatch to the ANE); CI runs only the off-device subset, so state in the PR that the on-device tests passed locally.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions