00001
00002
00003
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,
00052 IN int in_bands,
00053 IN band_info *pfilt,
00054 IN int num_filt,
00055 OUT band_info **pps,
00056 OUT int *pout_bands,
00057 IN bool copy=true
00058 );
00059
00060
00061 void gpu_s_rbf(
00062 IN band_info *pc,
00063 IN int in_bands,
00064 IN band_info *pfilt,
00065 IN int num_filt,
00066 IN float sigma,
00067 OUT band_info **pps,
00068 OUT int *pout_bands,
00069 IN bool copy=true
00070 );
00071
00072 void gpu_c_local(
00073 IN band_info* s,
00074 IN int in_bands,
00075 IN int pool_xy,
00076 IN int step_xy,
00077 IN int pool_scale,
00078 IN int step_scale,
00079 OUT band_info** c,
00080 OUT int* out_bands,
00081 IN bool copy=true
00082 );
00083
00084 void gpu_c_global(
00085 IN band_info* s,
00086 IN int in_bands,
00087 OUT int* out_units,
00088 OUT float* c
00089 );
00090
00091 void cpu_c_global(
00092 IN band_info* s,
00093 IN int in_bands,
00094 OUT float** ppc,
00095 OUT int* out_units
00096 );
00097
00098 void cpu_create_c0(
00099 IN const float* pimg,
00100 IN int width,
00101 IN int height,
00102 OUT band_info** ppc,
00103 OUT int* pbands,
00104 IN float scale=1.113,
00105 IN int num_scales=16
00106 );
00107
00108 void gpu_create_c0(
00109 IN const float* pimg,
00110 IN int width,
00111 IN int height,
00112 OUT band_info** ppc,
00113 OUT int* pbands,
00114 IN float scale=1.113,
00115 IN int num_scales=16,
00116 IN bool copy =true
00117 );
00118
00119 void cpu_release_images(
00120 IN band_info** ppbands,
00121 OUT int num_bands
00122 );
00123 #endif