scatter_update.hpp
1 //*****************************************************************************
2 // Copyright 2017-2021 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/op/op.hpp"
20 #include "ngraph/op/util/scatter_base.hpp"
21 #include "ngraph/runtime/host_tensor.hpp"
22 
23 namespace ngraph
24 {
25  namespace op
26  {
27  namespace v3
28  {
29  ///
30  /// \brief Set new values to slices from data addressed by indices
31  ///
32  class NGRAPH_API ScatterUpdate : public util::ScatterBase
33  {
34  public:
35  static constexpr NodeTypeInfo type_info{"ScatterUpdate", 3};
36  const NodeTypeInfo& get_type_info() const override { return type_info; }
37  ScatterUpdate() = default;
38  ///
39  /// \brief Constructs ScatterUpdate operator object.
40  ///
41  /// \param data The input tensor to be updated.
42  /// \param indices The tensor with indexes which will be updated.
43  /// \param updates The tensor with update values.
44  /// \param[in] axis The axis at which elements will be updated.
45  ///
47  const Output<Node>& indices,
48  const Output<Node>& updates,
49  const Output<Node>& axis);
50 
51  virtual std::shared_ptr<Node>
52  clone_with_new_inputs(const OutputVector& inputs) const override;
53 
54  bool evaluate(const HostTensorVector& outputs,
55  const HostTensorVector& inputs) const override;
56 
57  private:
58  bool evaluate_scatter_update(const HostTensorVector& outputs,
59  const HostTensorVector& inputs) const;
60  };
61  }
62  }
63 }
A handle for one of a node's outputs.
Definition: node_output.hpp:42
Base class for ScatterXXX operators.
Definition: scatter_base.hpp:31
Set new values to slices from data addressed by indices.
Definition: scatter_update.hpp:33
bool evaluate(const HostTensorVector &outputs, const HostTensorVector &inputs) const override
Evaluates the op on input_values putting results in output_values.
const NodeTypeInfo & get_type_info() const override
Definition: scatter_update.hpp:36
ScatterUpdate(const Output< Node > &data, const Output< Node > &indices, const Output< Node > &updates, const Output< Node > &axis)
Constructs ScatterUpdate operator object.
The Intel nGraph C++ API.
Definition: attribute_adapter.hpp:28
Definition: type.hpp:39