summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'debian/ti-timl/usr/src/timl/src/common/cnn/timlCNNInitialize.c')
-rw-r--r--debian/ti-timl/usr/src/timl/src/common/cnn/timlCNNInitialize.c115
1 files changed, 115 insertions, 0 deletions
diff --git a/debian/ti-timl/usr/src/timl/src/common/cnn/timlCNNInitialize.c b/debian/ti-timl/usr/src/timl/src/common/cnn/timlCNNInitialize.c
new file mode 100644
index 0000000..25bb79d
--- /dev/null
+++ b/debian/ti-timl/usr/src/timl/src/common/cnn/timlCNNInitialize.c
@@ -0,0 +1,115 @@
1/******************************************************************************/
2/*!
3 * \file timlCNNInitialize.c
4 */
5/* Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 *
14 * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the
17 * distribution.
18 *
19 * Neither the name of Texas Instruments Incorporated nor the names of
20 * its contributors may be used to endorse or promote products derived
21 * from this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 *
35 ******************************************************************************/
36
37
38/*******************************************************************************
39 *
40 * INCLUDES
41 *
42 ******************************************************************************/
43
44#include "../api/timl.h"
45
46
47/******************************************************************************/
48/*!
49 * \ingroup cnn
50 * \brief Allocate the memory required by the cnn
51 * \param[in] cnn CNN
52 * \return Error code
53 */
54/******************************************************************************/
55
56int timlCNNInitialize(timlConvNeuralNetwork *cnn)
57{
58 int err;
59 timlCNNLayer *layer = cnn->head;
60
61 if (cnn->params.allocatorLevel == Util_AllocatorLevel3) {
62 cnn->memPoolSize = timlCNNMemPoolSize(cnn);
63 if (timlUtilMalloc((void**)&cnn->memPool, sizeof(float) * cnn->memPoolSize)) {
64 return ERROR_CNN_LAYER_ALLOCATION;
65 }
66 }
67 while (layer != NULL) {
68 switch (layer->type) {
69 case CNN_Input:
70 err = timlCNNInputInitialize(layer);
71 if (err) {
72 return ERROR_CNN_LAYER_ALLOCATION;
73 }
74 break;
75 case CNN_Conv:
76 err = timlCNNConvInitialize(layer);
77 if (err) {
78 return ERROR_CNN_LAYER_ALLOCATION;
79 }
80 break;
81 case CNN_Nonlinear:
82 err = timlCNNNonlinearInitialize(layer);
83 if (err) {
84 return ERROR_CNN_LAYER_ALLOCATION;
85 }
86 break;
87 case CNN_Linear:
88 err = timlCNNLinearInitialize(layer);
89 if (err) {
90 return ERROR_CNN_LAYER_ALLOCATION;
91 }
92 break;
93 case CNN_Pooling:
94 err = timlCNNPoolingInitialize(layer);
95 if (err) {
96 return ERROR_CNN_LAYER_ALLOCATION;
97 }
98 break;
99 case CNN_Norm:
100 err = timlCNNNormInitialize(layer);
101 if (err) {
102 return ERROR_CNN_LAYER_ALLOCATION;
103 }
104 break;
105 case CNN_Dropout:
106 err = timlCNNDropoutInitialize(layer);
107 if (err) {
108 return ERROR_CNN_LAYER_ALLOCATION;
109 }
110 break;
111 }
112 layer = layer->next;
113 }
114 return 0;
115}