Open3D (C++ API)
0.18.0+3975044
|
Functions | |
bool | IsCompatibleBroadcastShape (const SizeVector &l_shape, const SizeVector &r_shape) |
Returns true if two shapes are compatible for broadcasting. More... | |
SizeVector | BroadcastedShape (const SizeVector &l_shape, const SizeVector &r_shape) |
Returns the broadcasted shape of two shapes. More... | |
bool | CanBeBrocastedToShape (const SizeVector &src_shape, const SizeVector &dst_shape) |
Returns true if src_shape can be brocasted to dst_shape . More... | |
SizeVector | ReductionShape (const SizeVector &src_shape, const SizeVector &dims, bool keepdim) |
Returns the shape after reduction. More... | |
int64_t | WrapDim (int64_t dim, int64_t max_dim, bool inclusive=false) |
Wrap around negative dim . More... | |
SizeVector | InferShape (SizeVector shape, int64_t num_elements) |
SizeVector | Concat (const SizeVector &l_shape, const SizeVector &r_shape) |
Concatenate two shapes. More... | |
SizeVector | Iota (int64_t n) |
Returns a SizeVector of {0, 1, ..., n - 1}, similar to std::iota. More... | |
SizeVector | DefaultStrides (const SizeVector &shape) |
Compute default strides for a shape when a tensor is contiguous. More... | |
std::pair< bool, SizeVector > | Restride (const SizeVector &old_shape, const SizeVector &old_strides, const SizeVector &new_shape) |
SizeVector open3d::core::shape_util::BroadcastedShape | ( | const SizeVector & | l_shape, |
const SizeVector & | r_shape | ||
) |
bool open3d::core::shape_util::CanBeBrocastedToShape | ( | const SizeVector & | src_shape, |
const SizeVector & | dst_shape | ||
) |
Returns true if src_shape
can be brocasted to dst_shape
.
E.g. CanBeBrocastedToShape({1, 2}, {3, 5, 2}) -> true CanBeBrocastedToShape({1, 2}, {3, 5, 3}) -> false
src_shape | Source tensor shape. |
dst_shape | Destination tensor shape. |
src_shape
can be brocasted to dst_shape
. SizeVector open3d::core::shape_util::Concat | ( | const SizeVector & | l_shape, |
const SizeVector & | r_shape | ||
) |
Concatenate two shapes.
SizeVector open3d::core::shape_util::DefaultStrides | ( | const SizeVector & | shape | ) |
Compute default strides for a shape when a tensor is contiguous.
SizeVector open3d::core::shape_util::InferShape | ( | SizeVector | shape, |
int64_t | num_elements | ||
) |
Infers the size of a dim with size -1, if it exists. Also checks that new shape is compatible with the number of elements.
E.g. Shape({2, -1, 4}) with num_elemnts 24, will be inferred as {2, 3, 4}.
Ref: PyTorch's aten/src/ATen/InferSize.h
SizeVector open3d::core::shape_util::Iota | ( | int64_t | n | ) |
Returns a SizeVector of {0, 1, ..., n - 1}, similar to std::iota.
bool open3d::core::shape_util::IsCompatibleBroadcastShape | ( | const SizeVector & | l_shape, |
const SizeVector & | r_shape | ||
) |
Returns true if two shapes are compatible for broadcasting.
E.g. IsCompatibleBroadcastShape({3, 1, 2}, {5, 1}) -> true IsCompatibleBroadcastShape({3, 1, 2}, {5, 3}) -> false
l_shape
and r_shape
are compatible for broadcasting. SizeVector open3d::core::shape_util::ReductionShape | ( | const SizeVector & | src_shape, |
const SizeVector & | dims, | ||
bool | keepdim | ||
) |
Returns the shape after reduction.
E.g. CanBeBrocastedToShape({1, 2}, {3, 5, 2}) -> true CanBeBrocastedToShape({1, 2}, {3, 5, 3}) -> false
src_shape | shape to reduce |
dims | A list of dimensions to be reduced. |
keepdim | If true, the reduced dims will be retained as size 1. |
std::pair< bool, SizeVector > open3d::core::shape_util::Restride | ( | const SizeVector & | old_shape, |
const SizeVector & | old_strides, | ||
const SizeVector & | new_shape | ||
) |
oldshape
into chunks of dimensions, where the dimensions are `‘contiguous’' in each chunk, i.e., oldstride[i] = oldshape[i+1] * oldstride[i+1]newshape
must be able to be separated into same number of chunks as oldshape
was separated into, where each chunk of newshape has matching `‘numel’', i.e., number of subspaces, as the corresponding chunk of oldshape
. Ref: aten/src/ATen/TensorUtils.cpp int64_t open3d::core::shape_util::WrapDim | ( | int64_t | dim, |
int64_t | max_dim, | ||
bool | inclusive = false |
||
) |
Wrap around negative dim
.
E.g. If max_dim == 5, dim -1 will be converted to 4.
dim | Dimension index |
max_dim | Maximum dimension index |
inclusive | Set to true to allow dim == max_dim. E.g. for slice T[start:end], we allow end == max_dim. |