| 34 | namespace { |
| 35 | |
| 36 | TEST_F(OpenCLOperationTest, Sigmoid) { |
| 37 | TensorFloat32 src_tensor; |
| 38 | src_tensor.shape = BHWC(1, 2, 1, 2); |
| 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 | Sigmoid operation = CreateSigmoid(op_def); |
| 52 | ASSERT_OK(ExecuteGPUOperation(src_tensor, creation_context_, &operation, |
| 53 | BHWC(1, 2, 1, 2), &dst_tensor)); |
| 54 | EXPECT_THAT(dst_tensor.data, |
| 55 | Pointwise(FloatNear(eps), {0.5f, 1.0f / 3.0f, 0.25f, 0.2f})); |
| 56 | } |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | } // namespace |
| 61 | } // namespace cl |
nothing calls this directly
no test coverage detected