Skip to content

Comments

compiler: add Relu operator support#14

Merged
strimo378 merged 1 commit intomainfrom
codex/implement-relu-operator
Jan 10, 2026
Merged

compiler: add Relu operator support#14
strimo378 merged 1 commit intomainfrom
codex/implement-relu-operator

Conversation

@strimo378
Copy link
Contributor

Motivation

  • Support the ONNX Relu operator end-to-end so small models with ReLU can be compiled and emitted as C.
  • Provide both runtime evaluation and emitted C code that match ONNX Runtime behavior.
  • Keep unary operator lowering consistent with existing Tanh handling and avoid adding extra C runtime deps.

Description

  • Map the Relu op to a unary symbol by adding Relu"relu" in _unary_op_symbol.
  • Implement runtime evaluation for ReLU by adding np.maximum(value, 0) in _apply_unary_op.
  • Update the Jinja2 unary operator template templates/unary_op.c.j2 to emit an inline ternary clamp expression for relu instead of a function call.
  • Add tests and a golden C output: extend tests/test_endtoend_ops.py and tests/test_golden.py with ReLU cases and add tests/golden/relu_model.c as the expected codegen output.

Testing

  • Ran the full test suite with pytest -q and all tests completed successfully.
  • Test run result: 18 passed (tests include golden comparisons and compiled C testbench execution).

Codex Task

@strimo378 strimo378 merged commit 26dab6e into main Jan 10, 2026
0 of 2 checks passed
@strimo378 strimo378 deleted the codex/implement-relu-operator branch January 10, 2026 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant