MCPcopy Create free account
hub / github.com/OAID/Tengine / create_test_node

Function create_test_node

internal/bin/test_permute_op.cpp:88–164  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

86}
87
88int create_test_node(graph_t graph, const char* node_name, int order, const char* inputs[], int input_counts)
89{
90 std::cout << "create_ggraph_node--" << order << "\n";
91 node_t test_node = create_graph_node(graph, node_name, "Permute");
92 if(test_node == nullptr)
93 {
94 std::cout << "create_graph_node_failed : node_name=" << node_name << "\n";
95 return -1;
96 }
97
98 int data_type = 0;
99 int dim[4] = {0};
100 for(int ii = 0; ii < input_counts; ++ii)
101 {
102 tensor_t input_tensor = get_graph_tensor(graph, inputs[ii]);
103 data_type = get_tensor_data_type(input_tensor);
104
105 get_tensor_shape(input_tensor, dim, 4);
106
107 if(input_tensor == nullptr)
108 {
109 std::cout << "ERRNO: " << get_tengine_errno() << "\noutput";
110 return -1;
111 }
112 // std::cout << "set_node_input_tensor\n";
113 set_node_input_tensor(test_node, ii, input_tensor);
114 // std::cout << "release_input_tensor\n";
115 release_graph_tensor(input_tensor);
116 }
117
118 int order0 = 0;
119 int order1 = 2;
120 int order2 = 3;
121 int order3 = 1;
122 std::cout << "layout : " << order << "\n";
123 if(order == TENGINE_LAYOUT_NHWC)
124 {
125 order1 = 3;
126 order2 = 1;
127 order3 = 2;
128
129 int tmp = dim[1];
130 dim[1] = dim[3];
131 dim[3] = dim[2];
132 dim[2] = tmp;
133 }
134 else
135 {
136 int tmp = dim[1];
137 dim[1] = dim[2];
138 dim[2] = dim[3];
139 dim[3] = tmp;
140 }
141 std::cout << "output_dim: " << dim[0] << "-" << dim[1] << "-" << dim[2] << "-" << dim[3] << "\n";
142 std::cout << "orders:" << order0 << "-" << order1 << "-" << order2 << "-" << order3 << "\n";
143
144 /* output */
145 tensor_t output_tensor = create_graph_tensor(graph, node_name, data_type);

Callers 1

create_test_graphFunction · 0.70

Calls 13

create_graph_nodeFunction · 0.85
get_graph_tensorFunction · 0.85
get_tensor_data_typeFunction · 0.85
get_tensor_shapeFunction · 0.85
get_tengine_errnoFunction · 0.85
set_node_input_tensorFunction · 0.85
release_graph_tensorFunction · 0.85
create_graph_tensorFunction · 0.85
set_tensor_shapeFunction · 0.85
set_node_output_tensorFunction · 0.85
set_tensor_quant_paramFunction · 0.85
set_node_attr_intFunction · 0.85

Tested by

no test coverage detected