range.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 
22 namespace ngraph
23 {
24  namespace op
25  {
26  namespace v4
27  {
28  /// \brief Range operation, analogous to `arange()` in Numpy.
29  class NGRAPH_API Range : public Op
30  {
31  public:
32  NGRAPH_RTTI_DECLARATION;
33  /// \brief Constructs an unitialized range operation.
34  Range() = default;
35 
36  /// \brief Constructs a range operation.
37  ///
38  /// \param start The tensor producing the start value. Must be a scalar of integer
39  /// element type, and same element type as `stop` and `step`.
40  /// \param stop The tensor producing the stop value. Must be a scalar of integer
41  /// element type, and same element type as `start` and `step`.
42  /// \param step The tensor producing the step value. Must be a scalar of integer
43  /// element type, and same element type as `start` and `stop`.
44  /// \param output_type The type of the output.
45  Range(const Output<Node>& start,
46  const Output<Node>& stop,
47  const Output<Node>& step,
48  element::Type output_type);
49 
50  bool visit_attributes(AttributeVisitor& visitor) override;
51  void validate_and_infer_types() override;
52 
53  virtual std::shared_ptr<Node>
54  clone_with_new_inputs(const OutputVector& new_args) const override;
55  bool evaluate(const HostTensorVector& outputs,
56  const HostTensorVector& inputs) const override;
57 
58  private:
59  element::Type m_output_type;
60  };
61  }
62  namespace v0
63  {
64  /// \brief Range operation, analogous to `range()` in Python.
65  class NGRAPH_API Range : public Op
66  {
67  public:
68  static constexpr NodeTypeInfo type_info{"Range", 0};
69  const NodeTypeInfo& get_type_info() const override { return type_info; }
70  /// \brief Constructs an unitialized range operation.
71  Range() = default;
72 
73  /// \brief Constructs a range operation.
74  ///
75  /// \param start The tensor producing the start value. Must be a scalar of integer
76  /// element type, and same element type as `stop` and `step`.
77  /// \param stop The tensor producing the stop value. Must be a scalar of integer
78  /// element type, and same element type as `start` and `step`.
79  /// \param step The tensor producing the step value. Must be a scalar of integer
80  /// element type, and same element type as `start` and `stop`.
81  Range(const Output<Node>& start,
82  const Output<Node>& stop,
83  const Output<Node>& step);
84 
85  bool visit_attributes(AttributeVisitor& visitor) override;
86  void validate_and_infer_types() override;
87 
88  virtual std::shared_ptr<Node>
89  clone_with_new_inputs(const OutputVector& new_args) const override;
90  bool evaluate(const HostTensorVector& outputs,
91  const HostTensorVector& inputs) const override;
92  };
93  }
94  using v0::Range;
95  }
96 }
ngraph::element::Type
Definition: element_type.hpp:61
ngraph::op::v0::Range::validate_and_infer_types
void validate_and_infer_types() override
Verifies that attributes and inputs are consistent and computes output shapes and element types....
ngraph
The Intel nGraph C++ API.
Definition: attribute_adapter.hpp:28
ngraph::op::v0::Range::Range
Range()=default
Constructs an unitialized range operation.
ngraph::op::v4::Range::Range
Range(const Output< Node > &start, const Output< Node > &stop, const Output< Node > &step, element::Type output_type)
Constructs a range operation.
ngraph::op::v0::Range::get_type_info
const NodeTypeInfo & get_type_info() const override
Definition: range.hpp:69
ngraph::op::v4::Range::Range
Range()=default
Constructs an unitialized range operation.
ngraph::AttributeVisitor
Visits the attributes of a node, primarily for serialization-like tasks.
Definition: attribute_visitor.hpp:70
ngraph::op::v0::Range
Range operation, analogous to range() in Python.
Definition: range.hpp:66
ngraph::stop
void stop()
stop the timer without writing the data to the log file. To write the data call the write method Call...
ngraph::op::v4::Range::validate_and_infer_types
void validate_and_infer_types() override
Verifies that attributes and inputs are consistent and computes output shapes and element types....
ngraph::op::v0::Range::Range
Range(const Output< Node > &start, const Output< Node > &stop, const Output< Node > &step)
Constructs a range operation.
ngraph::op::v4::Range
Range operation, analogous to arange() in Numpy.
Definition: range.hpp:30
ngraph::op::Op
Root of all actual ops.
Definition: op.hpp:29