21 #include "ngraph/attribute_adapter.hpp"
22 #include "ngraph/dimension.hpp"
23 #include "ngraph/op/util/attr_types.hpp"
24 #include "ngraph/rank.hpp"
25 #include "ngraph/shape.hpp"
31 struct AutoBroadcastSpec;
66 PartialShape(
const std::vector<Dimension::value_type>& dimensions);
91 Rank rank()
const {
return m_rank_is_static ?
Rank(m_dimensions.size()) : Rank::dynamic(); }
179 explicit operator std::vector<Dimension>()
const {
return m_dimensions; }
180 friend NGRAPH_API std::ostream& operator<<(std::ostream& str,
const PartialShape& shape);
181 friend PartialShape operator+(
const PartialShape& s1,
const PartialShape& s2);
182 bool operator==(
const PartialShape& partial_shape)
const;
183 bool operator!=(
const PartialShape& partial_shape)
const;
224 const op::AutoBroadcastSpec& autob);
228 PartialShape(
bool rank_is_static,
const std::vector<Dimension>& dimensions);
231 bool m_rank_is_static;
240 mutable enum class ShapeType {
250 } m_shape_type{ShapeType::SHAPE_IS_UNKNOWN};
253 std::vector<Dimension> m_dimensions;
267 PartialShape operator+(
const PartialShape& s1,
const PartialShape& s2);
302 std::ostream& operator<<(std::ostream& str,
const PartialShape& shape);
305 class NGRAPH_API AttributeAdapter<
PartialShape> :
public ValueAccessor<std::vector<int64_t>>
313 const std::vector<int64_t>&
get()
override;
314 void set(
const std::vector<int64_t>& value)
override;
315 static constexpr
DiscreteTypeInfo type_info{
"AttributeAdapter<PartialShape>", 0};
316 const DiscreteTypeInfo& get_type_info()
const override {
return type_info; }
317 operator PartialShape&() {
return m_ref; }
320 std::vector<int64_t> m_buffer;
321 bool m_buffer_valid{
false};
PartialShape(const std::vector< Dimension > &dimensions)
Constructs a PartialShape with static rank from a vector of Dimension.
PartialShape(const std::vector< Dimension::value_type > &dimensions)
Constructs a PartialShape with static rank from a vector of dimensions values.
void set(const std::vector< int64_t > &value) override
Sets the value.
bool merge_rank(Rank r)
Checks that this shape's rank is compatible with r, and, if this shape's rank is dynamic and r is sta...
bool same_scheme(const PartialShape &s) const
Check whether this shape represents the same scheme as the argument.
PartialShape()
Constructs a static PartialShape with zero rank (the shape of a scalar).
Class representing a shape that may be partially or totally dynamic.
Definition: partial_shape.hpp:46
static bool merge_into(PartialShape &dst, const PartialShape &src)
Try to merge one shape into another.
Dimension Rank
Alias for Dimension, used when the value represents the number of axes in a shape,...
Definition: rank.hpp:27
bool refines(const PartialShape &s) const
Check whether this shape is a refinement of the argument.
bool compatible(const PartialShape &s) const
Check whether this shape is compatible with the argument, i.e., whether it is possible to merge them.
bool is_static() const
Check if this shape is static.
bool all_non_negative() const
Returns true if all static dimensions of the tensor are non-negative, else false.
static bool broadcast_merge_into(PartialShape &dst, const PartialShape &src, const op::AutoBroadcastSpec &autob)
Try to merge one shape into another along with implicit broadcasting.
Shape to_shape() const
Convert a static PartialShape to a Shape.
Shape get_shape() const
Get the unique shape.
Rank rank() const
Get the rank of the shape.
Definition: partial_shape.hpp:91
Shape for a tensor.
Definition: shape.hpp:31
Class representing a dimension, which may be dynamic (undetermined until runtime),...
Definition: dimension.hpp:35
The Intel nGraph C++ API.
Definition: attribute_adapter.hpp:28
PartialShape(std::initializer_list< Dimension > init)
Constructs a shape with static rank from an initializer list of Dimension.
const std::vector< int64_t > & get() override
Returns the value.
const Dimension & operator[](size_t i) const
Index operator for PartialShape.
PartialShape(const Shape &shape)
Constructs a static PartialShape from a Shape.
Shape get_min_shape() const
Get the min bounding shape.
Shape get_max_shape() const
Get the max bounding shape.
bool relaxes(const PartialShape &s) const
Check whether this shape is a relaxation of the argument.
bool is_dynamic() const
Check if this shape is dynamic.
Definition: partial_shape.hpp:87
Dimension & operator[](size_t i)
Index operator for PartialShape.
static PartialShape dynamic(Rank r=Rank::dynamic())
Construct a PartialShape with the given rank and all dimensions (if any) dynamic.