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

Method Run

executor/operator/arm32/eltwise_float.cpp:124–266  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

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