cbcl_model.h

00001 /*
00002  *  Modified from MIT CBCL SVN repository
00003  *   Author: Sharat Chikkerur
00004  */
00005 
00006 
00007 #ifndef __cbcl_model_h__
00008 #define __cbcl_model_h__
00009 #define IN
00010 #define OUT
00011 
00012 #define ONHOST       0
00013 #define ONDEVICE     1
00014 
00015 #ifdef __CUDACC__
00016 __host__ __device__ float* elptr(float* base,int depth,int row,int col,int height,int pitch);
00017 #else
00018 inline float* elptr(float* base,int depth,int row,int col,int height,int pitch)
00019 {
00020   return (float*)((char*)base+depth*height*pitch+row*pitch)+col;
00021 }
00022 #endif
00023 
00024 typedef struct{
00025 #ifdef __CUDACC__
00026   int    __align__(8) height;
00027   int    __align__(8) width;
00028   int    __align__(8) depth;
00029   int    __align__(8) pitch;
00030   float  __align__(8) *ptr;
00031   int    __align__(8) where;
00032 #else
00033   int    height; __attribute__ ((aligned (8)));
00034   int    width;  __attribute__((aligned (8)));
00035   int    depth;  __attribute__((aligned (8)));
00036   int    pitch;  __attribute__((aligned (8)));
00037   float  *ptr;   __attribute__((aligned (8)));
00038   int    where;  __attribute__((aligned (8)));
00039 #endif
00040 }band_info;
00041 
00042 int cpu_get_width(band_info** ppfilt, int nfilts, int index);
00043 int cpu_get_height(band_info** ppfilt, int nfilts, int index);
00044 int cpu_get_depth(band_info** ppfilt, int nfilts, int index);
00045 void cpu_read_filters(const char *fname, band_info** ppfilt,int* pnfilts);
00046 void cpu_write_filters(band_info* pfilt,int nfilts,const char* filename);
00047 void cpu_create_filters(band_info** ppfilt,int nfilts, int width, int height, int depth);
00048 void cpu_copy_filter(band_info** ppfilt, int nfilts, int index, int x1, int y1, band_info **ppfiltin, int indexin, int x2, int y2);
00049 
00050 void gpu_s_norm_filter(
00051                        IN  band_info        *pc,     /*pointer to the DEVICE storage*/
00052                        IN  int                        in_bands,  /*number of input bands [IN]*/
00053                        IN  band_info        *pfilt,  /*pointer to DEVICE storage*/
00054                        IN  int                        num_filt,  /*number of filtes=output depth*/
00055                        OUT band_info        **pps,      /*pointer ot DEVICE storage*/
00056                        OUT int                        *pout_bands,/*number of output bands*/
00057                        IN  bool        copy=true   /*copy output to host*/
00058                        );
00059 
00060 
00061 void gpu_s_rbf(
00062                IN  band_info        *pc,     /*pointer to the DEVICE storage*/
00063                IN  int                        in_bands,  /*number of input bands [IN]*/
00064                IN  band_info        *pfilt,  /*pointer to DEVICE storage*/
00065                IN  int                        num_filt,  /*number of filtes=output depth*/
00066                IN  float       sigma,      /*sigma for the tuning curve*/
00067                OUT band_info        **pps,      /*pointer ot DEVICE storage*/
00068                OUT int                        *pout_bands,/*number of output bands*/
00069                IN  bool        copy=true  /*copy results back to host*/
00070                );
00071 
00072 void gpu_c_local(
00073                  IN  band_info* s,     /*pointer to DEVICE storage*/
00074                  IN  int in_bands,     /*number of input bands*/
00075                  IN  int pool_xy,      /*spatial pooling: subsampling by pool_xy/2*/
00076                  IN  int step_xy,      /*spatial subsampling factor*/
00077                  IN  int pool_scale,   /*scale wise pooling: out_bands=in_bands/pool_scale*/
00078                  IN  int step_scale,   /*scale incremenet step*/
00079                  OUT band_info** c,   /*pointer to DEVICE storage*/
00080                  OUT int* out_bands,   /*number of output bands*/
00081                  IN  bool copy=true    /*copy results back to host*/
00082                  );
00083 
00084 void gpu_c_global(
00085                   IN band_info* s,      /*pointer to device storage*/
00086                   IN int in_bands,      /*number of input bands*/
00087                   OUT int* out_units,   /*=input depth*/
00088                   OUT float* c          /*pointer to DEVICE storage*/
00089                   );
00090 
00091 void cpu_c_global(
00092                   IN band_info* s,      /*pointer to device storage*/
00093                   IN int in_bands,      /*number of input bands*/
00094                   OUT float** ppc,      /*pointer to DEVICE storage*/
00095                   OUT int* out_units   /*=input depth*/
00096                   );
00097 
00098 void cpu_create_c0(
00099                    IN  const float* pimg,            /*pointer to image data*/
00100                    IN  int width,              /*width of the image*/
00101                    IN  int height,             /*height of the image*/
00102                    OUT band_info** ppc,        /*pointer to host storage*/
00103                    OUT int* pbands,             /*number of bands*/
00104                    IN  float scale=1.113,       /*resize scale*/
00105                    IN  int   num_scales=16      /*number of scales*/
00106                    );
00107 
00108 void gpu_create_c0(
00109                    IN  const float* pimg,            /*pointer to image data*/
00110                    IN  int width,              /*width of the image*/
00111                    IN  int height,             /*height of the image*/
00112                    OUT band_info** ppc,        /*pointer to host storage*/
00113                    OUT int* pbands,             /*number of bands*/
00114                    IN  float scale=1.113,       /*resize scale*/
00115                    IN  int   num_scales=16,      /*number of scales*/
00116                    IN  bool  copy      =true    /*copy output to host*/
00117                    );
00118 
00119 void cpu_release_images(
00120                         IN  band_info** ppbands, /*pointer to HOST storage*/
00121                         OUT int num_bands        /*number of bands*/
00122                         );
00123 #endif
Generated on Sun May 8 08:04:43 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3