Repository navigation
[Relax][Op] Add missing TOPI-backed operators: correlation, lrn, dilate, dilation2d - #20758
Open
Asthenia0412 wants to merge 4 commits into
Open
Asthenia0412 wants to merge 4 commits into
Asthenia0412 wants to merge 4 commits into
Conversation
Asthenia0412
force-pushed
the
feat/contribution-20261016
branch
from
October 17, 2026 01:24
2932000 to
668c0cd
Compare
…te, dilation2d Add 4 new Relax operators that were previously only available in TOPI: - relax.nn.correlation: Cross-correlation between two feature maps (NCHW layout) - relax.nn.lrn: Local Response Normalization (AlexNet-style across channels) - relax.nn.dilate: Upsample with holes (insert zeros between elements) - relax.image.dilation2d: Morphological dilation (NCHW and NHWC layouts) Each operator includes: - C++ Attrs class with TVM_FFI_DECLARE_OBJECT_INFO_FINAL macro - Python Relax op definition with proper attrs and docstrings - TOPI legalization in legalize_ops/ - Export in __init__.py modules These operators fill gaps between TOPI's rich operator set and Relax's op surface, enabling easier frontend integration (ONNX/TFLite/Torch) for models that use these common but previously unsupported ops.
Asthenia0412
force-pushed
the
feat/contribution-20261016
branch
from
October 17, 2026 02:26
668c0cd to
f1fbe0b
Compare
PR apache#20758 added correlation, lrn, dilate, dilation2d ops with Attribute reflection registration, but missed the corresponding OpDef registration in the C++ OpRegistry. Without OpDef, Python side legalize_ops cannot find the Op via Op.get(), causing 'Operator not registered' errors during import. Add OpDef for: relax.image.dilation2d, relax.nn.correlation, relax.nn.lrn, relax.nn.dilate.
- Fix isinstance() calls to use X | Y union syntax (UP038) - Apply ruff-format to Python files - Apply clang-format to C++ files
- Remove incorrect 'from tvm_tirx import DataType' imports from image.py and nn.py - Replace all 'DataType' type annotations with 'tvm_ffi.dtype' - The original PR mistakenly replaced tvm_ffi.dtype with DataType, which caused NameError at module import time since DataType is not available in the runtime namespace.
This branch has not been deployed
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.
Adding 4 Relax ops backed by existing TOPI implementations.