![]() |
ACloudViewer
3.9.4
A Modern Library for 3D Data Processing
|
Classes | |
| class | DimValue |
| Class for representing a possibly unknown dimension value. More... | |
| class | Dim |
| Class for dimensions for which the value should be inferred. More... | |
| struct | DimXPlus |
| struct | DimXMinus |
| struct | DimXMultiply |
| struct | DimXDivide |
| struct | DimXOr |
| class | DimX |
| Dim expression class. More... | |
| struct | CountArgs |
Enumerations | |
| enum class | CSOpt { NONE = 0 , COMBINE_FIRST_DIMS , IGNORE_FIRST_DIMS , COMBINE_LAST_DIMS , IGNORE_LAST_DIMS } |
| Check shape options. More... | |
Functions | |
| DimValue | UnknownValue () |
| DimX< Dim, Dim, DimXPlus > | operator+ (Dim a, Dim b) |
| template<class TL , class TR , class TOp > | |
| DimX< Dim, DimX< TL, TR, TOp >, DimXPlus > | operator+ (Dim a, DimX< TL, TR, TOp > &&b) |
| template<class TL , class TR , class TOp > | |
| DimX< DimX< TL, TR, TOp >, Dim, DimXPlus > | operator+ (DimX< TL, TR, TOp > &&a, Dim b) |
| template<class TL1 , class TR1 , class TOp1 , class TL2 , class TR2 , class TOp2 > | |
| DimX< DimX< TL1, TR1, TOp1 >, DimX< TL2, TR2, TOp2 >, DimXPlus > | operator+ (DimX< TL1, TR1, TOp1 > &&a, DimX< TL2, TR2, TOp2 > &&b) |
| DimX< Dim, Dim, DimXMinus > | operator- (Dim a, Dim b) |
| template<class TL , class TR , class TOp > | |
| DimX< Dim, DimX< TL, TR, TOp >, DimXMinus > | operator- (Dim a, DimX< TL, TR, TOp > &&b) |
| template<class TL , class TR , class TOp > | |
| DimX< DimX< TL, TR, TOp >, Dim, DimXMinus > | operator- (DimX< TL, TR, TOp > &&a, Dim b) |
| template<class TL1 , class TR1 , class TOp1 , class TL2 , class TR2 , class TOp2 > | |
| DimX< DimX< TL1, TR1, TOp1 >, DimX< TL2, TR2, TOp2 >, DimXMinus > | operator- (DimX< TL1, TR1, TOp1 > &&a, DimX< TL2, TR2, TOp2 > &&b) |
| DimX< Dim, Dim, DimXMultiply > | operator* (Dim a, Dim b) |
| template<class TL , class TR , class TOp > | |
| DimX< Dim, DimX< TL, TR, TOp >, DimXMultiply > | operator* (Dim a, DimX< TL, TR, TOp > &&b) |
| template<class TL , class TR , class TOp > | |
| DimX< DimX< TL, TR, TOp >, Dim, DimXMultiply > | operator* (DimX< TL, TR, TOp > &&a, Dim b) |
| template<class TL1 , class TR1 , class TOp1 , class TL2 , class TR2 , class TOp2 > | |
| DimX< DimX< TL1, TR1, TOp1 >, DimX< TL2, TR2, TOp2 >, DimXMultiply > | operator* (DimX< TL1, TR1, TOp1 > &&a, DimX< TL2, TR2, TOp2 > &&b) |
| DimX< Dim, Dim, DimXDivide > | operator/ (Dim a, Dim b) |
| template<class TL , class TR , class TOp > | |
| DimX< Dim, DimX< TL, TR, TOp >, DimXDivide > | operator/ (Dim a, DimX< TL, TR, TOp > &&b) |
| template<class TL , class TR , class TOp > | |
| DimX< DimX< TL, TR, TOp >, Dim, DimXDivide > | operator/ (DimX< TL, TR, TOp > &&a, Dim b) |
| template<class TL1 , class TR1 , class TOp1 , class TL2 , class TR2 , class TOp2 > | |
| DimX< DimX< TL1, TR1, TOp1 >, DimX< TL2, TR2, TOp2 >, DimXDivide > | operator/ (DimX< TL1, TR1, TOp1 > &&a, DimX< TL2, TR2, TOp2 > &&b) |
| DimX< Dim, Dim, DimXOr > | operator|| (Dim a, Dim b) |
| template<class TL , class TR , class TOp > | |
| DimX< Dim, DimX< TL, TR, TOp >, DimXOr > | operator|| (Dim a, DimX< TL, TR, TOp > &&b) |
| template<class TL , class TR , class TOp > | |
| DimX< DimX< TL, TR, TOp >, Dim, DimXOr > | operator|| (DimX< TL, TR, TOp > &&a, Dim b) |
| template<class TL1 , class TR1 , class TOp1 , class TL2 , class TR2 , class TOp2 > | |
| DimX< DimX< TL1, TR1, TOp1 >, DimX< TL2, TR2, TOp2 >, DimXOr > | operator|| (DimX< TL1, TR1, TOp1 > &&a, DimX< TL2, TR2, TOp2 > &&b) |
| 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 |
Check shape options.
| Enumerator | |
|---|---|
| NONE | |
| COMBINE_FIRST_DIMS | |
| IGNORE_FIRST_DIMS | |
| COMBINE_LAST_DIMS | |
| IGNORE_LAST_DIMS | |
Definition at line 405 of file ShapeChecking.h.
| bool cloudViewer::ml::op_util::_CheckShape | ( | const std::vector< DimValue > & | shape, |
| TDimX && | dimex | ||
| ) |
Definition at line 414 of file ShapeChecking.h.
References CheckDim(), COMBINE_FIRST_DIMS, COMBINE_LAST_DIMS, IGNORE_FIRST_DIMS, and NONE.
| bool cloudViewer::ml::op_util::_CheckShape | ( | const std::vector< DimValue > & | shape, |
| TDimX && | dimex, | ||
| TArgs &&... | args | ||
| ) |
Definition at line 446 of file ShapeChecking.h.
References CheckDim(), COMBINE_FIRST_DIMS, IGNORE_FIRST_DIMS, NONE, and offset.
Definition at line 399 of file ShapeChecking.h.
| bool cloudViewer::ml::op_util::CheckDim | ( | const DimValue & | lhs, |
| DimX< TLeft, TRight, TOp > && | rhs | ||
| ) |
Definition at line 394 of file ShapeChecking.h.
Referenced by _CheckShape().
| std::tuple<bool, std::string> cloudViewer::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 |
Definition at line 574 of file ShapeChecking.h.
References COMBINE_FIRST_DIMS, COMBINE_LAST_DIMS, CreateDimXString(), GetString(), IGNORE_FIRST_DIMS, IGNORE_LAST_DIMS, NONE, and patch::to_string().
| std::vector<int64_t> cloudViewer::ml::op_util::CreateDimVector | ( | int64_t | unknown_dim_value, |
| TDimX | dimex | ||
| ) |
Definition at line 374 of file ShapeChecking.h.
| std::vector<int64_t> cloudViewer::ml::op_util::CreateDimVector | ( | int64_t | unknown_dim_value, |
| TDimX | dimex, | ||
| TArgs... | args | ||
| ) |
Definition at line 381 of file ShapeChecking.h.
| void cloudViewer::ml::op_util::CreateDimVector | ( | std::vector< int64_t > & | out, |
| int64_t | unknown_dim_value, | ||
| TDimX | dimex | ||
| ) |
Definition at line 358 of file ShapeChecking.h.
| void cloudViewer::ml::op_util::CreateDimVector | ( | std::vector< int64_t > & | out, |
| int64_t | unknown_dim_value, | ||
| TDimX | dimex, | ||
| TArgs... | args | ||
| ) |
Definition at line 365 of file ShapeChecking.h.
|
inline |
Definition at line 345 of file ShapeChecking.h.
Referenced by CheckShape(), and CreateDimXString().
| std::string cloudViewer::ml::op_util::CreateDimXString | ( | TDimX | dimex | ) |
Definition at line 348 of file ShapeChecking.h.
References GetString().
| std::string cloudViewer::ml::op_util::CreateDimXString | ( | TDimX | dimex, |
| TArgs... | args | ||
| ) |
Definition at line 353 of file ShapeChecking.h.
References CreateDimXString(), and GetString().
|
inline |
Definition at line 316 of file ShapeChecking.h.
References cloudViewer::ml::op_util::Dim::ToString().
| std::string cloudViewer::ml::op_util::GetString | ( | DimX< TLeft, TRight, TOp > | a, |
| bool | show_value = true |
||
| ) |
Definition at line 312 of file ShapeChecking.h.
References cloudViewer::ml::op_util::DimX< TLeft, TRight, TOp >::ToString().
Referenced by cloudViewer::ml::op_util::DimXPlus::backprop(), cloudViewer::ml::op_util::DimXMinus::backprop(), cloudViewer::ml::op_util::DimXMultiply::backprop(), cloudViewer::ml::op_util::DimXDivide::backprop(), CheckShape(), and CreateDimXString().
|
inline |
Definition at line 335 of file ShapeChecking.h.
References cloudViewer::ml::op_util::Dim::value().
|
inline |
Definition at line 337 of file ShapeChecking.h.
References cloudViewer::ml::op_util::Dim::constant(), and cloudViewer::ml::op_util::Dim::value().
| int64_t cloudViewer::ml::op_util::GetValue | ( | DimX< TLeft, TRight, TOp > | a | ) |
Definition at line 321 of file ShapeChecking.h.
References cloudViewer::ml::op_util::DimX< TLeft, TRight, TOp >::value().
| int64_t cloudViewer::ml::op_util::GetValue | ( | DimX< TLeft, TRight, TOp > | a, |
| int64_t | unknown_dim_value | ||
| ) |
Definition at line 326 of file ShapeChecking.h.
References cloudViewer::ml::op_util::DimX< TLeft, TRight, TOp >::constant(), and cloudViewer::ml::op_util::DimX< TLeft, TRight, TOp >::value().
Definition at line 276 of file ShapeChecking.h.
|
inline |
Definition at line 276 of file ShapeChecking.h.
|
inline |
Definition at line 276 of file ShapeChecking.h.
|
inline |
Definition at line 276 of file ShapeChecking.h.
Definition at line 274 of file ShapeChecking.h.
|
inline |
Definition at line 274 of file ShapeChecking.h.
|
inline |
Definition at line 274 of file ShapeChecking.h.
|
inline |
Definition at line 274 of file ShapeChecking.h.
Definition at line 275 of file ShapeChecking.h.
|
inline |
Definition at line 275 of file ShapeChecking.h.
|
inline |
Definition at line 275 of file ShapeChecking.h.
|
inline |
Definition at line 275 of file ShapeChecking.h.
Definition at line 277 of file ShapeChecking.h.
|
inline |
Definition at line 277 of file ShapeChecking.h.
|
inline |
Definition at line 277 of file ShapeChecking.h.
|
inline |
Definition at line 277 of file ShapeChecking.h.
Definition at line 295 of file ShapeChecking.h.
References cloudViewer::ml::op_util::Dim::assign(), cloudViewer::ml::op_util::DimValue::constant(), and cloudViewer::ml::op_util::DimValue::value().
|
inline |
Definition at line 287 of file ShapeChecking.h.
References cloudViewer::ml::op_util::DimValue::constant(), and cloudViewer::ml::op_util::DimValue::value().
Definition at line 278 of file ShapeChecking.h.
|
inline |
Definition at line 278 of file ShapeChecking.h.
|
inline |
Definition at line 278 of file ShapeChecking.h.
|
inline |
Definition at line 278 of file ShapeChecking.h.
|
inline |
Definition at line 47 of file ShapeChecking.h.