10 #include "ngraph/attribute_adapter.hpp"
11 #include "ngraph/axis_set.hpp"
12 #include "ngraph/ngraph_visibility.hpp"
13 #include "ngraph/strides.hpp"
18 class Shape :
public std::vector<size_t>
23 NGRAPH_API
Shape(
const std::initializer_list<size_t>& axis_lengths);
25 NGRAPH_API
Shape(
const std::vector<size_t>& axis_lengths);
29 NGRAPH_API
explicit Shape(
size_t n,
size_t initial_value = 0);
33 template <
class InputIterator>
34 Shape(InputIterator first, InputIterator last)
35 : std::vector<size_t>(first, last)
40 NGRAPH_API
Shape& operator=(
Shape&& v) noexcept;
58 template <
typename SHAPE_TYPE>
70 template <
typename SHAPE_TYPE>
73 std::vector<size_t> strides(shape.size());
75 auto st = strides.rbegin();
76 for (
auto d = shape.rbegin(); d != shape.rend() && st != strides.rend(); d++, st++)
84 template <
typename SHAPE_TYPE>
85 size_t row_major_stride(
const SHAPE_TYPE& shape,
size_t axis)
88 for (
size_t i = shape.size(); i-- > axis + 1;)
95 template <
typename SHAPE_TYPE>
96 inline bool is_scalar(
const SHAPE_TYPE& shape)
98 return 0 == shape.size();
101 template <
typename SHAPE_TYPE>
102 inline bool is_vector(
const SHAPE_TYPE& shape)
104 return 1 == shape.size();
108 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:161
Definition: attribute_adapter.hpp:126
Shape for a tensor.
Definition: shape.hpp:19
The Intel nGraph C++ API.
Definition: attribute_adapter.hpp:16
size_t shape_size(const SHAPE_TYPE &shape)
Number of elements in spanned by a shape.
Definition: shape.hpp:59
std::vector< size_t > row_major_strides(const SHAPE_TYPE &shape)
Row-major strides for a shape.
Definition: shape.hpp:71