| 78 | // ============= Basic Scalar Reductions ============= |
| 79 | |
| 80 | TEST_F(TensorReductionTest, Sum) { |
| 81 | std::vector<float> data = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; |
| 82 | |
| 83 | auto custom_tensor = Tensor::from_vector(data, {10}, Device::CUDA); |
| 84 | auto torch_tensor = torch::tensor(data, torch::TensorOptions().device(torch::kCUDA)); |
| 85 | |
| 86 | float custom_sum = custom_tensor.sum_scalar(); |
| 87 | float torch_sum = torch_tensor.sum().item<float>(); |
| 88 | |
| 89 | compare_scalars(custom_sum, torch_sum, 1e-4f, "Sum"); |
| 90 | EXPECT_FLOAT_EQ(custom_sum, 55.0f); |
| 91 | } |
| 92 | |
| 93 | TEST_F(TensorReductionTest, SumMultiDim) { |
| 94 | std::vector<float> data(24); |
nothing calls this directly
no test coverage detected