Open3D (C++ API)
Functions
open3d::shape_util Namespace Reference

Functions

const SizeVector ExpandFrontDims (const SizeVector &shape, int64_t ndims)
 
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)
 Wrap around negative dim. More...
 
SizeVector InferShape (SizeVector shape, int64_t num_elements)
 

Function Documentation

◆ BroadcastedShape()

SizeVector open3d::shape_util::BroadcastedShape ( const SizeVector l_shape,
const SizeVector r_shape 
)

Returns the broadcasted shape of two shapes.

E.g. BroadcastedShape({3, 1, 2}, {5, 1}) -> {3, 5, 2} BroadcastedShape({3, 1, 2}, {5, 3}) -> Exception

Parameters
l_shapeShape of the left-hand-side Tensor.
r_shapeShape of the left-hand-side Tensor.
Returns
The broadcasted shape.

◆ CanBeBrocastedToShape()

bool open3d::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

Parameters
src_shapeSource tensor shape.
dst_shapeDestination tensor shape.
Returns
Returns true if src_shape can be brocasted to dst_shape.

◆ ExpandFrontDims()

const SizeVector open3d::shape_util::ExpandFrontDims ( const SizeVector shape,
int64_t  ndims 
)

Expand a shape with ones in front. Returning a shape with size of ndims. E.g. ExpandFrontDims({2, 3}, 5) == {1, 1, 1, 2, 3}

◆ InferShape()

SizeVector open3d::shape_util::InferShape ( SizeVector  shape,
int64_t  num_elements 
)

◆ IsCompatibleBroadcastShape()

bool open3d::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

Parameters
l_shapeShape of the left-hand-side Tensor.
r_shapeShape of the left-hand-side Tensor.
Returns
Returns true if l_shape and r_shape are compatible for broadcasting.

◆ ReductionShape()

SizeVector open3d::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

Parameters
src_shapeshape to reduce
dimsA list of dimensions to be reduced.
keepdimIf true, the reduced dims will be retained as size 1.

◆ WrapDim()

int64_t open3d::shape_util::WrapDim ( int64_t  dim,
int64_t  max_dim 
)

Wrap around negative dim.

E.g. If max_dim == 5, dim -1 will be converted to 4.