提交 15d7e8b3 编写于 作者: alinag's avatar alinag

reduce Eigen transformation

test=develop
上级 5cf46e90
......@@ -46,23 +46,6 @@ void ReduceFunctor(const lite::Tensor& input,
lite::Tensor* output,
const std::vector<int>& dims,
bool keep_dim) {
auto x = EigenTensor<T, D>::From(input);
auto reduce_dim = Eigen::array<int, R_D>();
auto x_rank = static_cast<int>(x.dimensions().size());
for (size_t i = 0; i < dims.size(); ++i) {
if (dims[i] < 0) {
reduce_dim[i] = x_rank + dims[i];
} else {
reduce_dim[i] = dims[i];
}
}
Functor functor;
if (D == 1) {
auto out = EigenScalar<T>::From(output);
functor(&x, &out, reduce_dim);
} else {
auto te = strstr(typeid(Functor).name(), "SumFunctor");
if (D == 3 && R_D == 1 && te != NULL) {
const lite::DDim& input_dims = input.dims();
......@@ -80,6 +63,23 @@ void ReduceFunctor(const lite::Tensor& input,
output_data[out_d] = output_temp;
}
}
} else {
auto x = EigenTensor<T, D>::From(input);
auto reduce_dim = Eigen::array<int, R_D>();
auto x_rank = static_cast<int>(x.dimensions().size());
for (size_t i = 0; i < dims.size(); ++i) {
if (dims[i] < 0) {
reduce_dim[i] = x_rank + dims[i];
} else {
reduce_dim[i] = dims[i];
}
}
Functor functor;
if (D == 1) {
auto out = EigenScalar<T>::From(output);
functor(&x, &out, reduce_dim);
} else {
auto out = EigenTensor<T, (D - R_D)>::From(*output, output->dims());
functor(&x, &out, reduce_dim);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册