| 36 | |
| 37 | template <typename T> |
| 38 | static 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( \ |
no test coverage detected