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

Function create_fc_node

internal/tests/executor/tests/test_fc.cpp:53–174  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

51}
52
53Node* create_fc_node(void)
54{
55 Operator* op = OpManager::CreateOp("FullyConnected");
56 FullyConnected* fc_op = dynamic_cast<FullyConnected*>(op);
57
58 FCParam* param = fc_op->GetParam();
59
60 /* calculate shapes */
61
62#if 1
63 param->num_output = 2;
64 int input_n = 1;
65 int input_c = 128;
66#else
67 param->num_output = 12544;
68 int input_n = 32;
69 int input_c = 288;
70#endif
71
72 int input_h = 1;
73 int input_w = 1;
74
75 int N = input_n;
76 int K = input_h * input_w * input_c;
77 int M = param->num_output;
78
79 std::vector<int> input_dims = {input_n, input_c, input_h, input_w};
80 std::vector<int> weight_dims = {M, K};
81 std::vector<int> bias_dims = {M};
82 std::vector<int> output_dims = {N, M};
83
84 op_fops = 1.0 * N * M * (2 * K);
85
86 std::cout << "Input n: " << input_n << " c: " << input_c << " h: " << input_h << " w: " << input_w << "\n";
87 std::cout << "weight M: " << M << " K: " << K << "\n";
88 std::cout << "N: " << N << " M: " << M << " K: " << K << "\n";
89
90 Node* node = new Node("test_fc");
91
92 node->SetOp(fc_op);
93
94 // prepare tensor: input/weight/bias/output
95 Tensor* tensor;
96 int mem_size;
97 void* addr;
98
99 tensor = new Tensor("input");
100
101 tensor->SetDataType("float32");
102 tensor->SetType(kVarTensor);
103
104 TShape* shape = &tensor->GetShape();
105
106 shape->SetDataLayout("NCHW");
107 shape->SetDim(input_dims);
108
109 node->SetInputPort(0, tensor);
110

Callers 2

test_fully_connectedFunction · 0.85
test_new_operatorFunction · 0.85

Calls 11

set_tensor_memFunction · 0.85
GetParamMethod · 0.80
SetOpMethod · 0.80
SetDataTypeMethod · 0.80
SetTypeMethod · 0.80
SetDataLayoutMethod · 0.80
SetDimMethod · 0.80
SetInputPortMethod · 0.80
GetTotalSizeMethod · 0.80
SetOutputPortMethod · 0.80
init_tensor_dataFunction · 0.70

Tested by

no test coverage detected