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

Function Slice2D

tensorflow/core/kernels/mkl_slice_op_test.cc:38–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36
37template <typename T>
38static Graph* Slice2D(const string& kind, DataType type, int size) {
39 Graph* g = new Graph(OpRegistry::Global());
40
41 const bool isDefault = (kind == "Default");
42 string op_name = isDefault ? "Slice" : "_MklSlice";
43
44 int kDim = 100;
45 int kMaxSize = 15000;
46 CHECK_LT(size, kMaxSize);
47
48 Tensor input(type, TensorShape({2 * kDim, kMaxSize}));
49 input.flat<T>().setRandom();
50
51 Tensor begin(DT_INT32, TensorShape({2}));
52 begin.flat<int32>()(0) = 10;
53 begin.flat<int32>()(1) = 10;
54
55 Tensor sizes(DT_INT32, TensorShape({2}));
56 sizes.flat<int32>()(0) = kDim;
57 sizes.flat<int32>()(1) = size;
58
59 Node* not_mkl_shape =
60 test::graph::Constant(g, GetMklMetaTensor(), "not_mkl");
61
62 auto nodeBuilder = NodeBuilder(g->NewName("n"), op_name)
63 .Input(test::graph::Constant(g, input))
64 .Input(test::graph::Constant(g, begin))
65 .Input(test::graph::Constant(g, sizes))
66 .Attr("T", type);
67 isDefault ? nodeBuilder : nodeBuilder.Input(not_mkl_shape)
68 .Input(not_mkl_shape)
69 .Input(not_mkl_shape)
70 .Attr("_kernel", "MklLayoutDependentOp");
71 TF_CHECK_OK(nodeBuilder.Finalize(g, nullptr));
72
73 return g;
74}
75
76#define BM_Slice2D_Base(kind, size, T, TFTYPE, DEVICE, NTH) \
77 static void BM_Slice2D##_##kind##_##size##_##T##_##TFTYPE##_##DEVICE##_##NTH( \

Callers 2

TEST_FFunction · 0.85
XLA_TEST_PFunction · 0.85

Calls 8

GetMklMetaTensorFunction · 0.85
ConstantFunction · 0.70
TensorShapeClass · 0.50
NodeBuilderClass · 0.50
AttrMethod · 0.45
InputMethod · 0.45
NewNameMethod · 0.45
FinalizeMethod · 0.45

Tested by

no test coverage detected