| 24 | namespace { |
| 25 | |
| 26 | TEST(MklUtilTest, MklDnnTfShape) { |
| 27 | auto cpu_engine = engine(ENGINE_CPU, 0); |
| 28 | MklDnnData<float> a(&cpu_engine); |
| 29 | |
| 30 | const int N = 1, C = 2, H = 3, W = 4; |
| 31 | memory::dims a_dims = {N, C, H, W}; |
| 32 | MklDnnShape a_dnnl_shape; |
| 33 | a_dnnl_shape.SetMklTensor(true); |
| 34 | // Create TF layout in NCHW. |
| 35 | a_dnnl_shape.SetTfLayout(a_dims.size(), a_dims, MKL_TENSOR_FORMAT_NCHW); |
| 36 | TensorShape a_tf_shape_nchw({N, C, H, W}); |
| 37 | TensorShape a_tf_shape_nhwc({N, H, W, C}); |
| 38 | TensorShape a_dnnl_tf_shape = a_dnnl_shape.GetTfShape(); |
| 39 | // Check that returned shape is in NCHW format. |
| 40 | EXPECT_EQ(a_tf_shape_nchw, a_dnnl_tf_shape); |
| 41 | EXPECT_NE(a_tf_shape_nhwc, a_dnnl_tf_shape); |
| 42 | |
| 43 | memory::dims b_dims = {N, C, H, W}; |
| 44 | MklDnnShape b_dnnl_shape; |
| 45 | b_dnnl_shape.SetMklTensor(true); |
| 46 | // Create TF layout in NHWC. |
| 47 | b_dnnl_shape.SetTfLayout(b_dims.size(), b_dims, MKL_TENSOR_FORMAT_NHWC); |
| 48 | TensorShape b_tf_shape_nhwc({N, H, W, C}); |
| 49 | TensorShape b_tf_shape_nchw({N, C, H, W}); |
| 50 | TensorShape b_dnnl_tf_shape = b_dnnl_shape.GetTfShape(); |
| 51 | // Check that returned shape is in NHWC format. |
| 52 | EXPECT_EQ(b_tf_shape_nhwc, b_dnnl_tf_shape); |
| 53 | EXPECT_NE(b_tf_shape_nchw, b_dnnl_tf_shape); |
| 54 | } |
| 55 | |
| 56 | TEST(MklUtilTest, MklDnnBlockedFormatTest) { |
| 57 | // Let's create 2D tensor of shape {3, 4} with 3 being innermost dimension |
nothing calls this directly
no test coverage detected