Open3D (C++ API)
0.11.0
|
Data Structures | |
struct | CountArgs |
class | Dim |
Class for dimensions for which the value should be inferred. More... | |
class | DimValue |
Class for representing a possibly unknown dimension value. More... | |
class | DimX |
Dim expression class. More... | |
struct | DimXDivide |
struct | DimXMinus |
struct | DimXMultiply |
struct | DimXOr |
struct | DimXPlus |
Enumerations | |
enum | CSOpt { CSOpt::NONE = 0, CSOpt::COMBINE_FIRST_DIMS, CSOpt::IGNORE_FIRST_DIMS, CSOpt::COMBINE_LAST_DIMS, CSOpt::IGNORE_LAST_DIMS } |
Check shape options. More... | |
Functions | |
DimValue | UnknownValue () |
template<class TLeft , class TRight , class TOp > | |
bool | operator== (DimValue a, DimX< TLeft, TRight, TOp > &&b) |
bool | operator== (DimValue a, Dim b) |
template<class TLeft , class TRight , class TOp > | |
std::string | GetString (DimX< TLeft, TRight, TOp > a, bool show_value=true) |
std::string | GetString (Dim a, bool show_value=true) |
template<class TLeft , class TRight , class TOp > | |
int64_t | GetValue (DimX< TLeft, TRight, TOp > a) |
template<class TLeft , class TRight , class TOp > | |
int64_t | GetValue (DimX< TLeft, TRight, TOp > a, int64_t unknown_dim_value) |
int64_t | GetValue (Dim a) |
int64_t | GetValue (Dim a, int64_t unknown_dim_value) |
std::string | CreateDimXString () |
template<class TDimX > | |
std::string | CreateDimXString (TDimX dimex) |
template<class TDimX , class... TArgs> | |
std::string | CreateDimXString (TDimX dimex, TArgs... args) |
template<class TDimX > | |
void | CreateDimVector (std::vector< int64_t > &out, int64_t unknown_dim_value, TDimX dimex) |
template<class TDimX , class... TArgs> | |
void | CreateDimVector (std::vector< int64_t > &out, int64_t unknown_dim_value, TDimX dimex, TArgs... args) |
template<class TDimX > | |
std::vector< int64_t > | CreateDimVector (int64_t unknown_dim_value, TDimX dimex) |
template<class TDimX , class... TArgs> | |
std::vector< int64_t > | CreateDimVector (int64_t unknown_dim_value, TDimX dimex, TArgs... args) |
template<class TLeft , class TRight , class TOp > | |
bool | CheckDim (const DimValue &lhs, DimX< TLeft, TRight, TOp > &&rhs) |
bool | CheckDim (const DimValue &lhs, Dim d) |
template<CSOpt Opt = CSOpt::NONE, class TDimX > | |
bool | _CheckShape (const std::vector< DimValue > &shape, TDimX &&dimex) |
template<CSOpt Opt = CSOpt::NONE, class TDimX , class... TArgs> | |
bool | _CheckShape (const std::vector< DimValue > &shape, TDimX &&dimex, TArgs &&... args) |
template<CSOpt Opt = CSOpt::NONE, class TDimX , class... TArgs> | |
std::tuple< bool, std::string > | CheckShape (const std::vector< DimValue > &shape, TDimX &&dimex, TArgs &&... args) |
|
strong |
bool open3d::ml::op_util::_CheckShape | ( | const std::vector< DimValue > & | shape, |
TDimX && | dimex | ||
) |
bool open3d::ml::op_util::_CheckShape | ( | const std::vector< DimValue > & | shape, |
TDimX && | dimex, | ||
TArgs &&... | args | ||
) |
bool open3d::ml::op_util::CheckDim | ( | const DimValue & | lhs, |
DimX< TLeft, TRight, TOp > && | rhs | ||
) |
std::tuple<bool, std::string> open3d::ml::op_util::CheckShape | ( | const std::vector< DimValue > & | shape, |
TDimX && | dimex, | ||
TArgs &&... | args | ||
) |
Function for checking a shape with dim expressions. Usage example:
Dim depth("depth"); Dim height("height"); Dim width("width"); status = CheckShape({30,40}, height, width); // VALID, will assign values // to height and width
status = CheckShape({50,41}, height+20, width+1); // VALID, values match status = CheckShape({20,30,40}, depth+10, height, width); // VALID, will // assign 10 to depth
status = CheckShape({0},depth||0); // VALID, shape must match depth or 0 status = CheckShape({10}, depth||0); // VALID, shape must match depth or 0 status = CheckShape({123,10}, Dim(), depth); // VALID, first dim may be // anything
status = CheckShape<CSOpt::COMBINE_LAST_DIMS>({123,10,4}, Dim(), width); // VALID, width==40==10*4
status = CheckShape<CSOpt::COMBINE_FIRST_DIMS>( {10,2,2,123,456}, width, Dim(), Dim()); // VALID, width==40==10*2*2
status = CheckShape({70}, height+width); // VALID, works because height // and width have been initialized since the first call to CheckShape
status = CheckShape({1,2,3}, Dim(), Dim()); // INVALID, rank mismatch 3vs2 status = CheckShape({1,2,3}, depth, width, height); // INVALID, at least // one dim does not match
The options CSOpt::COMBINE_FIRST_DIMS and CSOpt::COMBINE_LAST_DIMS allow to match the rank of the dim expressions by combining the shape dimensions at the beginning or end. The options CSOpt::IGNORE_FIRST_DIMS and CSOpt::IGNORE_LAST_DIMS allow to ignore additional dimensions in the shape.
The shape to be cheked may contain unknowns Dim A("A"); Dim B("B"); status = CheckShape({30, UnknownValue()}, A, B); // VALID, A is 30 and B // is still unknown
status = CheckShape<CSOpt::COMBINE_LAST_DIMS>({30,1,2,UnknownValue()},A,B); // VALID, A is 30 and B is still unknown
The following shows some limitations of the dim expressions Dim A("A"); Dim B("B"); status = CheckShape({30}, A+B); // THROWS EXCEPTION, illegal expression // because neither A or B is a constant
However, the following will work Dim A(20,"A"); Dim B("B"); status = CheckShape({30}, A+B); // VALID, B is now 10
This will work, too Dim A("A"); // uninitialized Dim B("B"); status = CheckShape({20}, A); // VALID, A is now 20 status = CheckShape({30}, A+B); // VALID, B is now 10
Multiplication and division are not allowed for unknown dims Dim A("A"); status = CheckShape({30}, 3*A); // THROWS EXCEPTION, although expression // seems reasonable status = CheckShape({20}, 3*A); // THROWS EXCEPTION, this // is the reason why mul/div is only allowed for known dims
Important, do not create objects of dim expressions, i.e., auto dimx = Dim("tmp") + 3; status = CheckShape({20}, dimx); // intended to not compile Assigning a value to dimx will assign a value to Dim("tmp") which has a shorter lifetime.
The return value is a tuple <bool,std::string>. If the bool is false then the shape is INVALID and the string contains an error message of the form "got [shape], expected [dim expressions]". If true then the shape is VALID and the error string is empty.
Note the goal of this function is to simplify checking tensor shapes. There may be cases where shapes cannot be checked with the provided functionality and you have to write custom shape checking code.
shape | This is the actual shape of an object. |
args | This is a list of dim expression |
void open3d::ml::op_util::CreateDimVector | ( | std::vector< int64_t > & | out, |
int64_t | unknown_dim_value, | ||
TDimX | dimex | ||
) |
void open3d::ml::op_util::CreateDimVector | ( | std::vector< int64_t > & | out, |
int64_t | unknown_dim_value, | ||
TDimX | dimex, | ||
TArgs... | args | ||
) |
std::vector<int64_t> open3d::ml::op_util::CreateDimVector | ( | int64_t | unknown_dim_value, |
TDimX | dimex | ||
) |
std::vector<int64_t> open3d::ml::op_util::CreateDimVector | ( | int64_t | unknown_dim_value, |
TDimX | dimex, | ||
TArgs... | args | ||
) |
|
inline |
std::string open3d::ml::op_util::CreateDimXString | ( | TDimX | dimex | ) |
std::string open3d::ml::op_util::CreateDimXString | ( | TDimX | dimex, |
TArgs... | args | ||
) |
std::string open3d::ml::op_util::GetString | ( | DimX< TLeft, TRight, TOp > | a, |
bool | show_value = true |
||
) |
|
inline |
int64_t open3d::ml::op_util::GetValue | ( | DimX< TLeft, TRight, TOp > | a | ) |
int64_t open3d::ml::op_util::GetValue | ( | DimX< TLeft, TRight, TOp > | a, |
int64_t | unknown_dim_value | ||
) |
|
inline |
|
inline |
|
inline |
|
inline |