Cortenn
|
Classes | |
struct | DataArg |
Data to pass around when evaluating. More... | |
struct | Evaluator |
struct | GenericData |
GenericData for holding data when passing up the tensor graph. More... | |
struct | GenericRef |
struct | Variable |
Leaf node containing GenericData. More... | |
struct | VecRef |
Typedefs | |
using | VarptrT = std::shared_ptr< llo::Variable > |
Smart pointer for variable nodes. More... | |
using | DataArgsT = std::vector< DataArg > |
Vector of DataArgs to hold arguments. More... | |
using | EngineT = std::default_random_engine |
RNG engine used. More... | |
Functions | |
template<typename T > | |
VarptrT | get_variable (std::vector< T > data, ade::Shape shape, std::string label="") |
template<typename T > | |
VarptrT | get_variable (ade::Shape shape, std::string label="") |
template<typename T > | |
VarptrT | get_scalar (T scalar, ade::Shape shape, std::string label="") |
template<typename T > | |
VecRef< T > | to_ref (DataArg &arg) |
Converts DataArgs to VecRef of specific type. More... | |
template<typename T > | |
std::vector< VecRef< T > > | to_refs (DataArgsT &args) |
Converts multiple DataArgs to multiple VecRefs of the same type. More... | |
GenericData | eval (ade::TensptrT tens, age::_GENERATED_DTYPE dtype) |
Evaluate generic data of tens converted to specified dtype. More... | |
ade::TensptrT | mtens_mul (ade::TensptrT lhs, ade::MappedTensor rhs) |
Return product of lhs with mapped rhs. More... | |
ade::TensptrT | grad_prod (ade::iFunctor *fwd, size_t gradidx, ade::TensT tens) |
ade::TensptrT | grad_min (ade::iFunctor *fwd, size_t gradidx, ade::TensT tens) |
ade::TensptrT | grad_max (ade::iFunctor *fwd, size_t gradidx, ade::TensT tens) |
ade::TensptrT | reduce (ade::Opcode opcode, ade::TensptrT tens, uint8_t dim) |
Return reduction of tens after dimension dim using opcode operation. More... | |
ade::TensptrT | matmul (ade::TensptrT a, ade::TensptrT b) |
Return matmul of a and b. More... | |
ade::TensptrT | convolution (ade::TensptrT img, ade::TensptrT kernel) |
Return convolution operation on img with kernel. More... | |
EngineT & | get_engine (void) |
Return global random generator. More... | |
template<typename T > | |
void | unary (T *out, ade::Shape &outshape, VecRef< T > in, std::function< T(const T &)> f) |
Generic unary operation assuming identity mapping. More... | |
template<typename T > | |
void | abs (T *out, VecRef< T > in) |
template<> | |
void | abs< uint8_t > (uint8_t *out, VecRef< uint8_t > in) |
template<> | |
void | abs< uint16_t > (uint16_t *out, VecRef< uint16_t > in) |
template<> | |
void | abs< uint32_t > (uint32_t *out, VecRef< uint32_t > in) |
template<> | |
void | abs< uint64_t > (uint64_t *out, VecRef< uint64_t > in) |
template<typename T > | |
void | neg (T *out, VecRef< T > in) |
template<> | |
void | neg< uint8_t > (uint8_t *out, VecRef< uint8_t > in) |
template<> | |
void | neg< uint16_t > (uint16_t *out, VecRef< uint16_t > in) |
template<> | |
void | neg< uint32_t > (uint32_t *out, VecRef< uint32_t > in) |
template<> | |
void | neg< uint64_t > (uint64_t *out, VecRef< uint64_t > in) |
template<typename T > | |
void | bit_not (T *out, VecRef< T > in) |
template<typename T > | |
void | sin (T *out, VecRef< T > in) |
template<typename T > | |
void | cos (T *out, VecRef< T > in) |
template<typename T > | |
void | tan (T *out, VecRef< T > in) |
template<typename T > | |
void | exp (T *out, VecRef< T > in) |
template<typename T > | |
void | log (T *out, VecRef< T > in) |
template<typename T > | |
void | sqrt (T *out, VecRef< T > in) |
template<typename T > | |
void | round (T *out, VecRef< T > in) |
template<typename OUT , typename ATYPE , typename BTYPE > | |
void | binary (OUT *out, ade::Shape &outshape, VecRef< ATYPE > a, VecRef< BTYPE > b, std::function< OUT(const ATYPE &, const BTYPE &)> f) |
Generic binary operation assuming identity mapping. More... | |
template<typename T > | |
void | pow (T *out, ade::Shape &outshape, VecRef< T > a, VecRef< T > b) |
template<typename T > | |
void | sub (T *out, ade::Shape &outshape, VecRef< T > a, VecRef< T > b) |
template<typename T > | |
void | div (T *out, ade::Shape &outshape, VecRef< T > a, VecRef< T > b) |
template<typename T > | |
void | eq (T *out, ade::Shape &outshape, VecRef< T > a, VecRef< T > b) |
template<typename T > | |
void | neq (T *out, ade::Shape &outshape, VecRef< T > a, VecRef< T > b) |
template<typename T > | |
void | lt (T *out, ade::Shape &outshape, VecRef< T > a, VecRef< T > b) |
template<typename T > | |
void | gt (T *out, ade::Shape &outshape, VecRef< T > a, VecRef< T > b) |
template<typename T > | |
void | rand_binom (T *out, ade::Shape &outshape, VecRef< T > a, VecRef< double > b) |
template<> | |
void | rand_binom< double > (double *out, ade::Shape &outshape, VecRef< double > a, VecRef< double > b) |
template<> | |
void | rand_binom< float > (float *out, ade::Shape &outshape, VecRef< float > a, VecRef< double > b) |
template<typename T > | |
void | rand_uniform (T *out, ade::Shape &outshape, VecRef< T > a, VecRef< T > b) |
template<> | |
void | rand_uniform< double > (double *out, ade::Shape &outshape, VecRef< double > a, VecRef< double > b) |
template<> | |
void | rand_uniform< float > (float *out, ade::Shape &outshape, VecRef< float > a, VecRef< float > b) |
template<typename T > | |
void | rand_normal (T *out, ade::Shape &outshape, VecRef< T > a, VecRef< T > b) |
template<> | |
void | rand_normal< double > (double *out, ade::Shape &outshape, VecRef< double > a, VecRef< double > b) |
template<> | |
void | rand_normal< float > (float *out, ade::Shape &outshape, VecRef< float > a, VecRef< float > b) |
template<typename T > | |
void | nnary (T *out, ade::Shape &outshape, std::vector< VecRef< T >> args, std::function< void(T &, const T &)> acc) |
Generic n-nary operation. More... | |
template<typename T > | |
void | add (T *out, ade::Shape &outshape, std::vector< VecRef< T >> args) |
template<typename T > | |
void | mul (T *out, ade::Shape &outshape, std::vector< VecRef< T >> args) |
template<typename T > | |
void | min (T *out, ade::Shape &outshape, std::vector< VecRef< T >> args) |
template<typename T > | |
void | max (T *out, ade::Shape &outshape, std::vector< VecRef< T >> args) |
std::string | serialize (const char *in, size_t nelems, size_t typecode) |
Marshal data to cortenn::Source. More... | |
ade::TensptrT | deserialize (const char *pb, ade::Shape shape, size_t typecode, std::string label) |
Unmarshal cortenn::Source as Variable containing context of source. More... | |
ade::TensptrT | zero_prune (ade::TensptrT root) |
ade::TensptrT | derive (ade::TensptrT root, ade::iTensor *target) |
Derive root with respect to target with zero branches pruned. More... | |
data.hpp llo
Purpose: Define data structures for owning, and passing generalized and type-specific data
helper.hpp llo
Purpose: Helper functions for generated age files
operator.hpp llo
Purpose: Define functions manipulating tensor data values No function in this file makes any attempt to check for nullptrs
serialize.hpp llo
Purpose: Define functions for marshal and unmarshal data sources
zprune.hpp llo
Purpose: Define llo zero pruning functions
using llo::DataArgsT = typedef std::vector<DataArg> |
Vector of DataArgs to hold arguments.
using llo::EngineT = typedef std::default_random_engine |
RNG engine used.
using llo::VarptrT = typedef std::shared_ptr<llo::Variable> |
Smart pointer for variable nodes.
void llo::abs | ( | T * | out, |
VecRef< T > | in | ||
) |
Given reference to output array, and input vector ref, make output elements take absolute value of inputs
void llo::add | ( | T * | out, |
ade::Shape & | outshape, | ||
std::vector< VecRef< T >> | args | ||
) |
Given arguments, for every mapped index i in range [0:max_nelems], sum all elements for all arguments
void llo::binary | ( | OUT * | out, |
ade::Shape & | outshape, | ||
VecRef< ATYPE > | a, | ||
VecRef< BTYPE > | b, | ||
std::function< OUT(const ATYPE &, const BTYPE &)> | f | ||
) |
Generic binary operation assuming identity mapping.
void llo::bit_not | ( | T * | out, |
VecRef< T > | in | ||
) |
Given reference to output array, and input vector ref, make output elements take bitwise nots of inputs
ade::TensptrT llo::convolution | ( | ade::TensptrT | img, |
ade::TensptrT | kernel | ||
) |
Return convolution operation on img with kernel.
void llo::cos | ( | T * | out, |
VecRef< T > | in | ||
) |
Given reference to output array, and input vector ref, make output elements take cosine of inputs
ade::TensptrT llo::derive | ( | ade::TensptrT | root, |
ade::iTensor * | target | ||
) |
Derive root with respect to target with zero branches pruned.
ade::TensptrT llo::deserialize | ( | const char * | pb, |
ade::Shape | shape, | ||
size_t | typecode, | ||
std::string | label | ||
) |
Unmarshal cortenn::Source as Variable containing context of source.
void llo::div | ( | T * | out, |
ade::Shape & | outshape, | ||
VecRef< T > | a, | ||
VecRef< T > | b | ||
) |
Given arguments a, and b, for every pair of mapped elements sharing the same index divide Only accept 2 arguments
Given arguments a, and b, for every pair of mapped elements sharing the same index apply == operator Only accept 2 arguments
GenericData llo::eval | ( | ade::TensptrT | tens, |
age::_GENERATED_DTYPE | dtype | ||
) |
Evaluate generic data of tens converted to specified dtype.
void llo::exp | ( | T * | out, |
VecRef< T > | in | ||
) |
Given reference to output array, and input vector ref, make output elements take exponent of inputs
EngineT& llo::get_engine | ( | void | ) |
Return global random generator.
VarptrT llo::get_scalar | ( | T | scalar, |
ade::Shape | shape, | ||
std::string | label = "" |
||
) |
Return new variable containing 0s according to specified shape and labelled according to input label
VarptrT llo::get_variable | ( | std::vector< T > | data, |
ade::Shape | shape, | ||
std::string | label = "" |
||
) |
Return new variable containing input vector data according to specified shape and labelled according to input label Throw error if the input vector size differs from shape.n_elems()
VarptrT llo::get_variable | ( | ade::Shape | shape, |
std::string | label = "" |
||
) |
Return new variable containing 0s according to specified shape and labelled according to input label
ade::TensptrT llo::grad_max | ( | ade::iFunctor * | fwd, |
size_t | gradidx, | ||
ade::TensT | tens | ||
) |
Return the gradient for max operation assuming the target derived wrt is index gradidx and arguments are tens
ade::TensptrT llo::grad_min | ( | ade::iFunctor * | fwd, |
size_t | gradidx, | ||
ade::TensT | tens | ||
) |
Return the gradient for min operation assuming the target derived wrt is index gradidx and arguments are tens
ade::TensptrT llo::grad_prod | ( | ade::iFunctor * | fwd, |
size_t | gradidx, | ||
ade::TensT | tens | ||
) |
Return the gradient for prod operation assuming the target derived wrt is index gradidx and arguments are tens
Given arguments a, and b, for every pair of mapped elements sharing the same index apply > operator Only accept 2 arguments
void llo::log | ( | T * | out, |
VecRef< T > | in | ||
) |
Given reference to output array, and input vector ref, make output elements take natural log of inputs
Given arguments a, and b, for every pair of mapped elements sharing the same index apply < operator Only accept 2 arguments
ade::TensptrT llo::matmul | ( | ade::TensptrT | a, |
ade::TensptrT | b | ||
) |
Return matmul of a and b.
void llo::max | ( | T * | out, |
ade::Shape & | outshape, | ||
std::vector< VecRef< T >> | args | ||
) |
Given arguments, for every mapped index i in range [0:max_nelems], take the maximum all elements for all arguments
void llo::min | ( | T * | out, |
ade::Shape & | outshape, | ||
std::vector< VecRef< T >> | args | ||
) |
Given arguments, for every mapped index i in range [0:max_nelems], take the minimum all elements for all arguments
ade::TensptrT llo::mtens_mul | ( | ade::TensptrT | lhs, |
ade::MappedTensor | rhs | ||
) |
Return product of lhs with mapped rhs.
void llo::mul | ( | T * | out, |
ade::Shape & | outshape, | ||
std::vector< VecRef< T >> | args | ||
) |
Given arguments, for every mapped index i in range [0:max_nelems], multiply all elements for all arguments
void llo::neg | ( | T * | out, |
VecRef< T > | in | ||
) |
Given reference to output array, and input vector ref, make output elements take negatives of inputs
void llo::neq | ( | T * | out, |
ade::Shape & | outshape, | ||
VecRef< T > | a, | ||
VecRef< T > | b | ||
) |
Given arguments a, and b, for every pair of mapped elements sharing the same index apply != operator Only accept 2 arguments
void llo::nnary | ( | T * | out, |
ade::Shape & | outshape, | ||
std::vector< VecRef< T >> | args, | ||
std::function< void(T &, const T &)> | acc | ||
) |
Generic n-nary operation.
void llo::pow | ( | T * | out, |
ade::Shape & | outshape, | ||
VecRef< T > | a, | ||
VecRef< T > | b | ||
) |
Given arguments a, and b, for every pair of mapped elements sharing the same index apply std::pow operator Only accept 2 arguments
void llo::rand_binom | ( | T * | out, |
ade::Shape & | outshape, | ||
VecRef< T > | a, | ||
VecRef< double > | b | ||
) |
Given arguments a, and b, for every pair of mapped elements sharing the same index apply std::binomial_distribution function Only accept 2 arguments
void llo::rand_binom< double > | ( | double * | out, |
ade::Shape & | outshape, | ||
VecRef< double > | a, | ||
VecRef< double > | b | ||
) |
void llo::rand_binom< float > | ( | float * | out, |
ade::Shape & | outshape, | ||
VecRef< float > | a, | ||
VecRef< double > | b | ||
) |
void llo::rand_normal | ( | T * | out, |
ade::Shape & | outshape, | ||
VecRef< T > | a, | ||
VecRef< T > | b | ||
) |
Given arguments a, and b, for every pair of mapped elements sharing the same index apply std::normal_distribution function Only accept 2 arguments
void llo::rand_normal< double > | ( | double * | out, |
ade::Shape & | outshape, | ||
VecRef< double > | a, | ||
VecRef< double > | b | ||
) |
void llo::rand_normal< float > | ( | float * | out, |
ade::Shape & | outshape, | ||
VecRef< float > | a, | ||
VecRef< float > | b | ||
) |
void llo::rand_uniform | ( | T * | out, |
ade::Shape & | outshape, | ||
VecRef< T > | a, | ||
VecRef< T > | b | ||
) |
Given arguments a, and b, for every pair of mapped elements sharing the same index apply std::uniform_distributon function Only accept 2 arguments
void llo::rand_uniform< double > | ( | double * | out, |
ade::Shape & | outshape, | ||
VecRef< double > | a, | ||
VecRef< double > | b | ||
) |
void llo::rand_uniform< float > | ( | float * | out, |
ade::Shape & | outshape, | ||
VecRef< float > | a, | ||
VecRef< float > | b | ||
) |
ade::TensptrT llo::reduce | ( | ade::Opcode | opcode, |
ade::TensptrT | tens, | ||
uint8_t | dim | ||
) |
Return reduction of tens after dimension dim using opcode operation.
void llo::round | ( | T * | out, |
VecRef< T > | in | ||
) |
Given reference to output array, and input vector ref, make output elements take rounded values of inputs
std::string llo::serialize | ( | const char * | in, |
size_t | nelems, | ||
size_t | typecode | ||
) |
Marshal data to cortenn::Source.
void llo::sin | ( | T * | out, |
VecRef< T > | in | ||
) |
Given reference to output array, and input vector ref, make output elements take sine of inputs
void llo::sqrt | ( | T * | out, |
VecRef< T > | in | ||
) |
Given reference to output array, and input vector ref, make output elements take square root of inputs
void llo::sub | ( | T * | out, |
ade::Shape & | outshape, | ||
VecRef< T > | a, | ||
VecRef< T > | b | ||
) |
Given arguments a, and b, for every pair of mapped elements sharing the same index subtract Only accept 2 arguments
void llo::tan | ( | T * | out, |
VecRef< T > | in | ||
) |
Given reference to output array, and input vector ref, make output elements take tangent of inputs
Converts DataArgs to VecRef of specific type.
Converts multiple DataArgs to multiple VecRefs of the same type.
void llo::unary | ( | T * | out, |
ade::Shape & | outshape, | ||
VecRef< T > | in, | ||
std::function< T(const T &)> | f | ||
) |
Generic unary operation assuming identity mapping.
ade::TensptrT llo::zero_prune | ( | ade::TensptrT | root | ) |
Return tree that prunes zero branches in input according to OPCODE For example, add(x, 0) is converted to simply x, while mul(x, 0) is 0