22 #include "ngraph/attribute_adapter.hpp"
23 #include "ngraph/axis_set.hpp"
24 #include "ngraph/ngraph_visibility.hpp"
25 #include "ngraph/strides.hpp"
30 class Shape :
public std::vector<size_t>
35 NGRAPH_API
Shape(
const std::initializer_list<size_t>& axis_lengths);
37 NGRAPH_API
Shape(
const std::vector<size_t>& axis_lengths);
41 NGRAPH_API
explicit Shape(
size_t n,
size_t initial_value = 0);
45 template <
class InputIterator>
46 Shape(InputIterator first, InputIterator last)
47 : std::vector<size_t>(first, last)
52 NGRAPH_API
Shape& operator=(
Shape&& v) noexcept;
70 template <
typename SHAPE_TYPE>
82 template <
typename SHAPE_TYPE>
85 std::vector<size_t> strides(shape.size());
87 auto st = strides.rbegin();
88 for (
auto d = shape.rbegin(); d != shape.rend() && st != strides.rend(); d++, st++)
96 template <
typename SHAPE_TYPE>
97 size_t row_major_stride(
const SHAPE_TYPE& shape,
size_t axis)
100 for (
size_t i = shape.size(); i-- > axis + 1;)
107 template <
typename SHAPE_TYPE>
108 inline bool is_scalar(
const SHAPE_TYPE& shape)
110 return 0 == shape.size();
113 template <
typename SHAPE_TYPE>
114 inline bool is_vector(
const SHAPE_TYPE& shape)
116 return 1 == shape.size();
120 std::ostream& operator<<(std::ostream& s,
const Shape& shape);
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:137
Shape for a tensor.
Definition: shape.hpp:31
The Intel nGraph C++ API.
Definition: attribute_adapter.hpp:28
size_t shape_size(const SHAPE_TYPE &shape)
Number of elements in spanned by a shape.
Definition: shape.hpp:71
std::vector< size_t > row_major_strides(const SHAPE_TYPE &shape)
Row-major strides for a shape.
Definition: shape.hpp:83