| 34 | namespace { |
| 35 | |
| 36 | TEST_F(OpenCLOperationTest, Softmax1x1) { |
| 37 | TensorFloat32 src_tensor; |
| 38 | src_tensor.shape = BHWC(1, 1, 1, 4); |
| 39 | src_tensor.data = {std::log(1.0f), std::log(2.0f), std::log(3.0f), |
| 40 | std::log(4.0f)}; |
| 41 | |
| 42 | for (auto storage : env_.GetSupportedStorages()) { |
| 43 | for (auto precision : env_.GetSupportedPrecisions()) { |
| 44 | const float eps = precision == CalculationsPrecision::F32 ? 1e-6f : 1e-3f; |
| 45 | OperationDef op_def; |
| 46 | op_def.precision = precision; |
| 47 | auto data_type = DeduceDataTypeFromPrecision(precision); |
| 48 | op_def.src_tensors.push_back({data_type, storage}); |
| 49 | op_def.dst_tensors.push_back({data_type, storage}); |
| 50 | TensorFloat32 dst_tensor; |
| 51 | Softmax1x1 operation = CreateSoftmax1x1(op_def); |
| 52 | ASSERT_OK(ExecuteGPUOperation(src_tensor, creation_context_, &operation, |
| 53 | BHWC(1, 1, 1, 4), &dst_tensor)); |
| 54 | EXPECT_THAT(dst_tensor.data, |
| 55 | Pointwise(FloatNear(eps), {0.1f, 0.2f, 0.3f, 0.4f})); |
| 56 | } |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | } // namespace |
| 61 | } // namespace cl |
nothing calls this directly
no test coverage detected