• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2016, Alliance for Open Media. All rights reserved
3  *
4  * This source code is subject to the terms of the BSD 2 Clause License and
5  * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6  * was not distributed with this source code in the LICENSE file, you can
7  * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8  * Media Patent License 1.0 was not distributed with this source code in the
9  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10  */
11 
12 #ifndef AOM_AV1_ENCODER_ML_H_
13 #define AOM_AV1_ENCODER_ML_H_
14 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
19 #include "config/av1_rtcd.h"
20 
21 #define NN_MAX_HIDDEN_LAYERS 10
22 #define NN_MAX_NODES_PER_LAYER 128
23 
24 struct NN_CONFIG {
25   int num_inputs;         // Number of input nodes, i.e. features.
26   int num_outputs;        // Number of output nodes.
27   int num_hidden_layers;  // Number of hidden layers, maximum 10.
28   // Number of nodes for each hidden layer.
29   int num_hidden_nodes[NN_MAX_HIDDEN_LAYERS];
30   // Weight parameters, indexed by layer.
31   const float *weights[NN_MAX_HIDDEN_LAYERS + 1];
32   // Bias parameters, indexed by layer.
33   const float *bias[NN_MAX_HIDDEN_LAYERS + 1];
34 };
35 // Typedef from struct NN_CONFIG to NN_CONFIG is in rtcd_defs
36 
37 // Applies the softmax normalization function to the input
38 // to get a valid probability distribution in the output:
39 // output[i] = exp(input[i]) / sum_{k \in [0,n)}(exp(input[k]))
40 void av1_nn_softmax(const float *input, float *output, int n);
41 
42 #ifdef __cplusplus
43 }  // extern "C"
44 #endif
45 
46 #endif  // AOM_AV1_ENCODER_ML_H_
47