NotImplementedError: Only tensor assignment with exactly 1 pure dimension selection is supported
- Dominant language
- Python
- Stars
- 5.4k
- Forks
- 850
- Avg merge
- 4d 5h
- Merged PRs (30d)
- 10
Description
## 🌱 Describe your Feature Request
Coremltools 5.2 only supports tensor assignment with exactly 1 pure dimension selection. I'm trying to convert a model from pytorch to coreml, which involves more flexible tensor assignments, as in the use case. After running the code, it raises a NotImplementedError("Only tensor assignment with exactly 1 pure dimension selection is supported"). It would be great if the feature could be supported.
## Use case
```
import torch
import torch.nn as nn
import coremltools as ct
class Model(nn.Module):
def __init__(self):
super().__init__()
def forward(self, x):
x[:, :4, :-1, :-1] = 0
return x
if __name__ == "__main__":
x = torch.randn(1, 3, 8, 8)
model = Model()
model.eval()
y = model(x)
torchscript_model = torch.jit.trace(model, x)
coreml_model = ct.convert(
torchscript_model,
inputs=[ct.ImageType(name="x_1",
shape=x.shape)]
)
```
Contributor guide
Research direction
Reproduce the provided Model and torch.jit.trace example, then follow the PyTorch-to-Core ML conversion through ct.convert. Locate the conversion path that raises the stated NotImplementedError and identify the existing tensor-assignment handling; done means the example converts without that error while preserving the assignment behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- machine-learning
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100