Skip to content

Commit

Permalink
torch 1.6 does not have tensor.index
Browse files Browse the repository at this point in the history
  • Loading branch information
HaiwangYu committed Oct 5, 2024
1 parent 6f017b9 commit 0b7cedc
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions pytorch/test/check_chunking.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ int main(int argc, const char* argv[])

// Disable gradient computation, use like a mutex lock
torch::NoGradGuard no_grad;
if (false) {
torch::Tensor a = torch::rand({1, 2, 3, 3});
std::cout << "Tensor shape: " << a.sizes() << std::endl;
std::cout << a << std::endl;
// Extract the desired sub-tensor using the slice method
torch::Tensor sub_tensor = a.index({torch::indexing::Slice(), torch::indexing::Slice(1, 2), torch::indexing::Slice(), torch::indexing::Slice()});
// Print the shape of the extracted tensor
std::cout << "Sub-tensor shape: " << sub_tensor.sizes() << std::endl;
std::cout << sub_tensor << std::endl;
}
// if (false) {
// torch::Tensor a = torch::rand({1, 2, 3, 3});
// std::cout << "Tensor shape: " << a.sizes() << std::endl;
// std::cout << a << std::endl;
// // Extract the desired sub-tensor using the slice method
// torch::Tensor sub_tensor = a.index({torch::indexing::Slice(), torch::indexing::Slice(1, 2), torch::indexing::Slice(), torch::indexing::Slice()});
// // Print the shape of the extracted tensor
// std::cout << "Sub-tensor shape: " << sub_tensor.sizes() << std::endl;
// std::cout << sub_tensor << std::endl;
// }
{
Eigen::MatrixXf ch_eigen = Eigen::MatrixXf::Identity(4, 4);
std::cout << "matrix: \n" << ch_eigen << std::endl;
Expand Down

0 comments on commit 0b7cedc

Please sign in to comment.