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

Function TEST_F

tests/test_tensor_masking.cpp:84–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

82// ============= Comparison Operations Tests =============
83
84TEST_F(TensorMaskingTest, ComparisonEqual) {
85 std::vector<float> a_data = {1, 2, 3, 4, 5};
86 std::vector<float> b_data = {1, 0, 3, 0, 5};
87
88 auto a_custom = Tensor::from_vector(a_data, {5}, Device::CUDA);
89 auto b_custom = Tensor::from_vector(b_data, {5}, Device::CUDA);
90 auto t = Tensor::zeros({1, 2});
91
92 auto a_torch = torch::tensor(a_data, torch::kCUDA);
93 auto b_torch = torch::tensor(b_data, torch::kCUDA);
94
95 auto mask_custom = a_custom.eq(b_custom);
96 auto mask_torch = a_torch.eq(b_torch);
97
98 compare_tensors(mask_custom, mask_torch, 1e-5f, 1e-7f, "ComparisonEqual");
99
100 // Test scalar comparison
101 auto mask2_custom = a_custom.eq(3.0f);
102 auto mask2_torch = a_torch.eq(3.0f);
103
104 compare_tensors(mask2_custom, mask2_torch, 1e-5f, 1e-7f, "ComparisonEqualScalar");
105}
106
107TEST_F(TensorMaskingTest, ComparisonLessThan) {
108 std::vector<float> a_data = {1, 2, 3, 4, 5};

Callers

nothing calls this directly

Calls 15

from_vectorFunction · 0.85
whereFunction · 0.85
fullFunction · 0.85
dtype_nameFunction · 0.85
TensorOptionsClass · 0.85
eqMethod · 0.80
ltMethod · 0.80
gtMethod · 0.80
logical_andMethod · 0.80
geMethod · 0.80
leMethod · 0.80
neMethod · 0.80

Tested by

no test coverage detected