Open ghostplant opened 1 year ago
Did you manage to implement this?
Would be great to have an example of this in open_registration_extension.cpp
The DLPrimitives for PyTorch repo has an example in the tensor_ops.cpp file. Seems like the implementation should be identical for the example in open_registration_extension.cpp
(it just creates an alias and contains some logic to infer the size if -1
is given).
If you wanted to implement the view
operation such that you could print tensors (like me) and it cannot fallback to CPU you will run into another issue where a _copy_from
operation will fail because src
and dst
vectors have different sizes. Seems like it will require a bit of work to get that working.
Thanks, I stared it!
📚 The doc issue
The original code is:
Then I get following errors:
According to some interface declaration in Pytorch source code, the extension looks like this:
However, it results in infinite recursive call of this function and ends with stack overflow. I don't think
x.view([2, -1])
really requires user to define its implementation. If this definition is a must, what documentation can I refer to get it passed correctly?Suggest a potential alternative/fix
An document example of how to implement custom
aten::view
, or any simpler solutions to solve the reshape problem above.cc @malfet @zou3519 @svekars @carljparker