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

Function TEST_F

tests/test_tensor_matrix.cpp:71–95  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

69// ============= Matrix Multiplication Tests =============
70
71TEST_F(TensorMatrixTest, MatMul2D) {
72 // Test basic 2D matrix multiplication: (2x3) @ (3x2) = (2x2)
73 std::vector<float> data_a = {1, 2, 3,
74 4, 5, 6}; // 2x3
75 std::vector<float> data_b = {7, 8,
76 9, 10,
77 11, 12}; // 3x2
78
79 auto custom_a = Tensor::from_vector(data_a, {2, 3}, Device::CUDA);
80 auto custom_b = Tensor::from_vector(data_b, {3, 2}, Device::CUDA);
81
82 auto torch_a = torch::tensor(data_a, torch::TensorOptions().device(torch::kCUDA))
83 .reshape({2, 3});
84 auto torch_b = torch::tensor(data_b, torch::TensorOptions().device(torch::kCUDA))
85 .reshape({3, 2});
86
87 auto custom_result = custom_a.matmul(custom_b);
88 auto torch_result = torch::matmul(torch_a, torch_b);
89
90 compare_tensors(custom_result, torch_result, 1e-4f, 1e-5f, "MatMul2D");
91
92 // Test mm() alias - should give same result
93 auto custom_mm = custom_a.mm(custom_b);
94 compare_tensors(custom_mm, torch_result, 1e-4f, 1e-5f, "MM_Alias");
95}
96
97TEST_F(TensorMatrixTest, MatMulVectorMatrix) {
98 // Test vector-matrix multiplication: (3,) @ (3x2) = (2,)

Callers

nothing calls this directly

Calls 15

from_vectorFunction · 0.85
TensorOptionsClass · 0.85
fullFunction · 0.85
numelMethod · 0.80
shapeMethod · 0.80
transposeMethod · 0.80
to_vectorMethod · 0.80
sum_scalarMethod · 0.80
all_closeMethod · 0.80
compare_tensorsFunction · 0.70
dotFunction · 0.50
reshapeMethod · 0.45

Tested by

no test coverage detected