 
 
 template<class BinaryFunction>
-void THCudaTensor_reduceDim(THCudaTensor *self_, THCudaTensor *src, long dimension, BinaryFunction binary_op, float init)
-{
-  THCudaTensor_transformReduceDim(self_, src, dimension, thrust::identity<float>(), binary_op, init);
+void THCudaTensor_reduceDim(THCudaTensor *self_, THCudaTensor *src, long dimension, float init, BinaryFunction binary_op)
+{
+  THCudaTensor_transformReduceDim(self_, src, dimension, thrust::identity<float>(), init, binary_op);
 }
 
 
 void THCudaTensor_sum(THCudaTensor *self, THCudaTensor *src, long dimension)
 {
-  return THCudaTensor_reduceDim(self, src, dimension, thrust::plus<float>(), 0.0f);
+  return THCudaTensor_reduceDim(self, src, dimension, 0.0f, thrust::plus<float>());
 }
 
 
 void THCudaTensor_max(THCudaTensor *self, THCudaTensor *src, long dimension)
 {
   const float minfloat32 = -3.402823466e+38f;
-  return THCudaTensor_reduceDim(self, src, dimension, thrust::maximum<float>(), minfloat32);
+  return THCudaTensor_reduceDim(self, src, dimension, minfloat32, thrust::maximum<float>());
 }
 
 
 void THCudaTensor_min(THCudaTensor *self, THCudaTensor *src, long dimension)
 {
   const float maxfloat32 = 3.402823466e+38f;
-  return THCudaTensor_reduceDim(self, src, dimension, thrust::minimum<float>(), maxfloat32);
+  return THCudaTensor_reduceDim(self, src, dimension, maxfloat32, thrust::minimum<float>());
 }
 
 


template<class UnaryFunction, class BinaryFunction>
__host__ void THCudaTensor_transformReduceOuterDim(THCudaTensor *tgt, THCudaTensor *src,
        long rdim, UnaryFunction unary_op, BinaryFunction binary_op, float init)
{
  const size_t reduce = 3;
  dim4 src_stride(0);


template<class UnaryFunction, class BinaryFunction>
__host__ void THCudaTensor_transformReduceInnermostDim(THCudaTensor *tgt, THCudaTensor *src,
        UnaryFunction unary_op, float init, BinaryFunction binary_op)
{
  dim4 src_stride(0);
  dim4 tgt_stride(0);
