grain.functions.binary

A module for binary autograd functions.

TODO: - support add tensor with cudnnAddTensor and mir.ndslice - support opBinary(add, mul, min, max) cudnnOpTensor - convolution - batchnorm

Members

Functions

dim2lin
int dim2lin(int[length] ids, int[] strides)
Undocumented in source. Be warned that the author may not have intended to support it.
doEpilog
void doEpilog(float[] o, int idx, float alphaAcc, float beta)
Undocumented in source. Be warned that the author may not have intended to support it.
generateStrides
void generateStrides(int* dimA, int* strideA, int nbDims, bool isNchw)
Undocumented in source. Be warned that the author may not have intended to support it.
lin2dim
void lin2dim(int id, int[length] ids, int[length] dims)

Convert a linear index i = d_1 s_1 ... s_n + d_2 s_2 ... s_n + d_n-1 s_n + d_n into a multidimensional index (d_1, d_2, ..., d_n)

Structs

AddBias
struct AddBias(T)

Add bias vector to matrix used inside grain.chain.Linear TODO: generalize to broadcastable addition (use cudnnAddTensor)

Convolution
struct Convolution(T, size_t imDims, bool isConv = false, bool isNchw = true)

Convolution/Cross-correration function

ConvolutionRefImpl
struct ConvolutionRefImpl(T, size_t imDims, bool isConv = false, bool isNchw = true)

Reference CPU implementation of Convolution function

Embedding
struct Embedding(T)

Emebedding ID into vector. TODO: support N-dim input. support sparse weight matrix

MatMul
struct MatMul(T)

Matrix-Matrix multiplication (using cuBLAS)

OpBinary
struct OpBinary(T, size_t dim, string ops)

c = op(alpha1 * a + alpha2 * b) + beta * c;

Meta