Open3D (C++ API)  0.17.0
Loading...
Searching...
No Matches
ShapeUtil.h
Go to the documentation of this file.
1// ----------------------------------------------------------------------------
2// - Open3D: www.open3d.org -
3// ----------------------------------------------------------------------------
4// Copyright (c) 2018-2023 www.open3d.org
5// SPDX-License-Identifier: MIT
6// ----------------------------------------------------------------------------
7
8#pragma once
9
13
14namespace open3d {
15namespace core {
16
17class Tensor;
18
19namespace shape_util {
20
29bool IsCompatibleBroadcastShape(const SizeVector& l_shape,
30 const SizeVector& r_shape);
31
39SizeVector BroadcastedShape(const SizeVector& l_shape,
40 const SizeVector& r_shape);
41
49bool CanBeBrocastedToShape(const SizeVector& src_shape,
50 const SizeVector& dst_shape);
51
59SizeVector ReductionShape(const SizeVector& src_shape,
60 const SizeVector& dims,
61 bool keepdim);
62
71int64_t WrapDim(int64_t dim, int64_t max_dim, bool inclusive = false);
72
79SizeVector InferShape(SizeVector shape, int64_t num_elements);
80
82SizeVector Concat(const SizeVector& l_shape, const SizeVector& r_shape);
83
85SizeVector Iota(int64_t n);
86
88SizeVector DefaultStrides(const SizeVector& shape);
89
98std::pair<bool, SizeVector> Restride(const SizeVector& old_shape,
99 const SizeVector& old_strides,
100 const SizeVector& new_shape);
101
102} // namespace shape_util
103} // namespace core
104} // namespace open3d
SizeVector Iota(int64_t n)
Returns a SizeVector of {0, 1, ..., n - 1}, similar to std::iota.
Definition ShapeUtil.cpp:205
SizeVector BroadcastedShape(const SizeVector &l_shape, const SizeVector &r_shape)
Returns the broadcasted shape of two shapes.
Definition ShapeUtil.cpp:56
SizeVector InferShape(SizeVector shape, int64_t num_elements)
Definition ShapeUtil.cpp:150
SizeVector ReductionShape(const SizeVector &src_shape, const SizeVector &dims, bool keepdim)
Returns the shape after reduction.
Definition ShapeUtil.cpp:99
bool IsCompatibleBroadcastShape(const SizeVector &l_shape, const SizeVector &r_shape)
Returns true if two shapes are compatible for broadcasting.
Definition ShapeUtil.cpp:32
std::pair< bool, SizeVector > Restride(const SizeVector &old_shape, const SizeVector &old_strides, const SizeVector &new_shape)
Definition ShapeUtil.cpp:225
int64_t WrapDim(int64_t dim, int64_t max_dim, bool inclusive)
Wrap around negative dim.
Definition ShapeUtil.cpp:131
SizeVector DefaultStrides(const SizeVector &shape)
Compute default strides for a shape when a tensor is contiguous.
Definition ShapeUtil.cpp:214
bool CanBeBrocastedToShape(const SizeVector &src_shape, const SizeVector &dst_shape)
Returns true if src_shape can be brocasted to dst_shape.
Definition ShapeUtil.cpp:90
SizeVector Concat(const SizeVector &l_shape, const SizeVector &r_shape)
Concatenate two shapes.
Definition ShapeUtil.cpp:199
Definition PinholeCameraIntrinsic.cpp:16