summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9450413)
raw | patch | inline | side by side (parent: 9450413)
author | Chenchi Luo <a0282871@ti.com> | |
Tue, 26 May 2015 14:25:45 +0000 (09:25 -0500) | ||
committer | Chenchi Luo <a0282871@ti.com> | |
Tue, 26 May 2015 14:25:45 +0000 (09:25 -0500) |
35 files changed:
diff --git a/src/app/cnn/.testignore b/src/app/cnn/.testignore
diff --git a/src/app/cnn/class/.testignore b/src/app/cnn/class/.testignore
diff --git a/src/app/cnn/class/cifar10/.Testing.testcfg b/src/app/cnn/class/cifar10/.Testing.testcfg
+++ /dev/null
@@ -1 +0,0 @@
-EXE=appCNNClassCIFAR10Testing.bin
diff --git a/src/app/cnn/class/imagenet/.testignore b/src/app/cnn/class/imagenet/.testignore
diff --git a/src/app/cnn/class/mnist/.testignore b/src/app/cnn/class/mnist/.testignore
diff --git a/src/app/cnn/convert/.testignore b/src/app/cnn/convert/.testignore
diff --git a/src/app/cnn/convert/imagenet/.testignore b/src/app/cnn/convert/imagenet/.testignore
diff --git a/src/app/cnn/convert/sbd/.testignore b/src/app/cnn/convert/sbd/.testignore
diff --git a/src/app/cnn/interop/.testignore b/src/app/cnn/interop/.testignore
diff --git a/src/app/cnn/interop/caffe/.testignore b/src/app/cnn/interop/caffe/.testignore
diff --git a/src/app/cnn/scene/.testignore b/src/app/cnn/scene/.testignore
diff --git a/src/app/cnn/scene/appCNNSceneLabelMatrix.c b/src/app/cnn/scene/appCNNSceneLabelMatrix.c
+++ /dev/null
@@ -1,99 +0,0 @@
-/******************************************************************************/
-/*!
- * \file appCNNSceneLabelMatrix.c
- */
-/* Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the
- * distribution.
- *
- * Neither the name of Texas Instruments Incorporated nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- ******************************************************************************/
-
-
-/*******************************************************************************
- *
- * INCLUDES
- *
- ******************************************************************************/
-
-#include "appCNNScene.h"
-#ifdef TIML_ALT
-#include "../../alt/timlAlt.h"
-#include "../../altApp/sl/appSLAlt.h"
-#endif
-
-
-/******************************************************************************/
-/*!
- * \ingroup appCNNScene
- * \brief Fill the label matrix
- * \param[in] map Feature map output of a CNN
- * \param[in] row Image row
- * \param[in] col Image col
- * \param[in] channel Image channel
- * \param[in] m Row Index
- * \param[in] k Col Index
- * \param[out] labelMatrix Label matrix
- * \param[in] numRow Num of rows
- * \param[in] numCol Num of cols
- * \return Error code
- */
-/******************************************************************************/
-
-int appCNNSceneLabelMatrix(float *map, int row, int col, int channel, int m, int k, int *labelMatrix, int numRow, int numCol)
-{
-#ifdef TIML_CPU
- int i;
- int j;
- int p;
- float max;
- int resolutionLossRow;
- int resolutionLossCol;
- int err;
-
- err = 0;
- resolutionLossRow = numRow/row;
- resolutionLossCol = numCol/col;
-
- for (i = 0; i < row; i++) {
- for (j = 0; j < col; j++) {
- max = -FLT_MAX;
- for (p = 0; p < channel; p++) {
- if (map[j + i*col + p*row*col] >= max) {
- labelMatrix[k + resolutionLossCol/2 + j*resolutionLossCol + (m + resolutionLossRow/2 + i*resolutionLossRow)*numCol] = p;
- max = map[j + i*col + p*row*col];
- }
- }
- }
- }
- return err;
-
-#elif defined TIML_ALT
- return appSLLabelMatrixAlt(map, row, col, channel, m, k, labelMatrix, numRow, numCol);
-#endif
-}
diff --git a/src/app/cnn/scene/sbd/.testignore b/src/app/cnn/scene/sbd/.testignore
diff --git a/src/common/cnn/timlCNNAssignDevice.c b/src/common/cnn/timlCNNAssignDevice.c
+++ /dev/null
@@ -1,68 +0,0 @@
-/******************************************************************************/
-/*!
- * \file timlCNNAssignDevice.c
- */
-/* Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the
- * distribution.
- *
- * Neither the name of Texas Instruments Incorporated nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- ******************************************************************************/
-
-
-/*******************************************************************************
- *
- * INCLUDES
- *
- ******************************************************************************/
-
-#include "../api/timl.h"
-
-
-/*******************************************************************************/
-/*!
- * \ingroup cnn
- * \brief Assign the cnn to a specific device and thread.
- * \param[in] cnn CNN
- * \param[in] deviceId Device Id starting from 0;
- * \param[in] threadId Thread Id starting from 0;
- * \return Error code
- */
-/*******************************************************************************/
-
-int timlCNNAssignDevice(timlConvNeuralNetwork *cnn, int deviceId, int threadId)
-{
-#ifdef TIML_CPU
- cnn->deviceId = deviceId;
- cnn->threadId = threadId;
- return 0;
-#elif defined TIML_ALT
- return timlUtilAssignDeviceAlt(cnn, deviceId, threadId);
-#endif
-}
-
diff --git a/src/common/cnn/timlCNNClassifyTop1SingleMode.c b/src/common/cnn/timlCNNClassifyTop1SingleMode.c
+++ /dev/null
@@ -1,71 +0,0 @@
-/******************************************************************************/\r
-/*!\r
- * \file timlCNNClassifyTop1SingleMode.c\r
- */\r
-/* Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/\r
- *\r
- * Redistribution and use in source and binary forms, with or without\r
- * modification, are permitted provided that the following conditions\r
- * are met:\r
- *\r
- * Redistributions of source code must retain the above copyright\r
- * notice, this list of conditions and the following disclaimer.\r
- *\r
- * Redistributions in binary form must reproduce the above copyright\r
- * notice, this list of conditions and the following disclaimer in the\r
- * documentation and/or other materials provided with the\r
- * distribution.\r
- *\r
- * Neither the name of Texas Instruments Incorporated nor the names of\r
- * its contributors may be used to endorse or promote products derived\r
- * from this software without specific prior written permission.\r
- *\r
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
- *\r
- ******************************************************************************/\r
-\r
-\r
-/*******************************************************************************\r
- *\r
- * INCLUDES\r
- *\r
- ******************************************************************************/\r
-\r
-#include "../api/timl.h"\r
-\r
-\r
-/******************************************************************************/\r
-/*!\r
- * \ingroup cnn\r
- * \brief Classify the data\r
- * \param[in,out] cnn CNN\r
- * \param[in] data Data\r
- * \param[in] dim Dimension of the data\r
- * \return Label\r
- */\r
-/******************************************************************************/\r
-\r
-int timlCNNClassifyTop1SingleMode(timlConvNeuralNetwork *cnn, float *data, int dim)\r
-{\r
-\r
- int err = 0;\r
- timlCNNLayer *layer = cnn->tail;\r
- int range = layer->channel*layer->row*layer->col;\r
- err = timlCNNForwardPropagation(cnn, data, dim);\r
- if (err) return err;\r
- if (cnn->tail->nonlinearParams.type == Util_Softmax) {\r
- return timlUtilVectorMaxIndexFloat(layer->featureMap, range, 1);\r
- }\r
-\r
- return ERROR_CNN_CLASS;\r
-}\r
diff --git a/src/common/cnn/timlCNNClassifyTopNBatchMode.c b/src/common/cnn/timlCNNClassifyTopNBatchMode.c
+++ /dev/null
@@ -1,91 +0,0 @@
-/*****************************************************************************/
-/*!
- * \file timlCNNClassifyTopNBatchMode.c
- */
-/* Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the
- * distribution.
- *
- * Neither the name of Texas Instruments Incorporated nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- ******************************************************************************/
-
-
-/*******************************************************************************
- *
- * INCLUDES
- *
- ******************************************************************************/
-
-#include "../api/timl.h"
-
-
-/******************************************************************************/
-/*!
- * \ingroup cnn
- * \brief Batch classification
- * \param[in,out] cnn CNN
- * \param[in] data Data batch
- * \param[in] dim Data dimension
- * \param[in] num Data number
- * \param[out] label Label array ptr, size = num*topN
- * \param[out] percent Percent array ptr, size = num*topN
- * \param[out] topN Output the top N labels and the corresponding percentage
- * \return Error code
- */
-/******************************************************************************/
-
-int timlCNNClassifyTopNBatchMode(timlConvNeuralNetwork *cnn, float *data, int dim, int num, int *label, float *percent, int topN)
-{
- int i;
- int j;
- int t;
- int k;
- int outputDim;
- int *index;
- int err;
-
- err = 0;
- outputDim = cnn->tail->row*cnn->tail->col*cnn->tail->channel;
- index = malloc(sizeof(int)*outputDim); // multiple copies for each thread
-
- for (j = 0; j < num; j++) {
- err = timlCNNForwardPropagation(cnn, data + j*dim, dim); // fp
- if (err) return err;
- err = timlUtilVectorSortIndexFloat(cnn->tail->featureMap, index, outputDim); // sort
- if (err) return err;
- for (i = 0; i < topN; i++) {
- label[j*topN + i] = index[outputDim - i - 1]; // record label
- if (percent != NULL) {
- timlUtilBLASscopy(1, cnn->tail->featureMap + index[outputDim - i - 1], percent + j*topN + i, cnn->deviceId, cnn->threadId);
- }
- }
- }
- free(index);
-
- return err;
-}
diff --git a/src/common/cnn/timlCNNClassifyTopNBatchModeOpenMP.c b/src/common/cnn/timlCNNClassifyTopNBatchModeOpenMP.c
+++ /dev/null
@@ -1,122 +0,0 @@
-/******************************************************************************/
-/*!
- * \file timlCNNClassifyTopNBatchModeOpenMP.c
- */
-/* Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the
- * distribution.
- *
- * Neither the name of Texas Instruments Incorporated nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- ******************************************************************************/
-
-
-/*******************************************************************************
- *
- * INCLUDES
- *
- ******************************************************************************/
-
-#include "../api/timl.h"
-
-
-/******************************************************************************/
-/*!
- * \ingroup cnn
- * \brief Batch classification using openmp
- * \param[in,out] cnn CNN
- * \param[in] data Data batch
- * \param[in] dim Data dimension
- * \param[in] num Data number
- * \param[out] label Label array ptr, size = num*topN
- * \param[out] percent Percent array ptr, size = num*topN
- * \param[out] topN Output the top N labels and the corresponding percentage
- * \return Error code
- */
-/******************************************************************************/
-
-int timlCNNClassifyTopNBatchModeOpenMP(timlConvNeuralNetwork *cnn, float *data, int dim, int num, int *label, float *percent, int topN)
-{
- int err;
- int i;
- int j;
- int t;
- int k;
- int thread;
- struct timespec startTime;
- struct timespec endTime;
- long testingTime;
- int outputDim;
- int *index;
- timlConvNeuralNetwork **cnnTeam;
-
- // init
- err = 0;
- thread = omp_get_max_threads();
- outputDim = cnn->tail->row*cnn->tail->col*cnn->tail->channel;
- index = malloc(sizeof(int)*outputDim*thread); // multiple copies for each thread
- cnnTeam = malloc(sizeof(timlConvNeuralNetwork*)*thread);
-
- // create cnnTeam
- cnnTeam[0] = cnn;
- for (i = 1; i < thread; i++) {
- cnnTeam[i] = timlCNNShareParams(cnn, 0);
- if (cnnTeam[i] == NULL) {
- return ERROR_CNN_TEAM_ALLOCATION;
- }
- }
-
- // batch iterations
- clock_gettime(CLOCK_REALTIME, &startTime);
- #pragma omp parallel num_threads(thread) private(i, j, t)
- {
- #pragma omp for
- for (j = 0; j < num; j++) {
- t = omp_get_thread_num();
- timlCNNForwardPropagation(cnnTeam[t], data + j*dim, dim); // fp
- timlUtilVectorSortIndexFloat(cnnTeam[t]->tail->featureMap, index + t*outputDim, outputDim); // sort
- for (i = 0; i < topN; i++) {
- label[j*topN + i] = index[t*outputDim + outputDim - i - 1]; // record label
- if (percent != NULL) {
- timlUtilBLASscopy(1, cnnTeam[t]->tail->featureMap + index[t*outputDim + outputDim - i - 1], percent + j*topN + i, cnnTeam[t]->deviceId, cnnTeam[t]->threadId);
- }
- }
- }
- }
- clock_gettime(CLOCK_REALTIME, &endTime);
- testingTime = timlUtilDiffTime(startTime, endTime);
-// printf("Loop testing time = %.2fs.\n", testingTime/1000000.0);
-
- // clean up
- for (i = 1; i < thread; i++) {
- timlCNNDelete(cnnTeam[i]);
- }
- free(cnnTeam);
- free(index);
-
- return err;
-}
diff --git a/src/common/cnn/timlCNNClassifyTopNTeamModeOpenMP.c b/src/common/cnn/timlCNNClassifyTopNTeamModeOpenMP.c
+++ /dev/null
@@ -1,93 +0,0 @@
-/******************************************************************************/
-/*!
- * \file timlCNNClassifyTopNTeamModeOpenMP.c
- */
-/* Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the
- * distribution.
- *
- * Neither the name of Texas Instruments Incorporated nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- ******************************************************************************/
-
-
-/*******************************************************************************
- *
- * INCLUDES
- *
- ******************************************************************************/
-
-#include "../api/timl.h"
-
-
-/******************************************************************************/
-/*!
- * \ingroup cnn
- * \brief Batch classification using openmp
- * \details This is the same function as timlCNNBatchClassifyOpenMP but avoids creating and deleting the cnn team each time the function is called
- * \param[in,out] cnnTeam An array of CNNs that shares the same parameters
- * \param[in] num Size of the CNN array as well as the data
- * \param[in] data Data batch
- * \param[in] dim Data dimension
- * \param[in,out] label Label array ptr, size = num*topN
- * \param[in,out] percent Percent array ptr, size = num*topN
- * \param[in,out] topN Output the top N labels and the corresponding percentage
- * \return Error code
- */
-/******************************************************************************/
-
-int timlCNNClassifyTopNTeamModeOpenMP(timlConvNeuralNetwork **cnnTeam, int num, float *data, int dim, int *label, float *percent, int topN)
-{
- int err;
- int i;
- int j;
- int outputDim;
- int *index;
- int t;
-
- outputDim = cnnTeam[0]->tail->row*cnnTeam[0]->tail->col*cnnTeam[0]->tail->channel;
- index = malloc(sizeof(int)*outputDim*num); // multiple copies for each thread
-
- #pragma omp parallel num_threads(num) private(i, j, t)
- {
- #pragma omp for
- for (j = 0; j < num; j++) {
- t = omp_get_thread_num();
- timlCNNForwardPropagation(cnnTeam[t], data + j*dim, dim); // fp
- timlUtilVectorSortIndexFloat(cnnTeam[t]->tail->featureMap, index + t*outputDim, outputDim); // sort
- for (i = 0; i < topN; i++) {
- label[j*topN + i] = index[t*outputDim + outputDim - i - 1]; // record label
- if (percent != NULL) {
- percent[j*topN + i] = cnnTeam[t]->tail->featureMap[index[t*outputDim + outputDim - i - 1]]; // record percent
- }
- }
- }
- }
- free(index);
-
- return err;
-}
diff --git a/src/common/cnn/timlCNNConvReadFromBinaryFile.c b/src/common/cnn/timlCNNConvReadFromBinaryFile.c
+++ /dev/null
@@ -1,78 +0,0 @@
-/******************************************************************************/
-/*!
- * \file timlCNNConvReadFromBinaryFile.c
- */
-/* Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the
- * distribution.
- *
- * Neither the name of Texas Instruments Incorporated nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- ******************************************************************************/
-
-
-/*******************************************************************************
- *
- * INCLUDES
- *
- ******************************************************************************/
-
-#include "../api/timl.h"
-
-
-/******************************************************************************/
-/*!
- * \ingroup cnn
- * \brief Read the conv layer parameters from binary files
- * \param[in] fp2 FILE ptr to the level 2 parameter bin file
- * \param[in] fp3 FILE ptr to the level 3 state bin file
- * \param[in,out] layer Conv layer
- * \return Error code
- */
-/******************************************************************************/
-
-int timlCNNConvReadFromBinaryFile(FILE *fp2, FILE *fp3, timlCNNLayer *layer)
-{
- int dim;
- // read params
- if (fp2 != NULL) {
- dim = layer->convParams.kernelRow*layer->convParams.kernelCol*layer->convParams.inputFeatureMapChannel*layer->convParams.outputFeatureMapChannel;
- timlUtilFread(layer->convParams.kernel, sizeof(float), dim, fp2);
- timlUtilFread(layer->convParams.bias, sizeof(float), layer->channel, fp2);
- }
-
- // read state
- if (layer->allocatorLevel == Util_AllocatorLevel1 && fp3 != NULL) {
- dim = layer->convParams.kernelRow*layer->convParams.kernelCol*layer->convParams.inputFeatureMapChannel*layer->convParams.outputFeatureMapChannel;
- timlUtilFread(layer->convParams.kernelInc, sizeof(float), dim, fp3);
- timlUtilFread(layer->convParams.kernelGradAccum, sizeof(float), dim, fp3);
- timlUtilFread(layer->convParams.biasInc, sizeof(float), layer->channel, fp3);
- timlUtilFread(layer->convParams.biasGradAccum, sizeof(float), layer->channel, fp3);
- }
-
- return 0;
-}
diff --git a/src/common/cnn/timlCNNCostWithLabel.c b/src/common/cnn/timlCNNCostWithLabel.c
+++ /dev/null
@@ -1,91 +0,0 @@
-/******************************************************************************/
-/*!
- * \file timlCNNCostWithLabel.c
- */
-/* Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the
- * distribution.
- *
- * Neither the name of Texas Instruments Incorporated nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- ******************************************************************************/
-
-
-/*******************************************************************************
- *
- * INCLUDES
- *
- ******************************************************************************/
-
-#include "../api/timl.h"
-
-
-/******************************************************************************/
-/*!
- * \ingroup cnn
- * \brief Calculate the cost based on the cnn output and the label
- * \param[in] cnn CNN
- * \param[in] label Label
- * \param[in,out] cost Cost
- * \param[in,out] bpStartLayer Back propagation start layer
- * \return Error code
- */
-/******************************************************************************/
-
-int timlCNNCostWithLabel(timlConvNeuralNetwork *cnn, int label, float *cost, timlCNNLayer **bpStartLayer)
-{
- int err;
- timlCNNLayer *layer;
- int dim;
- int deviceId;
- int threadId;
-
- // init
- err = 0;
- layer = cnn->tail;
- dim = layer->channel;
- deviceId = cnn->deviceId;
- threadId = cnn->threadId;
-
- switch (cnn->params.costType) {
- case Util_MSE:
- *cost = 0.5*timlUtilMeanSqaureError(layer->featureMap, label, dim);
- break;
- case Util_CrossEntropy:
- *cost = timlUtilMultinomialCrossEntropy(layer->featureMap, label, dim);
- if (layer->type == CNN_Nonlinear && (layer->nonlinearParams.type == Util_Softmax || layer->nonlinearParams.type == Util_Sigmoid)) {
- layer = layer->prev; // move ahead one layer
- *bpStartLayer = layer;
- }
- timlUtilBLASscopy(dim, layer->next->featureMap, layer->delta, deviceId, threadId);
- // delta + label -= 1.0
- timlUtilSubtract(layer->delta + label, 1.0, deviceId, threadId);
- break;
- }
-
- return err;
-}
diff --git a/src/common/cnn/timlCNNDeleteConvLayer.c b/src/common/cnn/timlCNNDeleteConvLayer.c
+++ /dev/null
@@ -1,107 +0,0 @@
-/******************************************************************************/\r
-/*!\r
- * \file timlCNNDeleteConvLayer.c\r
- */\r
-/* Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/\r
- *\r
- * Redistribution and use in source and binary forms, with or without\r
- * modification, are permitted provided that the following conditions\r
- * are met:\r
- *\r
- * Redistributions of source code must retain the above copyright\r
- * notice, this list of conditions and the following disclaimer.\r
- *\r
- * Redistributions in binary form must reproduce the above copyright\r
- * notice, this list of conditions and the following disclaimer in the\r
- * documentation and/or other materials provided with the\r
- * distribution.\r
- *\r
- * Neither the name of Texas Instruments Incorporated nor the names of\r
- * its contributors may be used to endorse or promote products derived\r
- * from this software without specific prior written permission.\r
- *\r
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
- *\r
- ******************************************************************************/\r
-\r
-\r
-/*******************************************************************************\r
- *\r
- * INCLUDES\r
- *\r
- ******************************************************************************/\r
-\r
-#include "../api/timl.h"\r
-\r
-\r
-/******************************************************************************/\r
-/*!\r
- * \ingroup cnn\r
- * \brief Delete conv layer\r
- * \param[in] layer Layer ptr\r
- * \return Error code\r
- */\r
-/******************************************************************************/\r
-\r
-int timlCNNDeleteConvLayer(timlCNNLayer *layer)\r
-{\r
- if (layer->allocatorLevel != Util_AllocatorLevel3) {\r
- if (layer->featureMap != NULL) {\r
- timlUtilFree(layer->featureMap);\r
- }\r
- }\r
-\r
- if (layer->convParams.biasMultiplier != NULL) {\r
- timlUtilFree(layer->convParams.biasMultiplier);\r
- }\r
-\r
- if (layer->delta != NULL) {\r
- timlUtilFree(layer->delta);\r
- }\r
-\r
- if (layer->convParams.prevFeatureMapReshape != NULL) {\r
- timlUtilFree(layer->convParams.prevFeatureMapReshape);\r
- }\r
-\r
- if (layer->convParams.shared == false) {\r
- if (layer->convParams.prevFeatureMapReshapeIndex != NULL) {\r
- timlUtilFree(layer->convParams.prevFeatureMapReshapeIndex);\r
- }\r
- if (layer->convParams.connectivity != NULL) {\r
- free(layer->convParams.connectivity);\r
- layer->convParams.connectivity = NULL;\r
- }\r
- if (layer->convParams.kernel != NULL) {\r
- timlUtilFree(layer->convParams.kernel);\r
- }\r
- if (layer->convParams.kernelInc != NULL) {\r
- timlUtilFree(layer->convParams.kernelInc);\r
- }\r
- if (layer->convParams.kernelGradAccum != NULL) {\r
- timlUtilFree(layer->convParams.kernelGradAccum);\r
- }\r
- if (layer->convParams.bias != NULL) {\r
- timlUtilFree(layer->convParams.bias);\r
- }\r
- if (layer->convParams.biasInc != NULL) {\r
- timlUtilFree(layer->convParams.biasInc);\r
- }\r
- if (layer->convParams.biasGradAccum != NULL) {\r
- timlUtilFree(layer->convParams.biasGradAccum);\r
- }\r
- }\r
- free(layer);\r
-\r
- return 0;\r
-\r
-}\r
diff --git a/src/common/cnn/timlCNNDeleteDropoutLayer.c b/src/common/cnn/timlCNNDeleteDropoutLayer.c
+++ /dev/null
@@ -1,78 +0,0 @@
-/******************************************************************************/
-/*!
- * \file timlCNNDeleteDropoutLayer.c
- */
-/* Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the
- * distribution.
- *
- * Neither the name of Texas Instruments Incorporated nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- ******************************************************************************/
-
-
-/*******************************************************************************
- *
- * INCLUDES
- *
- ******************************************************************************/
-
-#include "../api/timl.h"
-
-
-/******************************************************************************/
-/*!
- * \ingroup cnn
- * \brief Delete dropout layer
- * \param[in] layer Layer ptr
- * \return Error code
- */
-/******************************************************************************/
-
-int timlCNNDeleteDropoutLayer(timlCNNLayer *layer)
-{
- if (layer->allocatorLevel != Util_AllocatorLevel3) {
- if (layer->featureMap != NULL) {
- timlUtilFree(layer->featureMap);
- }
- }
-
- if (layer->delta != NULL) {
- timlUtilFree(layer->delta);
- }
-
- if (layer->dropoutParams.mask != NULL) {
- timlUtilFree(layer->dropoutParams.mask);
- }
-
- if (layer->dropoutParams.randomVector != NULL) {
- timlUtilFree(layer->dropoutParams.randomVector);
- }
- free(layer);
-
- return 0;
-}
diff --git a/src/common/cnn/timlCNNDeleteInputLayer.c b/src/common/cnn/timlCNNDeleteInputLayer.c
+++ /dev/null
@@ -1,77 +0,0 @@
-/******************************************************************************/\r
-/*!\r
- * \file timlCNNDeleteInputLayer.c\r
- */\r
-/* Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/\r
- *\r
- * Redistribution and use in source and binary forms, with or without\r
- * modification, are permitted provided that the following conditions\r
- * are met:\r
- *\r
- * Redistributions of source code must retain the above copyright\r
- * notice, this list of conditions and the following disclaimer.\r
- *\r
- * Redistributions in binary form must reproduce the above copyright\r
- * notice, this list of conditions and the following disclaimer in the\r
- * documentation and/or other materials provided with the\r
- * distribution.\r
- *\r
- * Neither the name of Texas Instruments Incorporated nor the names of\r
- * its contributors may be used to endorse or promote products derived\r
- * from this software without specific prior written permission.\r
- *\r
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
- *\r
- ******************************************************************************/\r
-\r
-\r
-/*******************************************************************************\r
- *\r
- * INCLUDES\r
- *\r
- ******************************************************************************/\r
-\r
-#include "../api/timl.h"\r
-\r
-\r
-/******************************************************************************/\r
-/*!\r
- * \ingroup cnn\r
- * \brief Delete input layer\r
- * \param[in] layer Layer ptr\r
- * \return Error code\r
- */\r
-/******************************************************************************/\r
-\r
-int timlCNNDeleteInputLayer(timlCNNLayer * layer)\r
-{\r
- if (layer->allocatorLevel != Util_AllocatorLevel3) {\r
- if (layer->featureMap != NULL) {\r
- timlUtilFree(layer->featureMap);\r
- }\r
- if (layer->inputParams.inputData != NULL) {\r
- timlUtilFree(layer->inputParams.inputData);\r
- }\r
- }\r
- if (layer->delta != NULL) {\r
- timlUtilFree(layer->delta);\r
- }\r
- if (layer->inputParams.shared == false) {\r
- if (layer->inputParams.mean != NULL) {\r
- timlUtilFree(layer->inputParams.mean);\r
- }\r
- }\r
- free(layer);\r
-\r
- return 0;\r
-}\r
diff --git a/src/common/cnn/timlCNNDeleteLinearLayer.c b/src/common/cnn/timlCNNDeleteLinearLayer.c
+++ /dev/null
@@ -1,91 +0,0 @@
-/******************************************************************************/
-/*!
- * \file timlCNNDeleteLinearLayer.c
- */
-/* Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the
- * distribution.
- *
- * Neither the name of Texas Instruments Incorporated nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- ******************************************************************************/
-
-
-/*******************************************************************************
- *
- * INCLUDES
- *
- ******************************************************************************/
-
-#include "../api/timl.h"
-
-
-/******************************************************************************/
-/*!
- * \ingroup cnn
- * \brief Delete linear layer
- * \param[in] layer Layer ptr
- * \return Error code
- */
-/******************************************************************************/
-
-int timlCNNDeleteLinearLayer(timlCNNLayer *layer)
-{
- if (layer->allocatorLevel != Util_AllocatorLevel3) {
- if (layer->featureMap != NULL) {
- timlUtilFree(layer->featureMap);
- }
- }
-
- if (layer->delta != NULL) {
- timlUtilFree(layer->delta);
- }
-
- if (layer->linearParams.shared == false) {
- if (layer->linearParams.weight != NULL) {
- timlUtilFree(layer->linearParams.weight);
- }
- if (layer->linearParams.weightInc != NULL) {
- timlUtilFree(layer->linearParams.weightInc);
- }
- if (layer->linearParams.weightGradAccum != NULL) {
- timlUtilFree(layer->linearParams.weightGradAccum);
- }
- if (layer->linearParams.bias != NULL) {
- timlUtilFree(layer->linearParams.bias);
- }
- if (layer->linearParams.biasInc != NULL) {
- timlUtilFree(layer->linearParams.biasInc);
- }
- if (layer->linearParams.biasGradAccum != NULL) {
- timlUtilFree(layer->linearParams.biasGradAccum);
- }
- }
- free(layer);
-
- return 0;
-}
diff --git a/src/common/cnn/timlCNNDeleteNonlinearLayer.c b/src/common/cnn/timlCNNDeleteNonlinearLayer.c
+++ /dev/null
@@ -1,73 +0,0 @@
-/******************************************************************************/\r
-/*!\r
- * \file timlCNNDeleteNonlinearLayer.c\r
- */\r
-/* Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/\r
- *\r
- * Redistribution and use in source and binary forms, with or without\r
- * modification, are permitted provided that the following conditions\r
- * are met:\r
- *\r
- * Redistributions of source code must retain the above copyright\r
- * notice, this list of conditions and the following disclaimer.\r
- *\r
- * Redistributions in binary form must reproduce the above copyright\r
- * notice, this list of conditions and the following disclaimer in the\r
- * documentation and/or other materials provided with the\r
- * distribution.\r
- *\r
- * Neither the name of Texas Instruments Incorporated nor the names of\r
- * its contributors may be used to endorse or promote products derived\r
- * from this software without specific prior written permission.\r
- *\r
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
- *\r
- ******************************************************************************/\r
-\r
-\r
-/*******************************************************************************\r
- *\r
- * INCLUDES\r
- *\r
- ******************************************************************************/\r
-\r
-#include "../api/timl.h"\r
-\r
-\r
-/******************************************************************************/\r
-/*!\r
- * \ingroup cnn\r
- * \brief Delete nonlinear layer\r
- * \param[in] layer Layer ptr\r
- * \return Error code\r
- */\r
-/******************************************************************************/\r
-\r
-int timlCNNDeleteNonlinearLayer(timlCNNLayer * layer)\r
-{\r
- if (layer->allocatorLevel != Util_AllocatorLevel3) {\r
- if (layer->featureMap != NULL) {\r
- timlUtilFree(layer->featureMap);\r
- }\r
- }\r
- if (layer->delta != NULL) {\r
- timlUtilFree(layer->delta);\r
- }\r
- if (layer->nonlinearParams.derivative != NULL) {\r
- timlUtilFree(layer->nonlinearParams.derivative);\r
- }\r
- free(layer);\r
-\r
- return 0;\r
-\r
-}\r
diff --git a/src/common/cnn/timlCNNDeleteNormLayer.c b/src/common/cnn/timlCNNDeleteNormLayer.c
+++ /dev/null
@@ -1,72 +0,0 @@
-/******************************************************************************/\r
-/*!\r
- * \file timlCNNDeleteNormLayer.c\r
- */\r
-/* Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/\r
- *\r
- * Redistribution and use in source and binary forms, with or without\r
- * modification, are permitted provided that the following conditions\r
- * are met:\r
- *\r
- * Redistributions of source code must retain the above copyright\r
- * notice, this list of conditions and the following disclaimer.\r
- *\r
- * Redistributions in binary form must reproduce the above copyright\r
- * notice, this list of conditions and the following disclaimer in the\r
- * documentation and/or other materials provided with the\r
- * distribution.\r
- *\r
- * Neither the name of Texas Instruments Incorporated nor the names of\r
- * its contributors may be used to endorse or promote products derived\r
- * from this software without specific prior written permission.\r
- *\r
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
- *\r
- ******************************************************************************/\r
-\r
-\r
-/*******************************************************************************\r
- *\r
- * INCLUDES\r
- *\r
- ******************************************************************************/\r
-\r
-#include "../api/timl.h"\r
-\r
-\r
-/******************************************************************************/\r
-/*!\r
- * \ingroup cnn\r
- * \brief Delete norm layer\r
- * \param[in] layer Layer ptr\r
- * \return Error code\r
- */\r
-/******************************************************************************/\r
-\r
-int timlCNNDeleteNormLayer(timlCNNLayer *layer)\r
-{\r
- if (layer->allocatorLevel != Util_AllocatorLevel3) {\r
- if (layer->featureMap != NULL) {\r
- timlUtilFree(layer->featureMap);\r
- }\r
- }\r
- if (layer->delta != NULL) {\r
- timlUtilFree(layer->delta);\r
- }\r
- if (layer->normParams.denom != NULL) {\r
- timlUtilFree(layer->normParams.denom);\r
- }\r
- free(layer);\r
-\r
- return 0;\r
-}\r
diff --git a/src/common/cnn/timlCNNDeletePoolingLayer.c b/src/common/cnn/timlCNNDeletePoolingLayer.c
+++ /dev/null
@@ -1,72 +0,0 @@
-/******************************************************************************/\r
-/*!\r
- * \file timlCNNDeletePoolingLayer.c\r
- */\r
-/* Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/\r
- *\r
- * Redistribution and use in source and binary forms, with or without\r
- * modification, are permitted provided that the following conditions\r
- * are met:\r
- *\r
- * Redistributions of source code must retain the above copyright\r
- * notice, this list of conditions and the following disclaimer.\r
- *\r
- * Redistributions in binary form must reproduce the above copyright\r
- * notice, this list of conditions and the following disclaimer in the\r
- * documentation and/or other materials provided with the\r
- * distribution.\r
- *\r
- * Neither the name of Texas Instruments Incorporated nor the names of\r
- * its contributors may be used to endorse or promote products derived\r
- * from this software without specific prior written permission.\r
- *\r
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
- *\r
- ******************************************************************************/\r
-\r
-\r
-/*******************************************************************************\r
- *\r
- * INCLUDES\r
- *\r
- ******************************************************************************/\r
-\r
-#include "../api/timl.h"\r
-\r
-\r
-/******************************************************************************/\r
-/*!\r
- * \ingroup cnn\r
- * \brief Delete pooling layer\r
- * \param[in] layer Layer ptr\r
- * \return Error code\r
- */\r
-/******************************************************************************/\r
-\r
-int timlCNNDeletePoolingLayer(timlCNNLayer *layer)\r
-{\r
- if (layer->allocatorLevel != Util_AllocatorLevel3) {\r
- if (layer->featureMap != NULL) {\r
- timlUtilFree(layer->featureMap);\r
- }\r
- }\r
- if (layer->delta != NULL) {\r
- timlUtilFree(layer->delta);\r
- }\r
- if (layer->poolingParams.maxIndex != NULL) {\r
- timlUtilFree(layer->poolingParams.maxIndex);\r
- }\r
- free(layer);\r
-\r
- return 0;\r
-}\r
diff --git a/src/common/cnn/timlCNNInputReadFromBinaryFile.c b/src/common/cnn/timlCNNInputReadFromBinaryFile.c
+++ /dev/null
@@ -1,65 +0,0 @@
-/******************************************************************************/
-/*!
- * \file timlCNNInputReadFromBinaryFile.c
- */
-/* Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the
- * distribution.
- *
- * Neither the name of Texas Instruments Incorporated nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- ******************************************************************************/
-
-
-/*******************************************************************************
- *
- * INCLUDES
- *
- ******************************************************************************/
-
-#include "../api/timl.h"
-
-
-/******************************************************************************/
-/*!
- * \ingroup cnn
- * \brief Read the input layer parameters from binary files
- * \param[in] fp2 FILE ptr to the level 2 parameter bin file
- * \param[in] fp3 FILE ptr to the level 3 state bin file
- * \param[in,out] layer Input layer
- * \return Error code
- */
-/******************************************************************************/
-
-int timlCNNInputReadFromBinaryFile(FILE *fp2, FILE *fp3, timlCNNLayer *layer)
-{
- // load params
- if (fp2 != NULL) {
- timlUtilFread(layer->inputParams.mean, sizeof(float), layer->inputParams.row * layer->inputParams.col * layer->inputParams.channel, fp2);
- }
- return 0;
-}
diff --git a/src/common/cnn/timlCNNLinearReadFromBinaryFile.c b/src/common/cnn/timlCNNLinearReadFromBinaryFile.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/******************************************************************************/
-/*!
- * \file timlCNNLinearReadFromBinaryFile.c
- */
-/* Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the
- * distribution.
- *
- * Neither the name of Texas Instruments Incorporated nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- ******************************************************************************/
-
-
-/*******************************************************************************
- *
- * INCLUDES
- *
- ******************************************************************************/
-
-#include "../api/timl.h"
-
-
-/******************************************************************************/
-/*!
- * \ingroup cnn
- * \brief Read the linear layer parameters from binary files
- * \param[in] fp2 FILE ptr to the level 2 parameter bin file
- * \param[in] fp3 FILE ptr to the level 3 state bin file
- * \param[in,out] layer Layer ptr
- * \return Error code
- */
-/******************************************************************************/
-
-int timlCNNLinearReadFromBinaryFile(FILE *fp2, FILE *fp3, timlCNNLayer *layer)
-{
- // copy params
- if (fp2 != NULL) {
- timlUtilFread(layer->linearParams.weight, sizeof(float), layer->linearParams.dim*layer->linearParams.prevDim, fp2);
- timlUtilFread(layer->linearParams.bias, sizeof(float), layer->linearParams.dim, fp2);
- }
-
- // copy state
- if (fp3 != NULL && layer->allocatorLevel == Util_AllocatorLevel1) {
- timlUtilFread(layer->linearParams.weightInc, sizeof(float), layer->linearParams.dim*layer->linearParams.prevDim, fp3);
- timlUtilFread(layer->linearParams.weightGradAccum, sizeof(float), layer->linearParams.dim*layer->linearParams.prevDim, fp3);
- timlUtilFread(layer->linearParams.biasInc, sizeof(float), layer->linearParams.dim, fp3);
- timlUtilFread(layer->linearParams.biasGradAccum, sizeof(float), layer->linearParams.dim, fp3);
- }
-
- return 0;
-}
diff --git a/src/common/cnn/timlCNNSupervisedTrainingWithLabelBatchMode.c b/src/common/cnn/timlCNNSupervisedTrainingWithLabelBatchMode.c
+++ /dev/null
@@ -1,85 +0,0 @@
-/******************************************************************************/\r
- /*!\r
- * \file timlCNNSupervisedTrainingWithLabelBatchMode.c\r
- */\r
-/* Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/\r
- *\r
- * Redistribution and use in source and binary forms, with or without\r
- * modification, are permitted provided that the following conditions\r
- * are met:\r
- *\r
- * Redistributions of source code must retain the above copyright\r
- * notice, this list of conditions and the following disclaimer.\r
- *\r
- * Redistributions in binary form must reproduce the above copyright\r
- * notice, this list of conditions and the following disclaimer in the\r
- * documentation and/or other materials provided with the\r
- * distribution.\r
- *\r
- * Neither the name of Texas Instruments Incorporated nor the names of\r
- * its contributors may be used to endorse or promote products derived\r
- * from this software without specific prior written permission.\r
- *\r
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
- *\r
- ******************************************************************************/\r
-\r
-\r
-/*******************************************************************************\r
- *\r
- * INCLUDES\r
- *\r
- ******************************************************************************/\r
-\r
-#include "../api/timl.h"\r
-\r
-\r
-/******************************************************************************/\r
-/*!\r
- * \ingroup cnn\r
- * \brief Supervised training with label\r
- * \param[in,out] cnn CNN\r
- * \param[in] data Data batch\r
- * \param[in] label Label ptr\r
- * \param[in] dim Data dimension\r
- * \param[in] num Batch size\r
- * \return Error code\r
- */\r
-/******************************************************************************/\r
-\r
-int timlCNNSupervisedTrainingWithLabelBatchMode(timlConvNeuralNetwork *cnn, float *data, int *label, int dim, int num)\r
-{\r
- int j;\r
- int err;\r
- timlCNNLayer *bpStartLayer;\r
- float batchCost;\r
- float *cost;\r
-\r
- err = 0;\r
- cost = malloc(sizeof(float)*num);\r
-\r
- for (j = 0; j < num; j++) {\r
- cnn->params.count += 1;\r
- err = timlCNNForwardPropagation(cnn, data + j*dim, dim);\r
- timlCNNCostWithLabel(cnn, label[j], cost + j, &bpStartLayer);\r
- err = timlCNNBackPropagation(cnn, bpStartLayer);\r
- }\r
-\r
- timlCNNUpdateParams(cnn);\r
- batchCost = timlUtilVectorSumFloat(cost, num)/(float)num;\r
- printf("batch = %d, cost = %f\n", cnn->params.batchCount, batchCost);\r
- cnn->params.batchCount += 1;\r
- free(cost);\r
-\r
- return err;\r
-}\r
diff --git a/src/common/cnn/timlCNNSupervisedTrainingWithLabelBatchModeOpenMP.c b/src/common/cnn/timlCNNSupervisedTrainingWithLabelBatchModeOpenMP.c
+++ /dev/null
@@ -1,108 +0,0 @@
-/******************************************************************************/\r
-/*!\r
- * \file timlCNNSupervisedTrainingWithLabelBatchModeOpenMP.c\r
- */\r
-/* Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/\r
- *\r
- * Redistribution and use in source and binary forms, with or without\r
- * modification, are permitted provided that the following conditions\r
- * are met:\r
- *\r
- * Redistributions of source code must retain the above copyright\r
- * notice, this list of conditions and the following disclaimer.\r
- *\r
- * Redistributions in binary form must reproduce the above copyright\r
- * notice, this list of conditions and the following disclaimer in the\r
- * documentation and/or other materials provided with the\r
- * distribution.\r
- *\r
- * Neither the name of Texas Instruments Incorporated nor the names of\r
- * its contributors may be used to endorse or promote products derived\r
- * from this software without specific prior written permission.\r
- *\r
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
- *\r
- ******************************************************************************/\r
-\r
-\r
-/*******************************************************************************\r
- *\r
- * INCLUDES\r
- *\r
- ******************************************************************************/\r
-\r
-#include "../api/timl.h"\r
-\r
-\r
-/******************************************************************************/\r
-/*!\r
- * \ingroup cnn\r
- * \brief supervised training with label using openmp\r
- * \param[in,out] cnn\r
- * \param[in] data data batch\r
- * \param[in] label\r
- * \param[in] dim data dimension\r
- * \param[in] num data number\r
- * \return error code\r
- */\r
-/******************************************************************************/\r
-\r
-int timlCNNSupervisedTrainingWithLabelBatchModeOpenMP(timlConvNeuralNetwork *cnn, float *data, int *label, int dim, int num)\r
-{\r
- int i;\r
- int t;\r
- int thread;\r
- int err;\r
- timlCNNLayer *bpStartLayer;\r
- float *cost;\r
- float batchCost;\r
-\r
- err = 0;\r
- cost = malloc(sizeof(float)*num);\r
- thread = omp_get_max_threads();\r
-\r
- // create cnnTeam\r
- timlConvNeuralNetwork **cnnTeam = malloc(sizeof(timlConvNeuralNetwork*)*thread);\r
- cnnTeam[0] = cnn;\r
- for (i = 1; i < thread; i++) {\r
- cnnTeam[i] = timlCNNShareParams(cnn, 0);\r
- }\r
-\r
- // parallel for loop\r
- #pragma omp parallel num_threads(thread) private(t, i, bpStartLayer, err)\r
- {\r
- #pragma omp for\r
- for (i = 0; i < num; i++) {\r
- t = omp_get_thread_num();\r
- err = timlCNNForwardPropagation(cnnTeam[t], data + i*dim, dim);\r
- timlCNNCostWithLabel(cnnTeam[t], label[i], cost + i, &bpStartLayer);\r
- err = timlCNNBackPropagation(cnnTeam[t], bpStartLayer);\r
- }\r
- }\r
-\r
- // update params\r
- cnn->params.count += num;\r
- timlCNNUpdateParams(cnn);\r
- batchCost = timlUtilVectorSumFloat(cost, num)/(float)num;\r
- printf("batch = %d, cost = %f\n", cnn->params.batchCount, batchCost);\r
- cnn->params.batchCount += 1;\r
-\r
- // free cnnTeam\r
- for (i = 1; i < thread; i++) {\r
- timlCNNDelete(cnnTeam[i]);\r
- }\r
- free(cnnTeam);\r
- free(cost);\r
-\r
- return err;\r
-}\r
diff --git a/src/common/util/timlUtilClassifyAccuracy.c b/src/common/util/timlUtilClassifyAccuracy.c
+++ /dev/null
@@ -1,74 +0,0 @@
-/******************************************************************************/
-/*!
- * \file timlUtilClassifyAccuracy.c
- */
-/* Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the
- * distribution.
- *
- * Neither the name of Texas Instruments Incorporated nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- ******************************************************************************/
-
-
-/*******************************************************************************
- *
- * INCLUDES
- *
- ******************************************************************************/
-
-#include "../api/timl.h"
-
-
-/******************************************************************************/
-/*!
- * \ingroup util
- * \brief Calculate the classification accuracy
- * \param[in] label Label matrix, size = num*topN
- * \param[in] topN Top N labels
- * \param[in] num Number of samples
- * \param[in] trueLabel True label array, size = num
- * \return Total number of correct labels
- */
-/******************************************************************************/
-
-int timlUtilClassifyAccuracy(int *label, int topN, int num, int *trueLabel)
-{
- int i;
- int j;
- int sum;
- sum = 0;
- for (i = 0; i < num; i++) {
- for (j = 0; j < topN; j++) {
- if (label[j + topN * i] == trueLabel[i]) {
- sum++;
- }
- }
- }
-
- return sum;
-}
diff --git a/src/common/util/timlUtilFree.c b/src/common/util/timlUtilFree.c
+++ /dev/null
@@ -1,71 +0,0 @@
-/******************************************************************************/
-/*!
- * \file timlUtilFree.c
- */
-/* Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the
- * distribution.
- *
- * Neither the name of Texas Instruments Incorporated nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- ******************************************************************************/
-
-
-/*******************************************************************************
- *
- * INCLUDES
- *
- ******************************************************************************/
-
-#include "../api/timl.h"
-#ifdef TIML_ALT
-#include "../../alt/timlAlt.h"
-#elif defined TIML_DSP
-#include "../../dsp/timlDSP.h"
-#endif
-
-
-/******************************************************************************/
-/*!
- * \ingroup util
- * \brief Free pointer
- * \param[in] ptr Memory pointer
- */
-/******************************************************************************/
-
-void timlUtilFree(void* ptr)
-{
-#if defined(TIML_CPU)
-# if defined(TIML_DSP)
- timlUtilFreeDSP(ptr);
-# else
- free(ptr);
-# endif
-#elif defined(TIML_ALT)
- timlUtilFreeAlt(ptr);
-#endif
-}
diff --git a/src/common/util/timlUtilMalloc.c b/src/common/util/timlUtilMalloc.c
+++ /dev/null
@@ -1,79 +0,0 @@
-/******************************************************************************/
-/*!
- * \file timlUtilMalloc.c
- */
-/* Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the
- * distribution.
- *
- * Neither the name of Texas Instruments Incorporated nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- ******************************************************************************/
-
-
-/*******************************************************************************
- *
- * INCLUDES
- *
- ******************************************************************************/
-
-#include "../api/timl.h"
-#ifdef TIML_ALT
-#include "../../alt/timlAlt.h"
-#endif
-
-
-/******************************************************************************/
-/*!
- * \ingroup util
- * \brief memory allocation
- * \param[in,out] devPtr device ptr
- * \param[in] size allocation size in byte
- * \return error code
- */
-/******************************************************************************/
-
-int timlUtilMalloc(void** devPtr, size_t size)
-{
-#if defined(TIML_CPU)
-# if defined(TIML_DSP)
- (*devPtr) = timlUtilMallocDSP(size);
- if ((*devPtr) == NULL) {
- return ERROR_UTIL_MALLOC;
- }
-# else
- (*devPtr) = malloc(size);
- if ((*devPtr) == NULL) {
- return ERROR_UTIL_MALLOC;
- }
-# endif
-#elif defined(TIML_ALT)
- return timlUtilMallocAlt(devPtr, size);
-#endif
-
- return 0;
-}
diff --git a/src/common/util/timlUtilSubtract.c b/src/common/util/timlUtilSubtract.c
+++ /dev/null
@@ -1,70 +0,0 @@
-/******************************************************************************/
-/*!
- * \file timlUtilSubtract.c
- */
-/* Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the
- * distribution.
- *
- * Neither the name of Texas Instruments Incorporated nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- ******************************************************************************/
-
-
-/*******************************************************************************
- *
- * INCLUDES
- *
- ******************************************************************************/
-
-#include "../api/timl.h"
-#ifdef TIML_ALT
-#include "../../alt/timlAlt.h"
-#endif
-
-
-/******************************************************************************/
-/*!
- * \ingroup util
- * \brief Subtract operation
- * \param[in,out] x x = x - y
- * \param[in] y Subtract constant
- * \param[in] deviceId Device id
- * \param[in] threadId Thread id
- * \return Error code
- */
-/******************************************************************************/
-
-int timlUtilSubtract(float *x, float y, int deviceId, int threadId)
-{
-#ifdef TIML_CPU
- *x -= y;
- return 0;
-#elif defined TIML_ALT
- return timlUtilSubtractAlt(x, y, deviceId, threadId);
-#endif
-}