MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / TEST_F

Function TEST_F

tensorflow/lite/delegates/gpu/cl/kernels/max_unpooling_test.cc:34–68  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32namespace {
33
34TEST_F(OpenCLOperationTest, MaxUnpooling) {
35 TensorFloat32 src_tensor;
36 src_tensor.shape = BHWC(1, 2, 2, 1);
37 src_tensor.data = {0.0f, 1.0f, 2.0f, 3.0f};
38 TensorFloat32 src_ind_tensor;
39 src_ind_tensor.shape = BHWC(1, 2, 2, 1);
40 src_ind_tensor.data = {0.1f, 1.1f, 2.1f, 3.1f};
41
42 MaxUnpooling2DAttributes attr;
43 attr.padding.prepended = HW(0, 0);
44 attr.padding.appended = HW(0, 0);
45 attr.strides = HW(2, 2);
46 attr.kernel = HW(2, 2);
47
48 for (auto storage : env_.GetSupportedStorages()) {
49 for (auto precision : env_.GetSupportedPrecisions()) {
50 const float eps = precision == CalculationsPrecision::F32 ? 1e-6f : 1e-3f;
51 OperationDef op_def;
52 op_def.precision = precision;
53 auto data_type = DeduceDataTypeFromPrecision(precision);
54 op_def.src_tensors.push_back({data_type, storage});
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 MaxUnpooling operation = CreateMaxUnpooling(op_def, attr);
59 ASSERT_OK(ExecuteGPUOperation({src_tensor, src_ind_tensor},
60 creation_context_, &operation,
61 BHWC(1, 4, 4, 1), &dst_tensor));
62 EXPECT_THAT(dst_tensor.data,
63 Pointwise(FloatNear(eps),
64 {0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f,
65 0.0f, 0.0f, 0.0f, 0.0f, 2.0f, 0.0f, 0.0f, 3.0f}));
66 }
67 }
68}
69
70} // namespace
71} // namespace cl

Callers

nothing calls this directly

Calls 6

CreateMaxUnpoolingFunction · 0.85
ExecuteGPUOperationFunction · 0.85
GetSupportedStoragesMethod · 0.80
push_backMethod · 0.45

Tested by

no test coverage detected