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

Function Transpose

tensorflow/core/kernels/mkl_transpose_op_test.cc:44–68  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42
43template <typename T>
44static Graph* Transpose(const string& kind, const TensorShape& in_shape, const Tensor& perm_tensor) {
45 Graph* g = new Graph(OpRegistry::Global());
46 DataType type = DataTypeToEnum<T>::v();
47
48 const bool isDefault = (kind == "Default");
49 string op_name = isDefault ? "Transpose" : "_MklTranspose";
50
51 // Create inputs
52 Tensor input1(type, in_shape);
53 input1.flat<T>().setRandom();
54
55 Node* input_in0 = test::graph::Constant(g, input1);
56 Node* input_in1 = test::graph::Constant(g, perm_tensor);
57
58 // Create NodeDef
59 auto nodeBuilder = NodeBuilder(g->NewName("transpose"), op_name)
60 .Input(input_in0)
61 .Input(input_in1);
62
63 isDefault ? nodeBuilder : nodeBuilder.Attr("_kernel", "MklNameChangeOp");
64
65 TF_CHECK_OK(nodeBuilder.Finalize(g, nullptr));
66
67 return g;
68}
69
70#define S_TENSOR(size, ...) test::AsTensor<int32>({__VA_ARGS__}, {size})
71

Callers

nothing calls this directly

Calls 6

ConstantFunction · 0.70
NodeBuilderClass · 0.50
InputMethod · 0.45
NewNameMethod · 0.45
AttrMethod · 0.45
FinalizeMethod · 0.45

Tested by

no test coverage detected