Refactor folder structure of the project

This commit is contained in:
2023-07-01 02:33:26 +02:00
parent 52cb85b41b
commit 79e7912ab3
23 changed files with 13 additions and 108 deletions

60
sample/test.cc Normal file
View File

@@ -0,0 +1,60 @@
// #include <torch/torch.h>
// int main()
// {
// torch::Tensor t = torch::rand({ 5, 5 });
// // Print original tensor
// std::cout << t << std::endl;
// // New value
// torch::Tensor new_val = torch::tensor(10.0f);
// // Indices for the cell you want to update
// auto index_i = torch::tensor({ 2 });
// auto index_j = torch::tensor({ 3 });
// // Update cell
// t.index_put_({ index_i, index_j }, new_val);
// // Print updated tensor
// std::cout << t << std::endl;
// }
#include <torch/torch.h>
int main()
{
//torch::Tensor t = torch::rand({ 5, 4, 3 }); // 3D tensor for this example
//int i = 3, j = 1, k = 2; // Indices for the cell you want to update
// Print original tensor
torch::Tensor t = torch::tensor({ {1, 2, 3}, {4, 5, 6} }); // 3D tensor for this example
std::cout << t << std::endl;
std::cout << "sum(0)" << std::endl;
std::cout << t.sum(0) << std::endl;
std::cout << "sum(1)" << std::endl;
std::cout << t.sum(1) << std::endl;
std::cout << "Normalized" << std::endl;
std::cout << t / t.sum(0) << std::endl;
// New value
// torch::Tensor new_val = torch::tensor(10.0f);
// // Indices for the cell you want to update
// std::vector<torch::Tensor> indices;
// indices.push_back(torch::tensor(i)); // Replace i with your index for the 1st dimension
// indices.push_back(torch::tensor(j)); // Replace j with your index for the 2nd dimension
// indices.push_back(torch::tensor(k)); // Replace k with your index for the 3rd dimension
// //torch::ArrayRef<at::indexing::TensorIndex> indices_ref(indices);
// // Update cell
// //torch::Tensor result = torch::stack(indices);
// //torch::List<c10::optional<torch::Tensor>> indices_list = { torch::tensor(i), torch::tensor(j), torch::tensor(k) };
// torch::List<c10::optional<torch::Tensor>> indices_list;
// indices_list.push_back(torch::tensor(i));
// indices_list.push_back(torch::tensor(j));
// indices_list.push_back(torch::tensor(k));
// //t.index_put_({ torch::tensor(i), torch::tensor(j), torch::tensor(k) }, new_val);
// t.index_put_(indices_list, new_val);
// // Print updated tensor
// std::cout << t << std::endl;
}