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

Function TEST

tensorflow/core/util/mkl_util_test.cc:26–54  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24namespace {
25
26TEST(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
56TEST(MklUtilTest, MklDnnBlockedFormatTest) {
57 // Let's create 2D tensor of shape {3, 4} with 3 being innermost dimension

Callers

nothing calls this directly

Calls 10

to_stringFunction · 0.85
SetMklTensorMethod · 0.80
SetTfLayoutMethod · 0.80
GetTfShapeMethod · 0.80
SetUsrMemMethod · 0.80
GetUsrMemDescMethod · 0.80
sizeMethod · 0.45
SetOpMethod · 0.45
GetOpMethod · 0.45
ClearMethod · 0.45

Tested by

no test coverage detected