Open w4-jihunlorenzopark opened 1 week ago
Well, it turns out can be resolved by adding with very simple snippet in my code.
from coremltools.converters.mil.frontend.torch import torch_op_registry
from coremltools.converters.mil.frontend.torch import ops
@torch_op_registry.register_torch_op
def intimplicit(context, node):
return ops._int(context, node)
How do you think adding this function to registered ops list https://github.com/apple/coremltools/blob/main/coremltools/converters/mil/frontend/torch/ops.py ?
Thanks @w4-jihunlorenzopark for reporting and a suggested fix.
Alternatively, seems like it could be resolved with adding an alias entry to
@register_torch_op(torch_alias=["int", "intimplicit"])
here.
It would be great if you can create a PR for this! Thanks.
Thanks for reply @DawerG . I confirmed it works in my case and just made a PR.
🌱 Describe your Feature Request
Hello, I would like to request a feature to convert
aten::IntImplicit
ops.How can this feature be used?
This is to resolve error described in another issue which is
RuntimeError: PyTorch convert function for op 'intimplicit' not implemented.
From my digging, this
aten::IntImplicit
appears when we try to use zero dim integer tensor (such astensor.tensor(1)
) in the place requiring native integer type.For my case, my module has slicing code in torch.jit.script function
which will occur
RuntimeError: PyTorch convert function for op 'intimplicit' not implemented.
during callingct.convert
function. The openvino, which is for intel cpus seems to have the translation for IntImplicit ops. I believe implementing this ops will help the coremltools users convert many open source models in the wild, where authors may not be care about this error during coremltools conversion.Describe alternatives you've considered
I am trying to figure out how can I run the same logic without seeing IntImplicit op. Any workaround will be welcomed!
Additional context
Here is a simple reproducible code to get the
RuntimeError: PyTorch convert function for op 'intimplicit' not implemented.
error.Here is the TorchScript graph of select_with_tensor
Thanks for reading this. I am new to coremltools and its codebase, so if someone provide me references or guide about how to implement this, I am gladly willing to make PR for this.