| 32 | namespace { |
| 33 | |
| 34 | TEST_F(OpenCLOperationTest, ConvTextureSimpleWeights) { |
| 35 | TensorFloat32 src_tensor; |
| 36 | src_tensor.shape = BHWC(1, 2, 2, 2); |
| 37 | src_tensor.data = {0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f}; |
| 38 | |
| 39 | Convolution2DAttributes attr; |
| 40 | attr.padding.prepended = HW(0, 0); |
| 41 | attr.padding.appended = HW(1, 1); |
| 42 | attr.strides = HW(1, 1); |
| 43 | attr.dilations = HW(1, 1); |
| 44 | attr.weights.shape = OHWI(1, 2, 2, 2); |
| 45 | attr.weights.data = {1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f}; |
| 46 | attr.bias.shape = Linear(1); |
| 47 | attr.bias.data = {0.0f}; |
| 48 | |
| 49 | for (auto storage : env_.GetSupportedTextureStorages()) { |
| 50 | for (auto precision : env_.GetSupportedPrecisions()) { |
| 51 | const float eps = precision == CalculationsPrecision::F32 ? 1e-6f : 1e-3f; |
| 52 | OperationDef op_def; |
| 53 | op_def.precision = precision; |
| 54 | auto data_type = DeduceDataTypeFromPrecision(precision); |
| 55 | op_def.src_tensors.push_back({data_type, storage}); |
| 56 | op_def.dst_tensors.push_back({data_type, storage}); |
| 57 | TensorFloat32 dst_tensor; |
| 58 | ConvTexture operation; |
| 59 | ASSERT_OK(CreateConvTexture(creation_context_, op_def, attr, &operation)); |
| 60 | ASSERT_OK(ExecuteGPUOperation(src_tensor, creation_context_, &operation, |
| 61 | BHWC(1, 2, 2, 1), &dst_tensor)); |
| 62 | EXPECT_THAT(dst_tensor.data, |
| 63 | Pointwise(FloatNear(eps), {28.0f, 18.0f, 22.0f, 13.0f})); |
| 64 | } |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | TEST_F(OpenCLOperationTest, ConvTexture) { |
| 69 | TensorFloat32 src_tensor; |
nothing calls this directly
no test coverage detected