提交 ae7766cd 编写于 作者: 虞连飞

optimize eltwise computing order

上级 f654c291
...@@ -900,23 +900,21 @@ class EltwiseOp : public Operation { ...@@ -900,23 +900,21 @@ class EltwiseOp : public Operation {
} }
} }
if (need_general_broadcast) { if (input1->size() == 1) {
TensorScalarEltwise(type_, input0_ptr, input1_ptr[0], coeff_,
input0->size(), swapped, output_ptr);
} else if (input0_shape == input1_shape) {
TensorEltwise(type_, input0_ptr, input1_ptr, coeff_, input0->size(),
swapped, output_ptr);
} else if (need_general_broadcast) {
TensorGeneralBroadcastEltwise(type_, input0_ptr, input1_ptr, coeff_, TensorGeneralBroadcastEltwise(type_, input0_ptr, input1_ptr, coeff_,
swapped, input0_shape, input1_shape, swapped, input0_shape, input1_shape,
output_shape, output_ptr); output_shape, output_ptr);
} else if (input1->size() == input0->size()) { } else {
TensorEltwise(type_, input0_ptr, input1_ptr, coeff_, input0->size(), index_t common_size = input1->size();
swapped, output_ptr); index_t diff_size = input0->size() / common_size;
} else if (input1->size() < input0->size()) { TensorBroadcastEltwise(type_, input0_ptr, input1_ptr, coeff_,
if (input1->size() > 1) { diff_size, common_size, swapped, output_ptr);
index_t common_size = input1->size();
index_t diff_size = input0->size() / common_size;
TensorBroadcastEltwise(type_, input0_ptr, input1_ptr, coeff_,
diff_size, common_size, swapped, output_ptr);
} else {
TensorScalarEltwise(type_, input0_ptr, input1_ptr[0], coeff_,
input0->size(), swapped, output_ptr);
}
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册