MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / Concat

Function Concat

tensorflow/core/kernels/mkl_concat_op_test.cc:38–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36
37template <typename T>
38static 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

Callers

nothing calls this directly

Calls 10

GetMklMetaTensorFunction · 0.85
ConstantFunction · 0.70
TensorShapeClass · 0.50
NodeBuilderClass · 0.50
reserveMethod · 0.45
push_backMethod · 0.45
AttrMethod · 0.45
InputMethod · 0.45
NewNameMethod · 0.45
FinalizeMethod · 0.45

Tested by

no test coverage detected