Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom ONNX node implementation not registering #129

Open
vselhakim1337 opened this issue May 13, 2023 · 0 comments
Open

Custom ONNX node implementation not registering #129

vselhakim1337 opened this issue May 13, 2023 · 0 comments

Comments

@vselhakim1337
Copy link

I'm trying to externally add and register a custom implementation for an ONNX op. For the sake of context, the op in question is ONNXMul. I've tried following the code snippet in the documentation, and I've come up with this:

@op_implementation(op="Mul", name="myimpl")
class FPGAMul(ONNXForward):
    @staticmethod
    def forward_can_be_applied(node: ONNXOp, state: SDFGState, sdfg: SDFG) -> bool:
        ...

    @staticmethod
    def forward(node: ONNXOp, state: SDFGState, sdfg: SDFG) -> typing.Union[Node, SDFG]:
        ...
        
daceml.onnx.default_implementation = 'myimpl'
    

This piece of code resides in the same Python script that loads an ONNX model and expands the library nodes. Namely, somewhere later in the script I have

    model = onnx.load(model_path)
    dace_model = daceml.onnx.ONNXModel(name, model)
    print ('ONNX model loaded...')
    dace_model.sdfg.expand_library_nodes()

However this results in an error:

Traceback (most recent call last):
  File "load.py", line 114, in predict_daceml
    dace_model.sdfg.expand_library_nodes()
  File ".../dace/sdfg/sdfg.py", line 2559, in expand_library_nodes
    impl_name = node.expand(self, state)
  File ".../dace/sdfg/nodes.py", line 1269, in expand
    raise KeyError("Unknown implementation for node {}: {}".format(type(self).__name__, implementation))
KeyError: 'Unknown implementation for node ONNXMul: myimpl'

Can you tell me why my implementation is not registering, and how to fix this?

@vselhakim1337 vselhakim1337 changed the title Custon ONNX node implementation not registering Custom ONNX node implementation not registering May 13, 2023
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

No branches or pull requests

1 participant