Changeset ecb9f64


Ignore:
Timestamp:
Dec 29, 2021, 5:52:02 PM (2 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/crepe
Children:
8e1e753
Parents:
7f915f7
git-author:
Paul Brossier <piem@piem.org> (01/29/19 03:04:06)
git-committer:
Paul Brossier <piem@piem.org> (12/29/21 17:52:02)
Message:

[conv2d] add basic documentation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ai/conv2d.h

    r7f915f7 recb9f64  
    2222#define AUBIO_CONV2D_H
    2323
     24/** \file
     25
     26  Convolutional layer (2D)
     27
     28  Standard implementation of a 2D convolutional layer. partly optimized for
     29  CPU.
     30
     31  Note
     32  ----
     33  Only the forward pass is implemented for now.
     34
     35  References
     36  ----------
     37  Vincent Dumoulin, Francesco Visin - [A guide to convolution arithmetic for
     38  deep learning](https://github.com/vdumoulin/conv_arithmetic)
     39
     40*/
     41
    2442#ifdef __cplusplus
    2543extern "C" {
    2644#endif
    2745
     46/** conv2d layer */
    2847typedef struct _aubio_conv2d_t aubio_conv2d_t;
    2948
    30 /** create a new conv2d layer */
    31 aubio_conv2d_t *new_aubio_conv2d(uint_t filters, uint_t *kernel_shape);
     49/** create a new conv2d layer
    3250
    33 /** perform forward 2D convolution */
    34 void aubio_conv2d_do(aubio_conv2d_t *t, aubio_tensor_t *input_tensor,
    35         aubio_tensor_t *activations);
     51  \param n_filters number of filters
     52  \param kernel_shape shape of each filter
    3653
    37 /** TODO: implement */
    38 void aubio_conv2d_train(aubio_conv2d_t *t, aubio_tensor_t *input_tensor);
     54  \return new conv2d layer
    3955
    40 /** set internal kernel weights */
    41 uint_t aubio_conv2d_set_kernel(aubio_conv2d_t *t, aubio_tensor_t *kernel);
     56*/
     57aubio_conv2d_t *new_aubio_conv2d(uint_t n_filters, uint_t kernel_shape[2]);
    4258
    43 /** get conv2d weights */
    44 aubio_tensor_t *aubio_conv2d_get_kernel(aubio_conv2d_t *t);
     59/** set padding mode
    4560
    46 /** set internal biases */
    47 uint_t aubio_conv2d_set_bias(aubio_conv2d_t *t, fvec_t *bias);
     61  \param c                  layer
     62  \param padding_mode       padding mode
    4863
    49 /** get conv2d biases */
    50 fvec_t *aubio_conv2d_get_bias(aubio_conv2d_t *t);
     64  \return 0 on success, non-zero otherwise
    5165
    52 /** set conv2d stride */
    53 uint_t aubio_conv2d_set_stride(aubio_conv2d_t *c,
    54     uint_t stride[2]);
     66  Available padding: "same", and "valid".
    5567
    56 uint_t *aubio_conv2d_get_stride(aubio_conv2d_t* t);
    57 
     68*/
    5869uint_t aubio_conv2d_set_padding_mode(aubio_conv2d_t *c,
    5970    const char_t *padding_mode);
    6071
     72/** set stride
     73
     74  \param c      layer
     75  \param stride array of length 2 containing the strides
     76
     77  \return 0 on success, non-zero otherwise
     78
     79*/
     80uint_t aubio_conv2d_set_stride(aubio_conv2d_t *c, uint_t stride[2]);
     81
     82/** get current stride settings
     83
     84  \param t  layer
     85
     86  \return   array of length 2 containing the stride in each dimension
     87
     88*/
     89uint_t *aubio_conv2d_get_stride(aubio_conv2d_t* t);
     90
     91/** get output shape
     92
     93  \param t                  layer
     94  \param input_tensor       input tensor
     95  \param shape              output shape
     96
     97  \return 0 on success, non-zero otherwise
     98
     99  Upon return, `shape` will be filled with the output shape of the layer. This
     100  function should be called after ::aubio_conv2d_set_stride or
     101  ::aubio_conv2d_set_padding_mode, and before ::aubio_conv2d_get_kernel or
     102  ::aubio_conv2d_get_bias.
     103
     104*/
    61105uint_t aubio_conv2d_get_output_shape(aubio_conv2d_t *t,
    62106        aubio_tensor_t *input_tensor, uint_t *shape);
    63107
     108/** get kernel weights
     109
     110  \param t  ::aubio_conv2d_t layer
     111
     112  \return tensor of weights
     113
     114  When called after ::aubio_conv2d_get_output_shape, this function will return
     115  a pointer to the tensor holding the weights of this layer.
     116
     117*/
     118aubio_tensor_t *aubio_conv2d_get_kernel(aubio_conv2d_t *t);
     119
     120/** get biases
     121
     122  \param t layer
     123
     124  \return vector of biases
     125
     126  When called after ::aubio_conv2d_get_output_shape, this function will return
     127  a pointer to the vector holding the biases.
     128
     129*/
     130fvec_t *aubio_conv2d_get_bias(aubio_conv2d_t *t);
     131
     132/** set kernel weights
     133
     134  \param t          layer
     135  \param kernel     kernel weights
     136
     137  \return 0 on success, non-zero otherwise
     138
     139  Copy kernel weights into internal layer memory.  This function should be
     140  called after ::aubio_conv2d_get_output_shape.
     141
     142*/
     143uint_t aubio_conv2d_set_kernel(aubio_conv2d_t *t, aubio_tensor_t *kernel);
     144
     145/** set biases
     146
     147  \param t          layer
     148  \param bias       biases
     149
     150  \return 0 on success, non-zero otherwise
     151
     152  Copy vector of biases into internal layer memory. This function should be
     153  called after ::aubio_conv2d_get_output_shape.
     154
     155*/
     156uint_t aubio_conv2d_set_bias(aubio_conv2d_t *t, fvec_t *bias);
     157
     158/** compute layer output
     159
     160  \param t              layer
     161  \param input_tensor   input tensor
     162  \param output_tensor  output tensor
     163
     164  Perform 2D convolution.
     165
     166*/
     167void aubio_conv2d_do(aubio_conv2d_t *t, aubio_tensor_t *input_tensor,
     168        aubio_tensor_t *output_tensor);
     169
     170/** destroy conv2d layer
     171
     172  \param t  layer
     173
     174*/
    64175void del_aubio_conv2d(aubio_conv2d_t *t);
    65176
Note: See TracChangeset for help on using the changeset viewer.