5 #include <THPP/tensors/THTensor.hpp> 10 thpp::FloatTensor* tensor =
new thpp::THTensor<float>();
11 thpp::FloatTensor* tensor2 =
new thpp::THTensor<float>();
12 assert(tensor->nDim() == 0);
14 tensor->resize({1, 2, 3});
15 assert(tensor->nDim() == 3);
17 for (
auto s : tensor->sizes())
20 vector<int64_t> sizes = {2, 2};
21 tensor2->resize(sizes);
23 tensor->add(*tensor2, 1);
24 assert(tensor->nDim() == 2);
26 for (
auto s : tensor->sizes())
28 for (
int i = 0; i < 2; i++)
29 assert(reinterpret_cast<float*>(tensor->data())[i] == 5);
33 thpp::IntTensor& a =
dynamic_cast<thpp::IntTensor&
>(*tensor);
34 }
catch (std::bad_cast& e) {