apple / apple/coremltools

What is _ctx_tx_to_fallback_0 in context_transfer type ?

Open
#1,975 1 comment 0 reactions 0 assignees View on GitHub
question
Dominant language
Python
Stars
5.4k
Forks
850
Avg merge
4d 5h
Merged PRs (30d)
10

Description

## ❓Question

I am not sure if this question is about coremltools or the Core ML Frame work or Xcode.

Here is an example to convert a simple pytorch model to coreml model.

```python
import torch
import torch.nn as nn
import coremltools as ct

class SimpleModel(nn.Module):

def __init__(self,):
super(SimpleModel, self).__init__()

self.weight = nn.Parameter(torch.randn(8, 8, 3, 3))

def forward(self, x):
return x * self.weight

if __name__ == '__main__':

model_pytorch = SimpleModel()
model_pytorch.eval()

input_example = torch.randn(8, 8, 1, 1)
model_traced = torch.jit.trace(model_pytorch, input_example)

model_coreml = ct.convert(
model_traced,
convert_to = 'neuralnetwork',
source = 'pytorch',
inputs = [ct.TensorType(name='x', shape=[8, 8, 1, 1])],
outputs = [ct.TensorType(name='output')],
compute_units = ct.ComputeUnit.ALL,
)
model_coreml.save('SimpleModel.mlmodel')
```

Then, open the **SimpleModel.mlmodel** in XCode and generate a performance report as shown below:

simplemodel_performance_report

## The Questions are:

- What is **_ctx_tx_to_fallback_0** in **context_transfer** type ?
I found nothing about **_ctx_tx_to_fallback_0** or **context_transfer** in Core ML documentation.
- How to modify the code to make this operation work on Neural Engine ?

## Environment:

- macOS Ventura 13.5.2
- XCode 14.3.1
- Python 3.8.17
- coremltools 7.0b2
- torch 2.0.0

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the provided Python/PyTorch conversion example with coremltools 7.0b2 and opening the generated SimpleModel.mlmodel in Xcode 14.3.1. Inspect the performance report's context_transfer entry and compare the reported execution device with the requested Neural Engine behavior; done means explaining the entry and determining whether the example can run that operation on the Neural Engine.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.