Getting issue in convert PyTorch model to CoreML using CoreMLTool Kit.

Hello Developers,

We are trying to convert Pytorch models to CoreML using coremltools, while converting we used jit.trace to create trace of model where we encountered a warning that if model has controlflow and conditions it is not advisable to use trace instead convert into TorchScript using jit.script,

However after successful conversion of model into TorchScript, Now in the next step of conversion from TorchScript to CoreML here is the error we are getting when we tried to convert to coremltools python package.

This root error is so abstract that we are not able to trace-back from where its occurring.

AssertionError: Item selection is supported only on python list/tuple objects

We trying to add this above error prompt into ChatGPT and we get something like the below response from ChatGPT. But unfortunately it's not working.

The error indicates that the Core ML converter encountered a TorchScript operation involving item selection (indexing or slicing) on an object that it doesn't recognize as a Python list or tuple. The converter supports item selection only on these Python container types. This could happen if your model uses indexing on tensors or other types not recognized as list or tuple by the Core ML tools. You may need to revise the TorchScript code to ensure it only performs item selection on supported types or adjust the way tensors are indexed.

Getting issue in convert PyTorch model to CoreML using CoreMLTool Kit.
 
 
Q