Open jamesETsmith opened 3 years ago
I believe the problem is that TACO currently does not support in-place updates of tensor elements, so tensor(0, 0) = 11.0;
will actually allocate a new tensor under the hood. If you really need to update tensor elements in-place, then one option would be to get a reference to the underlying array that stores the values and then modify that directly by doing something like:
double* arr = (double*)tensor.getStorage().getValues().getData();
arr[0] = 11;
(Note that this assumes the tensor is dense; if it is stored in a sparse format, then that'd be more difficult since you'd also have to update the index arrays.) In the long run though, we would definitely like to extend TACO to support in-place updates of tensor elements, which would solve problems like this.
Summary
Hello! I'm playing around with TACO and would like to pass some NumPy tensors to C++ and convert them to TACO's
Tensor
type before working with them in C++, but I'm finding that the modifications I make on the C++ side of things are not reflected in the original NumPy array. I tried to explicitly avoid copying here so I thought any modifications I made in C++ should show up in the original NumPy array. Am I missing something here?Minimal Example
Here is a minimal example adapted from
taco/python_bindings/src/pyTensor.cpp
:And a minimal Python test script:
Which has the following output:
Possible Solutions
Maybe some complicated things going on under the hood with Pybind11?
Any ideas/suggestions, would be much appreciated!