| 43 | |
| 44 | template <typename T> |
| 45 | static Graph* Softmax(const string& kind, const TensorShape& in_shape) { |
| 46 | Graph* g = new Graph(OpRegistry::Global()); |
| 47 | DataType type = DataTypeToEnum<T>::v(); |
| 48 | |
| 49 | const bool isDefault = (kind == "Default"); |
| 50 | string op_name = isDefault ? "Softmax" : "_MklSoftmax"; |
| 51 | |
| 52 | // Create inputs |
| 53 | Tensor input1(type, in_shape); |
| 54 | input1.flat<T>().setRandom(); |
| 55 | |
| 56 | Node* input_in0 = test::graph::Constant(g, input1); |
| 57 | |
| 58 | Node* not_mkl_shape = |
| 59 | test::graph::Constant(g, GetMklMetaTensor(), "not_mkl"); |
| 60 | // Create NodeDef |
| 61 | auto nodeBuilder = NodeBuilder(g->NewName("softmax"), op_name) |
| 62 | .Input(input_in0); |
| 63 | |
| 64 | isDefault ? nodeBuilder : nodeBuilder.Input(not_mkl_shape) |
| 65 | .Attr("_kernel", "MklLayoutDependentOp"); |
| 66 | |
| 67 | TF_CHECK_OK(nodeBuilder.Finalize(g, nullptr)); |
| 68 | |
| 69 | return g; |
| 70 | } |
| 71 | |
| 72 | #define BM_Softmax_Base(T, kind, name, in_shape, DEVICE, NTH) \ |
| 73 | static void BM_Softmax_##T##_##kind##name##_##NTH(int iters) { \ |
no test coverage detected