1 //*****************************************************************************
2 // Copyright 2020 Intel Corporation
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
8 // http://www.apache.org/licenses/LICENSE-2.0
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 //*****************************************************************************
19 #include "ngraph/node.hpp"
20 #include "onnx_import/default_opset.hpp"
21 #include "onnx_import/op/pow.hpp"
31 OutputVector pow(const Node& node)
33 auto inputs = node.get_ng_inputs();
34 NGRAPH_CHECK(inputs.size() == 2,
35 "Power operation requires 2 inputs. Got: ",
38 auto base = inputs[0];
39 auto exponent = inputs[1];
40 auto base_type = inputs[0].get_element_type();
41 auto exponent_type = inputs[1].get_element_type();
42 if (exponent_type != base_type)
44 if (exponent_type.is_integral() ||
45 (base_type.is_real() &&
46 base_type.bitwidth() >= exponent_type.bitwidth()))
49 std::make_shared<default_opset::Convert>(exponent, base_type);
53 base = std::make_shared<default_opset::Convert>(base, exponent_type);
54 auto power = std::make_shared<default_opset::Power>(base, exponent);
55 return {std::make_shared<default_opset::Convert>(power, base_type)};
58 return {std::make_shared<default_opset::Power>(base, exponent)};
65 } // namespace onnx_import