2 // Copyright (c) 2016-2019 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.
17 ///////////////////////////////////////////////////////////////////////////////////////////////////
19 #include "api/CPP/eltwise.hpp"
20 #include "primitive_inst.h"
22 #include "topology_impl.h"
27 struct typed_program_node<eltwise> : public typed_program_node_base<eltwise>
29 using parent = typed_program_node_base<eltwise>;
32 typed_program_node(std::shared_ptr<primitive> prim, program_impl& prog)
34 , output_qf(get_primitive()->output_quantization_factor)
35 , output_cf(!get_primitive()->output_calibration_factors.empty())
40 program_node& input(size_t idx = 0) const { return get_dependency(idx); }
41 size_t inputs_count() const { return get_dependencies().size() - (output_cf ? 1 : 0); }
42 program_node& output_calibration_factors() const { return get_dependency(inputs_count()); }
43 bool output_calibration_term() const { return !get_primitive()->output_calibration_factors.empty(); }
44 float get_output_qf() const { return output_qf; }
48 bool output_cf; // to know if we have calibration factors
51 using eltwise_node = typed_program_node<eltwise>;
54 class typed_primitive_inst<eltwise> : public typed_primitive_inst_base<eltwise>
56 using parent = typed_primitive_inst_base<eltwise>;
57 static void check_inputs_count(eltwise_node const &node);
60 static layout calc_output_layout(eltwise_node const& node);
61 static std::string to_string(eltwise_node const& node);
64 typed_primitive_inst(network_impl& network, eltwise_node const& node);
66 memory_impl& output_calibration_factors_memory() const { return dep_memory(node.inputs_count()); } // because last place should be reserved for calibration factors
67 bool output_calibration_factors_term() const { return node.output_calibration_term(); }
70 using eltwise_inst = typed_primitive_inst<eltwise>;