lgarithm / crystalnet

crystalnet -- a mini core AI library (being refactored, see https://github.com/lgarithm/stdnn-ops)
MIT License
16 stars 3 forks source link

[RFC] 004 operators #23

Open lgarithm opened 6 years ago

lgarithm commented 6 years ago

draft

Draft definitions

A symbolic operator is a generic operator that has a fixed arity. A specialized operator is a tensor function which has a fixed signature. A operator function is a function that takes some configuration parameters and returns a specialized operator.

types of operators

Example of operators

add

add is a 2-arity operator. add has signature < r, r, r >. add : T_p, T_p \to T_p where p is a shape

mul

mul is a 2-arity operator. mul has signature < r + s, s + t, r + t >. mul : T(p, q), T(q, r) \to T_(p, r) where p, q, r can be any shapes. When rank p = rank q = rank r = 1, mul reduces to the matrix times matrix operator, in general cases, mul is known as tensor contraction.

conv

conv is a 2-ariry operator, and can take several shapes as configuration parameters, including padding, stride, sample rate, etc.

pool

pool is a 1-arity operator. pool can take kernal/patch size, stride as configuration parameters, and can take a trait/policy function, which is default to max, and can be mean.

lgarithm commented 6 years ago

draft

The pooling operator

The generic pooling operator with filter shape [r, s] and stride shape [stride_r, stride_s] (TODO: add padding shape) has the following signature:

<3, 3> or <4, 4>

pool : [n, h, w, c] -> [n, h', w', c]

where n is the batch size, c is the channel size h' = (h - r) / stride_r + 1 w' = (w - s) / stride_s + 1

lgarithm commented 6 years ago

draft

Pointwise operators

Pointwise operators are generic unary operators that has generic signature <r, r>

common pointwise operators are

lgarithm commented 6 years ago

Other topics: