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

Method Run

executor/operator/arm64/eltwise_float.cpp:126–269  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

124 return( kernel_run(param->output,param->input0,param->input1,param->type,param->in_size0,param->in_size1, param->stride));
125 }
126 bool Run(Node* node)
127
128 {
129 // input
130 Tensor* input_tensor0 = node->GetInputTensor(0);
131 int element_size = DataType::GetTypeSize(input_tensor0->GetDataType());
132 float* input0 = (float*)get_tensor_mem(input_tensor0);
133
134 Tensor* input_tensor1 = nullptr;
135 float* input1 = nullptr;
136 int in_size0 = input_tensor0->GetTotalSize() / element_size;
137 int in_size1 = 0;
138 if(node->GetInputNum() > 1)
139 {
140 input_tensor1 = node->GetInputTensor(1);
141 input1 = (float*)get_tensor_mem(input_tensor1);
142 in_size1 = input_tensor1->GetTotalSize() / element_size;
143 }
144 TShape ishape;
145 int max_size = 0;
146 int min_size = 0;
147 float * main_data = NULL;
148 float * scale_data = NULL;
149
150 int batch_num = ishape.GetN();
151 if(in_size0 >= in_size1)
152 {
153 ishape = input_tensor0->GetShape();
154 main_data = input0;
155 scale_data = input1;
156 max_size = in_size0/batch_num;
157 min_size = in_size1/batch_num;
158 }
159 else
160 {
161 ishape = input_tensor1->GetShape();
162 main_data = input1;
163 scale_data = input0;
164 max_size = in_size1/batch_num;
165 min_size = in_size0/batch_num;
166 }
167
168 // this version only support for input_num=2
169 // int input_number=node->GetInputNum();
170
171 // output
172 Tensor* output_tensor = node->GetOutputTensor(0);
173 float* output = (float*)get_tensor_mem(output_tensor);
174 Eltwise* eltwise_op = dynamic_cast<Eltwise*>(node->GetOp());
175 EltwiseParam* elt_param = eltwise_op->GetParam();
176 bool result = true;
177
178 int stride = ishape.GetH() * ishape.GetW();
179 int channel = ishape.GetC();
180 int cpu_number = cpu_info->GetCPUNumber();
181
182 for(int n = 0; n < batch_num; n++)
183 {

Callers

nothing calls this directly

Calls 15

get_tensor_memFunction · 0.85
kernel_runFunction · 0.85
GetDataTypeMethod · 0.80
GetTotalSizeMethod · 0.80
GetNMethod · 0.80
GetOpMethod · 0.80
GetParamMethod · 0.80
GetHMethod · 0.80
GetWMethod · 0.80
GetCMethod · 0.80
GetCPUNumberMethod · 0.80
GetTypeSizeFunction · 0.50

Tested by

no test coverage detected