AllentDan / LibtorchTutorials

This is a code repository for pytorch c++ (or libtorch) tutorial.
Apache License 2.0
742 stars 122 forks source link

index_put_() #19

Closed jerry9055 closed 1 year ago

jerry9055 commented 2 years ago

Hi, I am new to libtorch/c++, and I confused when setting values to a torch::Tensor with indexput() here is my case image I fail to set values except for X[0][...] Would you like to tell me how to set values in Tensor? Thanks

AllentDan commented 2 years ago

The combination of indexput and index functions can achieve this task. https://github.com/AllentDan/LibtorchTutorials/tree/main/lesson2-TensorOperations