| 36 | |
| 37 | template <typename T> |
| 38 | static Graph* AddN(const string& kind, int num_inputs, const TensorShape& shape) { |
| 39 | Graph* g = new Graph(OpRegistry::Global()); |
| 40 | DataType type = DataTypeToEnum<T>::v(); |
| 41 | |
| 42 | const bool isDefault = (kind == "Default"); |
| 43 | string op_name = isDefault ? "AddN" : "_MklAddN"; |
| 44 | std::vector<NodeBuilder::NodeOut> inputs; |
| 45 | std::vector<NodeBuilder::NodeOut> inputs_not_mkl; |
| 46 | inputs.reserve(num_inputs); |
| 47 | inputs_not_mkl.reserve(num_inputs); |
| 48 | |
| 49 | for (int i = 0; i < num_inputs; ++i) { |
| 50 | Tensor in(type, shape); |
| 51 | in.flat<T>().setRandom(); |
| 52 | inputs.push_back(test::graph::Constant(g, in)); |
| 53 | inputs_not_mkl.push_back(test::graph::Constant(g, GetMklMetaTensor(), "not_mkl")); |
| 54 | } |
| 55 | |
| 56 | auto nodeBuilder = NodeBuilder(g->NewName("n"), op_name) |
| 57 | .Input(inputs) |
| 58 | .Attr("T", type); |
| 59 | isDefault ? nodeBuilder : nodeBuilder.Input(inputs_not_mkl) |
| 60 | .Attr("_kernel", "MklLayoutDependentOp"); |
| 61 | TF_CHECK_OK(nodeBuilder.Finalize(g, nullptr)); |
| 62 | return g; |
| 63 | } |
| 64 | |
| 65 | #define BM_AddN_Base(kind, T, name, nums, tf_shape, DEVICE, NTH) \ |
| 66 | static void BM_AddN##_##kind##_##T##_##name##_##DEVICE##_##NTH( \ |
no test coverage detected