MCPcopy Create free account
hub / github.com/MrNeRF/LichtFeld-Studio / TEST_F

Function TEST_F

tests/test_tensor_reduction.cpp:80–91  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

78// ============= Basic Scalar Reductions =============
79
80TEST_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
93TEST_F(TensorReductionTest, SumMultiDim) {
94 std::vector<float> data(24);

Callers

nothing calls this directly

Calls 15

from_vectorFunction · 0.85
TensorOptionsClass · 0.85
compare_scalarsFunction · 0.85
sum_scalarMethod · 0.80
mean_scalarMethod · 0.80
min_scalarMethod · 0.80
max_scalarMethod · 0.80
minmaxMethod · 0.80
stdMethod · 0.80
varMethod · 0.80
ndimMethod · 0.80
shapeMethod · 0.80

Tested by

no test coverage detected