dbsystel / yolov5-coreml-tools

Scripts for exporting YOLOv5 models to CoreML and benchmarking it.
Apache License 2.0
66 stars 9 forks source link

CoreML conversion failure: PyTorch convert function for op 'silu_' not implemented. #10

Open Jacobsolawetz opened 2 years ago

Jacobsolawetz commented 2 years ago

CoreML conversion failure: PyTorch convert function for op 'silu_' not implemented.

It seems like my coreml tools are having an issue with registering the silu opp here - Has anyone else encountered this issue?

https://github.com/dbsystel/yolov5-coreml-tools/blob/61a7441ad5b13c1d284e9a64ded8be6cef0b591e/src/coreml_export/main.py#L26

Jacobsolawetz commented 2 years ago

Added this and seems to be registering now

@register_torch_op
def silu_(context, node):
    inputs = _get_inputs(context, node, expected=1)
    x = inputs[0]
    y = mb.sigmoid(x=x)
    z = mb.mul(x=x, y=y, name=node.name)
    context.add(z)
Leon0402 commented 2 years ago

Sorry for the very late response. These sort of issues are because of a mismatch of the pyTorch version coreml supports and yolov5 uses. Registering missing operators yourself is one workaround for this. And as you quoted I already this this for silu.

Not sure what silu_ is or how it's different from silu, but what you did seems exactly right to me.

Perhaps the library should be upgraded to a newer coreml version and be tested against new yolov5 versions, but I don't have the time to this myself.