|
| 1 | +//***************************************************************************** |
| 2 | +// Copyright 2017-2019 Intel Corporation |
| 3 | +// |
| 4 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +// you may not use this file except in compliance with the License. |
| 6 | +// You may obtain a copy of the License at |
| 7 | +// |
| 8 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +// |
| 10 | +// Unless required by applicable law or agreed to in writing, software |
| 11 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +// See the License for the specific language governing permissions and |
| 14 | +// limitations under the License. |
| 15 | +//***************************************************************************** |
| 16 | + |
| 17 | +#pragma once |
| 18 | + |
| 19 | +#include <cmath> |
| 20 | + |
| 21 | +#define EIGEN_USE_THREADS |
| 22 | +#include <unsupported/Eigen/CXX11/Tensor> |
| 23 | + |
| 24 | +#include "ngraph/runtime/cpu/cpu_executor.hpp" |
| 25 | + |
| 26 | +namespace ngraph |
| 27 | +{ |
| 28 | + namespace runtime |
| 29 | + { |
| 30 | + namespace cpu |
| 31 | + { |
| 32 | + namespace kernel |
| 33 | + { |
| 34 | + template <typename ElementType> |
| 35 | + void atan2(void* input0, void* input1, void* output, size_t count, int arena) |
| 36 | + { |
| 37 | + Eigen::array<Eigen::Index, 1> out_dims, in_dims; |
| 38 | + |
| 39 | + out_dims[0] = in_dims[0] = count; |
| 40 | + |
| 41 | + Eigen::TensorMap<Eigen::Tensor<ElementType, 1, Eigen::RowMajor>> out( |
| 42 | + static_cast<ElementType*>(output), out_dims); |
| 43 | + Eigen::TensorMap<Eigen::Tensor<ElementType, 1, Eigen::RowMajor>> in0( |
| 44 | + static_cast<ElementType*>(input0), in_dims); |
| 45 | + Eigen::TensorMap<Eigen::Tensor<ElementType, 1, Eigen::RowMajor>> in1( |
| 46 | + static_cast<ElementType*>(input1), in_dims); |
| 47 | + |
| 48 | + out.device(ngraph::runtime::cpu::executor::GetCPUExecutor().get_device(arena)) = |
| 49 | + in0.binaryExpr(in1, [](ElementType y, ElementType x) { |
| 50 | + return static_cast<ElementType>(std::atan2(y, x)); |
| 51 | + }); |
| 52 | + } |
| 53 | + } |
| 54 | + } |
| 55 | + } |
| 56 | +} |
0 commit comments