apple / apple/coremltools

[PyTorch] torch.listconstruct causing issue for other ops

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

Description

This is the root cause to many issues. When symbolic shape is involved in `torch.listconstruct`, instead of a CoreML tensor, we simply return the list as is
```
def _array_construct(context, node, array_type):

...

else:
# If at least one input to the construct op is non-const, collect
# the inputs and add them directly to the context. Ops that use this
# node's output will take the list directly as input.
context.add(array_type(inputs), node.name)
```

## Appendix 1: Issues Sharing the Same Root Cause
* [#1303](https://github.com/apple/coremltools/issues/1303)
* [#1921](https://github.com/apple/coremltools/issues/1921)
* [#1991](https://github.com/apple/coremltools/issues/1991)
* [#2037](https://github.com/apple/coremltools/issues/2037)

## Appendix 2: Ops Impacted by the Root Cause
* `torch.GroupNorm`
* `torch.pad`
* `torch.index_put`

Contributor guide

Open the contributing guide

Research direction

Start at the _array_construct entry point shown in the issue and trace how symbolic-shape torch.listconstruct outputs are consumed by GroupNorm, torch.pad, and torch.index_put conversion. Review the related issues for expected behavior and add regression coverage for the affected operations. Done means those operations no longer fail because a symbolic construct output is passed through as a raw list.

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
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.