squared_difference.hpp
1 //*****************************************************************************
2 // Copyright 2017-2020 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 "ngraph/node.hpp"
20 #include "ngraph/op/op.hpp"
21 #include "ngraph/op/util/fused_op.hpp"
22 
23 NGRAPH_SUPPRESS_DEPRECATED_START
24 
25 namespace ngraph
26 {
27  namespace op
28  {
29  namespace v0
30  {
31  /// \brief Calculates an element-wise squared difference between two tensors
32  ///
33  /// y[i] = (x1[i] - x2[i])^2
34  class NGRAPH_API SquaredDifference : public ngraph::op::util::FusedOp
35  {
36  public:
37  static constexpr NodeTypeInfo type_info{"SquaredDifference", 0};
38  const NodeTypeInfo& get_type_info() const override { return type_info; }
39  SquaredDifference() = default;
40  /// \brief Constructs the squared difference operation.
41  ///
42  /// \param x1 First input tensor
43  /// \param x2 Second input tensor
44  /// \param auto_broadcast Auto broadcast specification
46  const Output<Node>& x1,
47  const Output<Node>& x2,
48  const AutoBroadcastSpec& auto_broadcast = AutoBroadcastType::NUMPY);
49 
50  bool visit_attributes(AttributeVisitor& visitor) override;
51  virtual OutputVector decompose_op() const override;
52 
53  virtual std::shared_ptr<Node>
54  clone_with_new_inputs(const OutputVector& new_args) const override;
55 
56  const AutoBroadcastSpec& get_autob() const override { return m_autobroadcast; }
57  void set_autob(const AutoBroadcastSpec& auto_broadcast)
58  {
59  m_autobroadcast = auto_broadcast;
60  }
61 
62  private:
63  AutoBroadcastSpec m_autobroadcast;
64  };
65  }
66  using v0::SquaredDifference;
67  } // namespace op
68 } // namespace ngraph
69 
70 NGRAPH_SUPPRESS_DEPRECATED_END
ngraph::op::AutoBroadcastSpec
Implicit broadcast specification.
Definition: attr_types.hpp:321
ngraph::op::v0::SquaredDifference::SquaredDifference
SquaredDifference(const Output< Node > &x1, const Output< Node > &x2, const AutoBroadcastSpec &auto_broadcast=AutoBroadcastType::NUMPY)
Constructs the squared difference operation.
ngraph::op::v0::SquaredDifference
Calculates an element-wise squared difference between two tensors.
Definition: squared_difference.hpp:35
ngraph
The Intel nGraph C++ API.
Definition: attribute_adapter.hpp:28
ngraph::AttributeVisitor
Visits the attributes of a node, primarily for serialization-like tasks.
Definition: attribute_visitor.hpp:70