coremltools icon indicating copy to clipboard operation
coremltools copied to clipboard

Add torch ops for d2go models

Open dncnbuck opened this issue 3 years ago • 8 comments

added torch ops

nms
repeat_interleave
numel
roi_align
logicaland

ops with minor patches

clamp
narrow 
index - handle broadcasting indicies
max -  inputs are len == 1
split - handle case when num_splits == 1
to -  handle the case where the dtype is not set, this should be inferred from the Tensor dtype. see, https://pytorch.org/docs/stable/generated/torch.Tensor.to.html?highlight=#torch.Tensor.to
tupleunpack - handle case when len(output) == 1

these were added in order to make progress with a conversion of pytorch Mask-RCNN model from d2go / detectron2.

Form more details see: https://github.com/apple/coremltools/issues/1505#issuecomment-1148436445

dncnbuck avatar Jun 07 '22 11:06 dncnbuck

@TobyRoseman "We need unit tests for the bug fixes and the new ops. @dncnbuck - can you add that?"

Yeah good point. I'll be able to add these but this might not happen today sadly. I'll try to get to it this week 😄

dncnbuck avatar Jun 08 '22 10:06 dncnbuck

I'll be able to add these but this might not happen today sadly. I'll try to get to it this week 😄

No worries about the timing. Let me know if you have any questions when adding the unit tests.

TobyRoseman avatar Jun 08 '22 23:06 TobyRoseman

@dncnbuck did you manage to fix this issue by any chance? I will be thankful for your response

luliuzee avatar Jul 10 '22 14:07 luliuzee

@TobyRoseman sorry this dropped off of my radar these last months. I've updated the Pr to include some tests for ops and removed the repeat interleave op implementation for the time being as it was not implemented well enough so I will hold out on adding that until I can give it some time

dncnbuck avatar Sep 03 '22 08:09 dncnbuck

@dncnbuck - no worries about this falling off your radar. Thanks for getting back to it.

Please rebase this pull request on top of main. Then I will kick off a CI run.

TobyRoseman avatar Sep 07 '22 21:09 TobyRoseman

Has this PR been included? i.e. is it possible to convert d2go models to coreml?

diegogranziol avatar Jan 15 '23 08:01 diegogranziol

Has this PR been included? i.e. is it possible to convert d2go models to coreml?

+1 would love to know the status on this PR, adding these ops would be a huge benefit to me

kells1986 avatar Jun 29 '23 09:06 kells1986

Has this PR been included? i.e. is it possible to convert d2go models to coreml?

+1 would love to know the status on this PR, adding these ops would be a huge benefit to me

So has anyone successfully converted a detectron2 / d2go model to coreml? I have been struggling with this as using cocoapods are not ideal for me.

michaelbinary avatar Aug 22 '23 06:08 michaelbinary