     ////////////////////////////////// SetTo //////////////////////////////////
     ///////////////////////////////////////////////////////////////////////////
 
+    template <typename T>
+    class shift_and_sizeof;
+
+    template <>
+    class shift_and_sizeof<char>
+    {
+        public:
+        enum { shift = 0 };
+    };
+
+    template <>
+    class shift_and_sizeof<unsigned char>
+    {
+        public:
+        enum { shift = 0 };
+    };
+
+    template <>
+    class shift_and_sizeof<short>
+    {
+        public:
+        enum { shift = 1 };
+    };
+
+    template <>
+    class shift_and_sizeof<unsigned short>
+    {
+        public:
+        enum { shift = 1 };
+    };
+
+    template <>
+    class shift_and_sizeof<int>
+    {
+        public:
+        enum { shift = 2 };
+    };
+
+    template <>
+    class shift_and_sizeof<float>
+    {
+        public:
+        enum { shift = 2 };
+    };
+
+    template <>
+    class shift_and_sizeof<double>
+    {
+        public:
+        enum { shift = 3 };
+    };
+
     template<typename T>
     __global__ void kernel_set_to_without_mask(T * mat, int cols, int rows, int step, int channels)
     {


                SetToFunc_without_mask func = tab[depth];

                if (func == 0) 
                    cv::gpu::error("Unsupported convert operation", __FILE__, __LINE__);

                func(mat, channels, stream);



            extern "C" void set_to_with_mask(DevMem2D mat, int depth, const double * scalar, const DevMem2D& mask, int channels, const cudaStream_t & stream)
            {
                cudaSafeCall( cudaMemcpyToSymbol(mat_operators::scalar_d, scalar, sizeof(double) * 4));

                static SetToFunc_with_mask tab[8] =
