@Namespace(value="ngraph") @NoOffset @Properties(inherit=ngraph.class) public class PartialShape extends Pointer
?
)
\li Static rank, but dynamic dimensions on some or all axes.
(Informal notation examples: {1,2,?,4}
, {?,?,?}
)
\li Static rank, and static dimensions on all axes.
(Informal notation examples: {1,2,3,4}
, {6}
, {}
)Pointer.CustomDeallocator, Pointer.Deallocator, Pointer.NativeDeallocator, Pointer.ReferenceCounter
Constructor and Description |
---|
PartialShape()
\brief Constructs a static PartialShape with zero rank (the shape of a scalar).
|
PartialShape(Dimension dimensions)
\brief Constructs a PartialShape with static rank from a vector of Dimension.
|
PartialShape(long size)
Native array allocator.
|
PartialShape(Pointer p)
Pointer cast constructor.
|
PartialShape(Shape shape)
\brief Constructs a static PartialShape from a Shape.
|
Modifier and Type | Method and Description |
---|---|
boolean |
all_non_negative()
\brief Returns
true if all static dimensions of the tensor are non-negative, else
false . |
static boolean |
broadcast_merge_into(PartialShape dst,
PartialShape src,
AutoBroadcastSpec autob)
\brief Try to merge one shape into another along with implicit broadcasting
|
boolean |
compatible(PartialShape s)
\brief Check whether this shape is compatible with the argument, i.e., whether it is
possible to merge them.
|
static PartialShape |
dynamic() |
static PartialShape |
dynamic(Dimension r)
\brief Construct a PartialShape with the given rank and all dimensions (if any) dynamic.
|
Dimension |
get(long i)
\brief Index operator for PartialShape.
|
PartialShape |
getPointer(long i) |
boolean |
is_dynamic()
\brief Check if this shape is dynamic.
|
boolean |
is_static()
\brief Check if this shape is static.
|
static boolean |
merge_into(PartialShape dst,
PartialShape src)
\brief Try to merge one shape into another.
|
boolean |
merge_rank(Dimension r)
\brief Checks that this shape's rank is compatible with
r , and, if this shape's
rank is dynamic and r is static, updates this shape to have a rank of r
with dimensions all dynamic. |
PartialShape |
position(long position) |
Dimension |
rank()
\brief Get the rank of the shape.
|
boolean |
refines(PartialShape s)
\brief Check whether this shape is a refinement of the argument.
|
boolean |
relaxes(PartialShape s)
\brief Check whether this shape is a relaxation of the argument.
|
boolean |
same_scheme(PartialShape s)
\brief Check whether this shape represents the same scheme as the argument.
|
Shape |
to_shape()
\brief Convert a static PartialShape to a Shape.
|
address, asBuffer, asByteBuffer, availablePhysicalBytes, calloc, capacity, capacity, close, deallocate, deallocate, deallocateReferences, deallocator, deallocator, equals, fill, formatBytes, free, getDirectBufferAddress, getPointer, getPointer, getPointer, hashCode, interruptDeallocatorThread, isNull, isNull, limit, limit, malloc, maxBytes, maxPhysicalBytes, memchr, memcmp, memcpy, memmove, memset, offsetAddress, offsetof, offsetof, parseBytes, physicalBytes, physicalBytesInaccurate, position, put, realloc, referenceCount, releaseReference, retainReference, setNull, sizeof, sizeof, toString, totalBytes, totalCount, totalPhysicalBytes, withDeallocator, zero
public PartialShape(Pointer p)
Pointer(Pointer)
.public PartialShape(long size)
Pointer.position(long)
.public PartialShape(@StdVector Dimension dimensions)
dimensions
- The Dimension values for the constructed shape.public PartialShape()
public PartialShape position(long position)
public PartialShape getPointer(long i)
getPointer
in class Pointer
@Cast(value="bool") public boolean is_static()
true
if this shape is static, else false
.
A shape is considered static if it has static rank, and all dimensions of the shape
are static.@Cast(value="bool") public boolean is_dynamic()
false
if this shape is static, else true
.
A shape is considered static if it has static rank, and all dimensions of the shape
are static.@ByVal @Cast(value="ngraph::Rank*") public Dimension rank()
@ByVal public static PartialShape dynamic(@ByVal(nullValue="ngraph::Rank::dynamic()") @Cast(value="ngraph::Rank*") Dimension r)
@ByVal public static PartialShape dynamic()
@Cast(value="bool") public boolean compatible(@Const @ByRef PartialShape s)
s
- The shape to be checked for compatibility with this shape.true
if this shape is compatible with s
, else false
.
Two shapes are compatible if
\li one or both of them has dynamic rank, or
\li both shapes have dynamic and equal rank, and their dimensions are elementwise
compatible (see Dimension::compatible()).@Cast(value="bool") public boolean same_scheme(@Const @ByRef PartialShape s)
s
- The shape whose scheme is being compared with this shape.true
if this shape represents the same scheme as s
, else false
.
Two shapes s1
and s2
represent the same scheme if
\li they both have dynamic rank, or
\li they both have static and equal rank r
, and for every i
from 0
to r-1
,
s1[i]
represents the same scheme as s2[i]
(see Dimension::same_scheme()).@Cast(value="bool") public boolean relaxes(@Const @ByRef PartialShape s)
s
- The shape which is being compared against this shape.true
if this shape relaxes s
, else false
.
Intuitively, a PartialShape s1
is said to _relax_ s2
(or _is a
relaxation_ of s2
) if it is "more permissive" than s2
. In other
words, s1
is a relaxation of s2
if anything you can form by
plugging things into the dynamic dimensions of s2
is also
something you can form by plugging things into the dynamic
dimensions of s1
, but not necessarily the other way around.
s1.relaxes(s2)
is equivalent to s2.refines(s1)
.
Formally, PartialShape s1
is said to _relax_ PartialShape s2
if:
\li s1
has dynamic rank, or
\li s1
and s2
both have static rank r
, and for every i
from 0
to r-1
,
either s1[i]
is dynamic, or s1[i]
== s2[i]
.@Cast(value="bool") public boolean refines(@Const @ByRef PartialShape s)
s
- The shape which is being compared against this shape.true
if this shape refines s
, else false
.
Intuitively, a PartialShape s1
is said to _relax_ s2
(or _is a
relaxation_ of s2
) if it is "less permissive" than s2
. In other
words, s1
is a relaxation of s2
if anything you can form by
plugging things into the dynamic dimensions of s1
is also
something you can form by plugging things into the dynamic
dimensions of s2
, but not necessarily the other way around.
s1.refines(s2)
is equivalent to s2.relaxes(s1)
.
Formally, PartialShape s1
is said to _refine_ PartialShape s2
if:
\li s2
has dynamic rank, or
\li s1
and s2
both have static rank r
, and for every i
from 0
to r-1
,
either s2[i]
is dynamic, or s1[i]
== s2[i]
.@Cast(value="bool") public boolean merge_rank(@ByVal @Cast(value="ngraph::Rank*") Dimension r)
r
, and, if this shape's
rank is dynamic and r
is static, updates this shape to have a rank of r
with dimensions all dynamic.true
if this shape's rank is compatible with r
, else false
.@ByVal public Shape to_shape()
s
where s[i] = size_t((*this)[i])
.std::invalid_argument
- If this PartialShape is dynamic.@Cast(value="bool") public boolean all_non_negative()
true
if all static dimensions of the tensor are non-negative, else
false
.@ByRef @Name(value="operator []") public Dimension get(@Cast(value="size_t") long i)
i
- The index of the dimension being selected.i
th Dimension of this shape.@Cast(value="bool") public static boolean merge_into(@ByRef PartialShape dst, @Const @ByRef PartialShape src)
dst
- [in,out] The shape that src
will be merged into.src
- The shape that will be merged into dst
.true
if merging succeeds, else false
.
Merges src
into dst
, returning true
on success and false
on failure. If
false
is returned, the effect on dst
is unspecified.
To merge two partial shapes s1
and s2
is to find the most permissive partial shape
s
that is no more permissive than s1
or s2
, if s
exists. For example:
merge(?,?) -> ?
merge(?,{?,?}) -> {?,?}
merge({?,?},{?,?}) -> {?,?}
merge({1,2,3,4},?) -> {1,2,3,4}
merge({1,2},{1,?}) -> {1,2}
merge({1,2,?,?},{1,?,3,?}) -> {1,2,3,?}
merge({1,2,3},{1,2,3}) -> {1,2,3}
merge({1,?},{2,?}) fails [dimension 0 constraints are inconsistent]
merge({?,?},{?,?,?}) fails [ranks are inconsistent]
This function (merge_into) performs the "merge" operation described above on dst
and
src
, but overwrites dst
with the result and returns true
if merging is
successful; if merging is unsuccessful, the function returns false
and may make
unspecified changes to dst
.@Cast(value="bool") public static boolean broadcast_merge_into(@ByRef PartialShape dst, @Const @ByRef PartialShape src, @Const @ByRef AutoBroadcastSpec autob)
Copyright © 2022. All rights reserved.