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

Function TEST_F

tests/test_tensor_ops.cpp:103–122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

101// ============= Scalar Operations =============
102
103TEST_F(TensorOpsTest, ScalarAdd) {
104 std::vector<float> data(12);
105 for (auto& val : data)
106 val = dist(gen);
107
108 auto custom_tensor = Tensor::from_vector(data, {3, 4}, Device::CUDA);
109 auto torch_tensor = torch::tensor(data, torch::TensorOptions().device(torch::kCUDA))
110 .reshape({3, 4});
111
112 float scalar = 2.5f;
113
114 auto custom_result = custom_tensor.add(scalar);
115 auto torch_result = torch_tensor + scalar;
116
117 compare_tensors(custom_result, torch_result, 1e-5f, 1e-6f, "ScalarAdd");
118
119 // Test operator overload
120 auto custom_result2 = custom_tensor + scalar;
121 compare_tensors(custom_result2, torch_result, 1e-5f, 1e-6f, "ScalarAdd_Operator");
122}
123
124TEST_F(TensorOpsTest, ScalarSubtract) {
125 std::vector<float> data(10);

Callers

nothing calls this directly

Calls 15

from_vectorFunction · 0.85
TensorOptionsClass · 0.85
powFunction · 0.85
logFunction · 0.85
maximumFunction · 0.85
minimumFunction · 0.85
clamp_minFunction · 0.85
clamp_maxFunction · 0.85
subMethod · 0.80
mulMethod · 0.80
divMethod · 0.80
expMethod · 0.80

Tested by

no test coverage detected