Helpers Overview (CUDNN, OneDNN,Armcompute)
Requirements Helper
Requirements helper was introduced to replace plain checks for making them output informative messages (Debug and Verbose mode) and also replace macros REQUIRE_TRUE.
it will lazily evaluate values and messages if the type wrapped and has
getValue
andgetMsg
methodsit is implicit bool. this makes it usable with logical operators and also inside if conditions. Besides it will benefit from shortcircuit nature of those operators.
it has the following check methods
you can either log the success case or throw error on the failure
it can use plain types for checks.
if value has stream operator it will be used to output it's value. for custom types you may need add that by yourself
ostream& operator<<(ostream& os, const CustomUserType& dt)
there is generic template
InfoVariable
wrapper for types to make it informative. you can use lambda operators with them as well to make it lazily evaluatedwe added custom
ShapeInfoVariable
wrapper for the NDArray and vector<> shapes to make them informativeone can use
expect
to add its own proper comparision. simple lambda for that will be like this:
Examples:
firstly, we should enable logging
simple case
Output: Requirement Helper Example#1: {20} expected to be equal to 21
using InfoVariable wrapper
Output:
helper behavior while using many checks in one block
Output:
As it is seen the second check did not happen as the previous failed. But still getAge()
method was called as its function argument.
using shortcircuit to avoid Requirement call at all if the previous one was failed
Output:
using lambdas with InfoVariable. it will make it lazily evaluated
Output:
```
lambda call#2
Requirement Helper Example#5: twenty {20} expected to be equal to twenty one 21
Output:
custom comparision lambda and also another usage of the custom wrapper written by us
ShapeInfoVariable
. Note: we will usestd::vector<int>
. this wrapper can be used withNDArray
as well.
Output:
throw error when there is failure
Output:
Here is live example:
Note: some classes were mocked there and do not represent the exact implementations in libnd4j. https://godbolt.org/z/sq98vchs5
Last updated