]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - ti-machine-learning/ti-machine-learning.git/blob - src/app/cnn/interop/caffe/appCNNInteropCaffe.hpp
Remove deleted files
[ti-machine-learning/ti-machine-learning.git] / src / app / cnn / interop / caffe / appCNNInteropCaffe.hpp
1 #ifndef APPCNNINTEROPCAFFE_HPP_
2 #define APPCNNINTEROPCAFFE_HPP_
5 /******************************************************************************/
6 /*!
7  * \file     appCNNInteropCaffe.hpp
8  * \defgroup appCNNInteropCaffe appCNNInteropCaffe
9  * \ingroup  appCNN
10  * \brief    CNN Caffe interoperation applications
11  */
12 /* Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/
13  *
14  * Redistribution and use in source and binary forms, with or without
15  * modification, are permitted provided that the following conditions
16  * are met:
17  *
18  *    Redistributions of source code must retain the above copyright
19  *    notice, this list of conditions and the following disclaimer.
20  *
21  *    Redistributions in binary form must reproduce the above copyright
22  *    notice, this list of conditions and the following disclaimer in the
23  *    documentation and/or other materials provided with the
24  *    distribution.
25  *
26  *    Neither the name of Texas Instruments Incorporated nor the names of
27  *    its contributors may be used to endorse or promote products derived
28  *    from this software without specific prior written permission.
29  *
30  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
31  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
32  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
33  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
34  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
35  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
36  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
37  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
38  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
40  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41  *
42  ******************************************************************************/
45 /*******************************************************************************
46  *
47  *  INCLUDES
48  *
49  ******************************************************************************/
51 #include <google/protobuf/io/coded_stream.h>
52 #include <google/protobuf/io/zero_copy_stream_impl.h>
53 #include <google/protobuf/message.h>
54 #include <google/protobuf/text_format.h>
56 #include <fcntl.h>
57 #include "appCNNInteropCaffeProtobuf.hpp"
59 extern "C" {
60 #include "timl.h"
61 }
63 using namespace std;
64 using namespace caffe;
65 using ::google::protobuf::Message;
66 using ::google::protobuf::io::FileInputStream;
67 using ::google::protobuf::io::FileOutputStream;
68 using ::google::protobuf::io::ZeroCopyInputStream;
69 using ::google::protobuf::io::CodedInputStream;
70 using ::google::protobuf::io::ZeroCopyOutputStream;
71 using ::google::protobuf::io::CodedOutputStream;
74 /*******************************************************************************
75  *
76  * DEFINES
77  *
78  ******************************************************************************/
80 typedef enum {
81    ERROR_APP_CNN_INTEROP_ARG,
82    ERROR_APP_CNN_INTEROP_READ_FIEL
83 } appCNNInteropError;
86 /*******************************************************************************
87  *
88  * FUNCTION PROTOTYPES
89  *
90  ******************************************************************************/
92 //! \ingroup appCNNInteropCaffe
93 //@{
95 bool appCNNInteropCaffeReadProtoFromTextFile(const char* filename, Message* proto);
97 //void appCNNInteropCaffeWriteProtoToTextFile(const Message& proto, const char* filename);
99 bool appCNNInteropCaffeReadProtoFromBinaryFile(const char* filename, Message* proto);
101 //void appCNNInteropCaffeWriteProtoToBinaryFile(const Message& proto, const char* filename);
103 int appCNNInteropCaffeFlipMatrixFloat(float *a, int m, int n);
105 int appCNNInteropCaffeFlipKernelMatrix(float *kernel, int kernelRow, int kernelCol, int inputChannel, int outputChannel);
107 int appCNNInteropCaffeFillBlockDiagonalMatrix(float *a, int M, int N, int group, float *b);
109 timlUtilActivationType appCNNInteropCaffeNonlinearTypeConvert(LayerParameter_LayerType type);
111 timlCNNLayerType appCNNInteropCaffeLayerTypeConvert(LayerParameter_LayerType type);
113 timlCNNPoolingType appCNNInteropCaffePoolingTypeConvert(PoolingParameter_PoolMethod method);
115 timlConvNeuralNetwork* appCNNInteropCaffeConvert(const char *netStructurePrototxtFileName, const char *netParamPrototxtFileName);
117 int appCNNInteropCaffeConvLayerConvert(timlConvNeuralNetwork *cnn, LayerParameter layerStructure, LayerParameter layerParam);
119 int appCNNInteropCaffeConvLayerPermuteKernel(timlCNNLayer *layer);
121 int appCNNInteropCaffePoolingLayerConvert(timlConvNeuralNetwork *cnn, LayerParameter layerStructure, LayerParameter layerParam);
123 int appCNNInteropCaffeNormLayerConvert(timlConvNeuralNetwork *cnn, LayerParameter layerStructure, LayerParameter layerParam);
125 int appCNNInteropCaffeLinearLayerConvert(timlConvNeuralNetwork *cnn, LayerParameter layerStructure, LayerParameter layerParam);
127 int appCNNInteropCaffeNonlinearLayerConvert(timlConvNeuralNetwork *cnn, LayerParameter layerStructure, LayerParameter layerParam);
129 int appCNNInteropCaffeDropoutLayerConvert(timlConvNeuralNetwork *cnn, LayerParameter layerStructure, LayerParameter layerParam);
131 int appCNNInteropCaffeReadMean(timlCNNLayer *layer, const char *fileName);
133 int appCNNInteropCaffePermuteMean(float *mean, int row, int col, int channel);
135 //@}
137 #endif /* APPCNNINTEROPCAFFE_HPP_ */