-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Torch] Add copy_ operator #7513
Conversation
This came up many times, we probably do not want to support this due to a lack of inplace op support in Relay. See #7231 |
@masahi I tried to add the following to
Yes it replaces Test Module:
After jit_passes
As you can see %15 is empty list. As a result we get TVM error because index_put indices array is empty:
|
@masahi This PR uses |
The point is, no matter how we try to support Rather than adding |
I think we already have 16 in-place operators ending with
Is |
Yeah, this is a tricky issue. Some inplace ops are benign (like cc @t-vi our favorite topic again |
@apivovarov If you really need to support this conversion and you are sure your conversion should work, you can use a custom convert map. See tvm/tests/python/frontend/pytorch/test_forward.py Line 1916 in 50e013d
|
What if we add log.warn message - This default |
I generally don't like a half baked solution, but if that allows more models to run on TVM, that doesn't sound too bad. If people agree with this, I think we can go with this @t-vi @siju-samuel @kevinthesun @codeislife99 @alexwong @apivovarov If you want to pursue this path, please revisit the |
I prepared a test model which uses both
Relay graph:
|
People never use |
What could be the example of more realistic Net with |
One example I know is in-place assignment like this https://github.com/pytorch/vision/blob/433283ebbf629c8b5bf27e28af7265267ac0af00/torchvision/ops/poolers.py#L269 |
What Net can represent it? Can you make a test Net to demonstrate it? |
Here is another example
|
We should include such test cases in this PR. |
Can you also address the test case in #7231 ? #7231 (comment) |
Net
Torch graph:
Relay graph has
|
Probably it is better to rewrite the following 4 lines in the model itself.
|
|
Add copy_ operator to PyTorch frontend.
Operator description:
https://pytorch.org/docs/stable/tensors.html#torch.Tensor.copy_
Related discussions:
https://discuss.tvm.apache.org/t/copy-opertor-in-relay/9212