| 31 | // ===== Stack dim=2 correctness (the root cause bug) ===== |
| 32 | |
| 33 | TEST_F(ExpandedTensorOpsTest, StackDim2_Correctness) { |
| 34 | const size_t H = 4, W = 3; |
| 35 | auto r = Tensor::full({H, W}, 0.25f, Device::CUDA); |
| 36 | auto g = Tensor::full({H, W}, 0.50f, Device::CUDA); |
| 37 | auto b = Tensor::full({H, W}, 0.75f, Device::CUDA); |
| 38 | |
| 39 | auto stacked = Tensor::stack({r, g, b}, 2); |
| 40 | assert_cuda_ok("stack dim=2"); |
| 41 | |
| 42 | ASSERT_EQ(stacked.size(0), static_cast<int>(H)); |
| 43 | ASSERT_EQ(stacked.size(1), static_cast<int>(W)); |
| 44 | ASSERT_EQ(stacked.size(2), 3); |
| 45 | |
| 46 | auto cpu = stacked.cpu(); |
| 47 | auto* p = cpu.ptr<float>(); |
| 48 | for (size_t row = 0; row < H; ++row) { |
| 49 | for (size_t col = 0; col < W; ++col) { |
| 50 | size_t base = (row * W + col) * 3; |
| 51 | EXPECT_FLOAT_EQ(p[base + 0], 0.25f) |
| 52 | << "R at [" << row << "," << col << "]"; |
| 53 | EXPECT_FLOAT_EQ(p[base + 1], 0.50f) |
| 54 | << "G at [" << row << "," << col << "]"; |
| 55 | EXPECT_FLOAT_EQ(p[base + 2], 0.75f) |
| 56 | << "B at [" << row << "," << col << "]"; |
| 57 | } |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | TEST_F(ExpandedTensorOpsTest, StackDim2_256x256) { |
| 62 | auto r = Tensor::full({256, 256}, 0.1f, Device::CUDA); |
nothing calls this directly
no test coverage detected