| 297 | // --------------------------------------------------------------------------// |
| 298 | template <typename T> |
| 299 | static Graph* Cwise(const string& op_name, const string& kind, |
| 300 | const TensorShape& shape0, const TensorShape& shape1) { |
| 301 | auto* graph = new Graph(OpRegistry::Global()); |
| 302 | const string node_name = kind + "_" + op_name; |
| 303 | const bool isDefault = (kind == "Default"); |
| 304 | |
| 305 | DataType dtype = DataTypeToEnum<T>::v(); |
| 306 | |
| 307 | auto init_input = [&](const TensorShape& shape, const std::string& name) { |
| 308 | DataType dtype = DataTypeToEnum<T>::v(); |
| 309 | Tensor input_t(dtype, shape); |
| 310 | input_t.flat<T>().setRandom(); |
| 311 | return test::graph::Constant(graph, input_t, name); |
| 312 | }; |
| 313 | |
| 314 | Node* input0 = init_input(shape0, "input0"); |
| 315 | Node* input1 = init_input(shape1, "input1"); |
| 316 | |
| 317 | Node* not_mkl_shape = |
| 318 | test::graph::Constant(graph, GetMklMetaTensor(), "not_mkl"); |
| 319 | |
| 320 | auto nodeBuilder = NodeBuilder(graph->NewName(node_name), isDefault ? op_name : "_Mkl" + op_name) |
| 321 | .Input(input0) |
| 322 | .Input(input1) |
| 323 | .Attr("T", dtype); |
| 324 | |
| 325 | isDefault ? nodeBuilder : nodeBuilder.Input(not_mkl_shape) |
| 326 | .Input(not_mkl_shape) |
| 327 | .Attr("_kernel", "MklLayoutDependentOp"); |
| 328 | |
| 329 | // MKL forward op. |
| 330 | TF_CHECK_OK(nodeBuilder.Finalize(graph, nullptr)); |
| 331 | return graph; |
| 332 | } |
| 333 | |
| 334 | #define BM_Cwise_Base(op, kind, name, shape_info_0, shape_info_1, T, DEVICE, NTH) \ |
| 335 | static void BM_##kind##_##name##_##NTH(int iters) { \ |
nothing calls this directly
no test coverage detected