| 36 | |
| 37 | template <typename T> |
| 38 | static Graph* Concat(const string& kind, int num_inputs, |
| 39 | const TensorShape& in_shape, int concat_dims) { |
| 40 | Graph* g = new Graph(OpRegistry::Global()); |
| 41 | DataType type = DataTypeToEnum<T>::v(); |
| 42 | |
| 43 | const bool isDefault = (kind == "Default"); |
| 44 | string op_name = isDefault ? "Concat" : "_MklConcat"; |
| 45 | |
| 46 | Tensor concat_dim(DT_INT32, TensorShape({})); |
| 47 | concat_dim.scalar<int32>()() = concat_dims; |
| 48 | |
| 49 | Node* not_mkl_shape = |
| 50 | test::graph::Constant(g, GetMklMetaTensor(), "not_mkl"); |
| 51 | |
| 52 | std::vector<NodeBuilder::NodeOut> inputs; |
| 53 | std::vector<NodeBuilder::NodeOut> inputs_not_mkl; |
| 54 | inputs.reserve(num_inputs); |
| 55 | inputs_not_mkl.reserve(num_inputs); |
| 56 | |
| 57 | for (int i = 0; i < num_inputs; ++i) { |
| 58 | Tensor in(type, in_shape); |
| 59 | in.flat<T>().setRandom(); |
| 60 | inputs.push_back(test::graph::Constant(g, in)); |
| 61 | inputs_not_mkl.push_back(test::graph::Constant(g, GetMklMetaTensor(), "not_mkl")); |
| 62 | } |
| 63 | |
| 64 | auto nodeBuilder = NodeBuilder(g->NewName("n"), op_name) |
| 65 | .Input(test::graph::Constant(g, concat_dim)) |
| 66 | .Input(inputs) |
| 67 | .Attr("N", num_inputs) |
| 68 | .Attr("T", type); |
| 69 | |
| 70 | isDefault ? nodeBuilder : nodeBuilder.Input(not_mkl_shape) |
| 71 | .Input(inputs_not_mkl) |
| 72 | .Attr("_kernel", "MklLayoutDependentOp"); |
| 73 | TF_CHECK_OK(nodeBuilder.Finalize(g, nullptr)); |
| 74 | |
| 75 | return g; |
| 76 | } |
| 77 | |
| 78 | #define S_TENSOR(...) test::AsTensor<int32>({__VA_ARGS__}) |
| 79 |
nothing calls this directly
no test coverage detected