BlackCat_Tensors
A GPU-supported autograd and linear algebra library, designed for neural network construction
Namespaces | Classes | Typedefs | Functions
bc Namespace Reference

The Evaluator determines if an expression needs to be greedily optimized. More...

Namespaces

 algorithms
 
 allocators
 
 blas
 
 caffe
 
 detail
 
 filesystem
 
 io
 
 nn
 
 oper
 
 random
 
 streams
 
 tensors
 
 traits
 
 utility
 

Classes

struct  device_tag
 
struct  Dim
 
struct  Dim< 0 >
 
struct  host_tag
 
struct  is_system_tag
 
struct  Shape
 
struct  Shape< 0 >
 
struct  Shape< 1 >
 
struct  Strided_Vector_Shape
 
struct  string
 Inherits from std::string. More...
 
class  system_tag_base
 
struct  system_tag_type
 

Typedefs

template<class ValueType >
using Basic_Allocator = allocators::Allocator< ValueType, host_tag >
 
template<class ValueType >
using Cuda_Allocator = allocators::Allocator< ValueType, device_tag >
 
template<class ValueType >
using Cuda_Managed = allocators::Device_Managed< ValueType >
 
using default_system_tag_t = host_tag
 
using size_t = int
 
template<int dim, class ValueType , class Allocator = tensors::detail::default_allocator<ValueType>>
using Tensor = bc::tensors::Tensor_Base< bc::tensors::exprs::Array< bc::Shape< dim >, ValueType, Allocator > >
 
template<class ValueType , class Allocator = tensors::detail::default_allocator<ValueType>>
using Scalar = Tensor< 0, ValueType, Allocator >
 
template<class ValueType , class Allocator = tensors::detail::default_allocator<ValueType>>
using Vector = Tensor< 1, ValueType, Allocator >
 
template<class ValueType , class Allocator = tensors::detail::default_allocator<ValueType>>
using Matrix = Tensor< 2, ValueType, Allocator >
 
template<class ValueType , class Allocator = tensors::detail::default_allocator<ValueType>>
using Cube = Tensor< 3, ValueType, Allocator >
 
template<class ValueType , class Allocator = tensors::detail::default_allocator<ValueType>>
using VecList = bc::tensors::Tensor_Base< bc::tensors::exprs::Vector< ValueType, Allocator > >
 

Functions

template<class RM_UNUSED_FUNCTION_WARNING = void>
void set_print_stream (std::ostream *ostream)
 
template<class RM_UNUSED_FUNCTION_WARNING = void>
std::ostream * get_print_stream ()
 
template<class RM_UNUSED_FUNCTION_WARNING = void>
void set_error_stream (std::ostream *ostream)
 
template<class RM_UNUSED_FUNCTION_WARNING = void>
std::ostream * get_error_stream ()
 
template<class... Ts>
void print (const Ts &... args)
 
template<class... Ts>
void printerr (const Ts &... args)
 
template<class str_type >
void bc_assert (bool condition, str_type msg, const char *file, const char *function, int line)
 
void BC_cuda_assert (cudaError_t code, const char *file, const char *function, int line)
 
void BC_cuda_assert (cublasStatus_t code, const char *file, const char *function, int line)
 
template<class T >
const char * bc_get_classname_of (const T &arg)
 
template<class Stream , class Indexes , class Image , class ImageOut >
void max_pooling_forward (Stream stream, Image image, ImageOut out, Indexes mask, Dim< 2 > krnl_shape, Dim< 2 > padding=Dim< 2 >().fill(0), Dim< 2 > strides={-1,-1})
 
template<class Stream , class Indexes , class Image , class ImageOut >
void max_pooling_backward (Stream stream, Image image, ImageOut delta, Indexes mask, Dim< 2 > krnl_shape, Dim< 2 > padding=Dim< 2 >().fill(0), Dim< 2 > strides=Dim< 2 >().fill(-1))
 
template<class Stream , class ColumnImage , class Image >
void im2col (Stream stream, ColumnImage col_image, Image image, bc::Dim< 3 > krnl_shape, bc::Dim< 2 > padding=bc::Dim< 2 >().fill(0), bc::Dim< 2 > strides=bc::Dim< 2 >().fill(1), bc::Dim< 2 > dilation=bc::Dim< 2 >().fill(1), int numb_spatial_axis=2)
 
template<class Stream , class ColumnImage , class Image >
void col2im (Stream stream, ColumnImage col_image, Image image, bc::Dim< 3 > krnl_shape, bc::Dim< 2 > padding=bc::Dim< 2 >(), bc::Dim< 2 > strides=bc::Dim< 2 >().fill(1), bc::Dim< 2 > dilation=bc::Dim< 2 >().fill(1))
 
template<class... Integers>
BCINLINE auto dim (const Integers &... ints)
 
template<class... Integers, typename = std::enable_if_t< traits::sequence_of_v<size_t, Integers...>>>
BCINLINE auto shape (Integers... ints)
 
template<class InnerShape , typename = std::enable_if_t<! traits::sequence_of_v<size_t, InnerShape>>>
BCINLINE auto shape (InnerShape is)
 

Detailed Description

The Evaluator determines if an expression needs to be greedily optimized.

If it attempts to use the left-hand variable (the output) as cache to reduce temporaries as possible. Then, if functions still requiring evaluating will use temporaries to replace the functions and finally complete the evaluation of the expresssion with an elementwise (nd_evaluator).

Example: (assume matrices) y += a * b + c * d

Naively, this expression may generate 2 temporaries, one for each matrix multiplication. However, a more efficient way to evaluate this equation would be to make 2 gemm calls, gemm(y,a,b) and gemm(y, c, d).

This expression reordering works with more complex calls, such as.... y = abs(a * b + c * d).

Here we can apply... (the second gemm call updateing alpha to 1) gemm(y,a,b), gemm(y,c,d) followed by evaluating y := abs(y).

Typedef Documentation

◆ Basic_Allocator

template<class ValueType >
using bc::Basic_Allocator = typedef allocators::Allocator<ValueType, host_tag>

◆ Cube

template<class ValueType , class Allocator = tensors::detail::default_allocator<ValueType>>
using bc::Cube = typedef Tensor<3, ValueType, Allocator>

◆ Cuda_Allocator

template<class ValueType >
using bc::Cuda_Allocator = typedef allocators::Allocator<ValueType, device_tag>

◆ Cuda_Managed

template<class ValueType >
using bc::Cuda_Managed = typedef allocators::Device_Managed<ValueType>

◆ default_system_tag_t

◆ Matrix

template<class ValueType , class Allocator = tensors::detail::default_allocator<ValueType>>
using bc::Matrix = typedef Tensor<2, ValueType, Allocator>

◆ Scalar

template<class ValueType , class Allocator = tensors::detail::default_allocator<ValueType>>
using bc::Scalar = typedef Tensor<0, ValueType, Allocator>

◆ size_t

using bc::size_t = typedef int

◆ Tensor

template<int dim, class ValueType , class Allocator = tensors::detail::default_allocator<ValueType>>
using bc::Tensor = typedef bc::tensors::Tensor_Base< bc::tensors::exprs::Array< bc::Shape<dim>, ValueType, Allocator> >

◆ VecList

template<class ValueType , class Allocator = tensors::detail::default_allocator<ValueType>>
using bc::VecList = typedef bc::tensors::Tensor_Base<bc::tensors::exprs::Vector<ValueType, Allocator> >

◆ Vector

template<class ValueType , class Allocator = tensors::detail::default_allocator<ValueType>>
using bc::Vector = typedef Tensor<1, ValueType, Allocator>

Function Documentation

◆ bc_assert()

template<class str_type >
void bc::bc_assert ( bool  condition,
str_type  msg,
const char *  file,
const char *  function,
int  line 
)
inline

◆ BC_cuda_assert() [1/2]

void bc::BC_cuda_assert ( cudaError_t  code,
const char *  file,
const char *  function,
int  line 
)
inline

◆ BC_cuda_assert() [2/2]

void bc::BC_cuda_assert ( cublasStatus_t  code,
const char *  file,
const char *  function,
int  line 
)
inline

◆ bc_get_classname_of()

template<class T >
const char* bc::bc_get_classname_of ( const T &  arg)
inline

◆ col2im()

template<class Stream , class ColumnImage , class Image >
void bc::col2im ( Stream  stream,
ColumnImage  col_image,
Image  image,
bc::Dim< 3 >  krnl_shape,
bc::Dim< 2 >  padding = bc::Dim<2>(),
bc::Dim< 2 >  strides = bc::Dim<2>().fill(1),
bc::Dim< 2 >  dilation = bc::Dim<2>().fill(1) 
)

◆ dim()

template<class... Integers>
BCINLINE auto bc::dim ( const Integers &...  ints)

◆ get_error_stream()

template<class RM_UNUSED_FUNCTION_WARNING = void>
std::ostream* bc::get_error_stream ( )
inline

◆ get_print_stream()

template<class RM_UNUSED_FUNCTION_WARNING = void>
std::ostream* bc::get_print_stream ( )
inline

◆ im2col()

template<class Stream , class ColumnImage , class Image >
void bc::im2col ( Stream  stream,
ColumnImage  col_image,
Image  image,
bc::Dim< 3 >  krnl_shape,
bc::Dim< 2 >  padding = bc::Dim<2>().fill(0),
bc::Dim< 2 >  strides = bc::Dim<2>().fill(1),
bc::Dim< 2 >  dilation = bc::Dim<2>().fill(1),
int  numb_spatial_axis = 2 
)

◆ max_pooling_backward()

template<class Stream , class Indexes , class Image , class ImageOut >
void bc::max_pooling_backward ( Stream  stream,
Image  image,
ImageOut  delta,
Indexes  mask,
Dim< 2 >  krnl_shape,
Dim< 2 >  padding = Dim<2>().fill(0 ),
Dim< 2 >  strides = Dim<2>().fill(-1) 
)

◆ max_pooling_forward()

template<class Stream , class Indexes , class Image , class ImageOut >
void bc::max_pooling_forward ( Stream  stream,
Image  image,
ImageOut  out,
Indexes  mask,
Dim< 2 >  krnl_shape,
Dim< 2 >  padding = Dim<2>().fill(0),
Dim< 2 >  strides = {-1,-1} 
)

◆ print()

template<class... Ts>
void bc::print ( const Ts &...  args)

◆ printerr()

template<class... Ts>
void bc::printerr ( const Ts &...  args)

◆ set_error_stream()

template<class RM_UNUSED_FUNCTION_WARNING = void>
void bc::set_error_stream ( std::ostream *  ostream)
inline

◆ set_print_stream()

template<class RM_UNUSED_FUNCTION_WARNING = void>
void bc::set_print_stream ( std::ostream *  ostream)
inline

◆ shape() [1/2]

template<class... Integers, typename = std::enable_if_t< traits::sequence_of_v<size_t, Integers...>>>
BCINLINE auto bc::shape ( Integers...  ints)

◆ shape() [2/2]

template<class InnerShape , typename = std::enable_if_t<! traits::sequence_of_v<size_t, InnerShape>>>
BCINLINE auto bc::shape ( InnerShape  is)