variable.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 <utility>
20 
21 #include "ngraph/op/op.hpp"
22 
23 namespace ngraph
24 {
25  struct VariableInfo
26  {
27  PartialShape data_shape;
28  element::Type data_type;
29  std::string variable_id;
30  };
31 
32  class NGRAPH_API Variable
33  {
34  public:
35  Variable() = default;
36 
37  explicit Variable(const VariableInfo& variable_info)
38  : m_info(variable_info)
39  {
40  }
41 
42  VariableInfo get_info() { return m_info; }
43  void update(const VariableInfo& variable_info) { m_info = variable_info; }
44  private:
45  VariableInfo m_info;
46  };
47 
48  template <>
49  class NGRAPH_API AttributeAdapter<std::shared_ptr<Variable>>
50  : public DirectValueAccessor<std::shared_ptr<Variable>>
51  {
52  public:
53  explicit AttributeAdapter(std::shared_ptr<Variable>& value)
55  {
56  }
57 
58  static constexpr DiscreteTypeInfo type_info{"AttributeAdapter<std::shared_ptr<Variable>>",
59  0};
60  const DiscreteTypeInfo& get_type_info() const override { return type_info; }
61  };
62 }
An AttributeAdapter "captures" an attribute as an AT& and makes it available as a ValueAccessor<VAT>.
Definition: attribute_adapter.hpp:171
Definition: attribute_adapter.hpp:79
Class representing a shape that may be partially or totally dynamic.
Definition: partial_shape.hpp:46
Definition: variable.hpp:33
Definition: element_type.hpp:61
The Intel nGraph C++ API.
Definition: attribute_adapter.hpp:28
Definition: type.hpp:39
Definition: variable.hpp:26