Cortenn
Classes | Typedefs | Functions
llo Namespace Reference

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...
 
EngineTget_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...
 

Detailed Description

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

Typedef Documentation

◆ DataArgsT

using llo::DataArgsT = typedef std::vector<DataArg>

Vector of DataArgs to hold arguments.

◆ EngineT

using llo::EngineT = typedef std::default_random_engine

RNG engine used.

◆ VarptrT

using llo::VarptrT = typedef std::shared_ptr<llo::Variable>

Smart pointer for variable nodes.

Function Documentation

◆ abs()

template<typename T >
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

◆ abs< uint16_t >()

template<>
void llo::abs< uint16_t > ( uint16_t *  out,
VecRef< uint16_t >  in 
)

◆ abs< uint32_t >()

template<>
void llo::abs< uint32_t > ( uint32_t *  out,
VecRef< uint32_t >  in 
)

◆ abs< uint64_t >()

template<>
void llo::abs< uint64_t > ( uint64_t *  out,
VecRef< uint64_t >  in 
)

◆ abs< uint8_t >()

template<>
void llo::abs< uint8_t > ( uint8_t *  out,
VecRef< uint8_t >  in 
)

◆ add()

template<typename T >
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

◆ binary()

template<typename OUT , typename ATYPE , typename BTYPE >
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.

◆ bit_not()

template<typename T >
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

◆ convolution()

ade::TensptrT llo::convolution ( ade::TensptrT  img,
ade::TensptrT  kernel 
)

Return convolution operation on img with kernel.

◆ cos()

template<typename T >
void llo::cos ( T *  out,
VecRef< T >  in 
)

Given reference to output array, and input vector ref, make output elements take cosine of inputs

◆ derive()

ade::TensptrT llo::derive ( ade::TensptrT  root,
ade::iTensor *  target 
)

Derive root with respect to target with zero branches pruned.

◆ deserialize()

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.

◆ div()

template<typename T >
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

◆ eq()

template<typename T >
void llo::eq ( 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

◆ eval()

GenericData llo::eval ( ade::TensptrT  tens,
age::_GENERATED_DTYPE  dtype 
)

Evaluate generic data of tens converted to specified dtype.

◆ exp()

template<typename T >
void llo::exp ( T *  out,
VecRef< T >  in 
)

Given reference to output array, and input vector ref, make output elements take exponent of inputs

◆ get_engine()

EngineT& llo::get_engine ( void  )

Return global random generator.

◆ get_scalar()

template<typename T >
VarptrT llo::get_scalar ( scalar,
ade::Shape  shape,
std::string  label = "" 
)

Return new variable containing 0s according to specified shape and labelled according to input label

◆ get_variable() [1/2]

template<typename T >
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()

◆ get_variable() [2/2]

template<typename T >
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

◆ grad_max()

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

◆ grad_min()

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

◆ grad_prod()

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

◆ gt()

template<typename T >
void llo::gt ( 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

◆ log()

template<typename T >
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

◆ lt()

template<typename T >
void llo::lt ( 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

◆ matmul()

ade::TensptrT llo::matmul ( ade::TensptrT  a,
ade::TensptrT  b 
)

Return matmul of a and b.

◆ max()

template<typename T >
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

◆ min()

template<typename T >
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

◆ mtens_mul()

ade::TensptrT llo::mtens_mul ( ade::TensptrT  lhs,
ade::MappedTensor  rhs 
)

Return product of lhs with mapped rhs.

◆ mul()

template<typename T >
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

◆ neg()

template<typename T >
void llo::neg ( T *  out,
VecRef< T >  in 
)

Given reference to output array, and input vector ref, make output elements take negatives of inputs

◆ neg< uint16_t >()

template<>
void llo::neg< uint16_t > ( uint16_t *  out,
VecRef< uint16_t >  in 
)

◆ neg< uint32_t >()

template<>
void llo::neg< uint32_t > ( uint32_t *  out,
VecRef< uint32_t >  in 
)

◆ neg< uint64_t >()

template<>
void llo::neg< uint64_t > ( uint64_t *  out,
VecRef< uint64_t >  in 
)

◆ neg< uint8_t >()

template<>
void llo::neg< uint8_t > ( uint8_t *  out,
VecRef< uint8_t >  in 
)

◆ neq()

template<typename T >
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

◆ nnary()

template<typename T >
void llo::nnary ( T *  out,
ade::Shape &  outshape,
std::vector< VecRef< T >>  args,
std::function< void(T &, const T &)>  acc 
)

Generic n-nary operation.

◆ pow()

template<typename T >
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

◆ rand_binom()

template<typename T >
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

◆ rand_binom< double >()

template<>
void llo::rand_binom< double > ( double *  out,
ade::Shape &  outshape,
VecRef< double >  a,
VecRef< double >  b 
)

◆ rand_binom< float >()

template<>
void llo::rand_binom< float > ( float *  out,
ade::Shape &  outshape,
VecRef< float >  a,
VecRef< double >  b 
)

◆ rand_normal()

template<typename T >
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

◆ rand_normal< double >()

template<>
void llo::rand_normal< double > ( double *  out,
ade::Shape &  outshape,
VecRef< double >  a,
VecRef< double >  b 
)

◆ rand_normal< float >()

template<>
void llo::rand_normal< float > ( float *  out,
ade::Shape &  outshape,
VecRef< float >  a,
VecRef< float >  b 
)

◆ rand_uniform()

template<typename T >
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

◆ rand_uniform< double >()

template<>
void llo::rand_uniform< double > ( double *  out,
ade::Shape &  outshape,
VecRef< double >  a,
VecRef< double >  b 
)

◆ rand_uniform< float >()

template<>
void llo::rand_uniform< float > ( float *  out,
ade::Shape &  outshape,
VecRef< float >  a,
VecRef< float >  b 
)

◆ reduce()

ade::TensptrT llo::reduce ( ade::Opcode  opcode,
ade::TensptrT  tens,
uint8_t  dim 
)

Return reduction of tens after dimension dim using opcode operation.

◆ round()

template<typename T >
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

◆ serialize()

std::string llo::serialize ( const char *  in,
size_t  nelems,
size_t  typecode 
)

Marshal data to cortenn::Source.

◆ sin()

template<typename T >
void llo::sin ( T *  out,
VecRef< T >  in 
)

Given reference to output array, and input vector ref, make output elements take sine of inputs

◆ sqrt()

template<typename T >
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

◆ sub()

template<typename T >
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

◆ tan()

template<typename T >
void llo::tan ( T *  out,
VecRef< T >  in 
)

Given reference to output array, and input vector ref, make output elements take tangent of inputs

◆ to_ref()

template<typename T >
VecRef<T> llo::to_ref ( DataArg arg)

Converts DataArgs to VecRef of specific type.

◆ to_refs()

template<typename T >
std::vector<VecRef<T> > llo::to_refs ( DataArgsT args)

Converts multiple DataArgs to multiple VecRefs of the same type.

◆ unary()

template<typename T >
void llo::unary ( T *  out,
ade::Shape &  outshape,
VecRef< T >  in,
std::function< T(const T &)>  f 
)

Generic unary operation assuming identity mapping.

◆ zero_prune()

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