| 33 | namespace { |
| 34 | |
| 35 | TEST_F(OpenCLOperationTest, MultiplyAddVectorMul) { |
| 36 | TensorFloat32 src_tensor; |
| 37 | src_tensor.shape = BHWC(1, 2, 1, 2); |
| 38 | src_tensor.data = {0.0f, 1.0f, 2.0f, 3.0f}; |
| 39 | |
| 40 | MultiplyScalarAttributes attr; |
| 41 | ::tflite::gpu::Tensor<Linear, DataType::FLOAT32> parameters; |
| 42 | parameters.shape = Linear(2); |
| 43 | parameters.data = {0.5f, 2.0f}; |
| 44 | attr.param = parameters; |
| 45 | |
| 46 | for (auto storage : env_.GetSupportedStorages()) { |
| 47 | for (auto precision : env_.GetSupportedPrecisions()) { |
| 48 | const float eps = precision == CalculationsPrecision::F32 ? 1e-6f : 1e-3f; |
| 49 | OperationDef op_def; |
| 50 | op_def.precision = precision; |
| 51 | auto data_type = DeduceDataTypeFromPrecision(precision); |
| 52 | op_def.src_tensors.push_back({data_type, storage}); |
| 53 | op_def.dst_tensors.push_back({data_type, storage}); |
| 54 | TensorFloat32 dst_tensor; |
| 55 | MultiplyAdd operation; |
| 56 | ASSERT_OK(CreateMultiplyAdd(creation_context_, op_def, attr, &operation)); |
| 57 | ASSERT_OK(ExecuteGPUOperation(src_tensor, creation_context_, &operation, |
| 58 | BHWC(1, 2, 1, 2), &dst_tensor)); |
| 59 | EXPECT_THAT(dst_tensor.data, |
| 60 | Pointwise(FloatNear(eps), {0.0f, 2.0f, 1.0f, 6.0f})); |
| 61 | } |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | TEST_F(OpenCLOperationTest, MultiplyAddVectorAdd) { |
| 66 | TensorFloat32 src_tensor; |
nothing calls this directly
no test coverage detected