 
 template<class real> void DeviceMathKernelsType<real>::
 min(DeviceScalar *d_min, const DeviceVector &d_x) {
-    size_t temp_storage_bytes;
+    size_t temp_storage_bytes = 0;
     cub::DeviceReduce::Min(NULL, temp_storage_bytes,
                            d_x.d_data, d_min->d_data, d_x.size, stream_, CUB_DEBUG);
     void *d_temp_storage = devStream_->allocate(temp_storage_bytes, __func__);

    sq::SizeType size = d_A.rows * d_A.cols;
    InLinear2dPtr<real> in(d_A.d_data, d_A.stride, d_A.cols);

    size_t temp_storage_bytes;
    cub::DeviceReduce::Min(NULL, temp_storage_bytes,
                           in, d_min->d_data, size, stream_, CUB_DEBUG);
    void *d_temp_storage = devStream_->allocate(temp_storage_bytes, __func__);

    sq::SizeType size = d_A.rows * d_A.cols;
    InLinear2dPtr<real> in(d_A.d_data, d_A.stride, d_A.cols);

    size_t temp_storage_bytes = 0;
    cub::DeviceReduce::Sum(NULL, temp_storage_bytes,
                           in, d_dst->d_data, size, stream_, CUB_DEBUG);
    void *d_temp_storage = devStream_->allocate(temp_storage_bytes, __func__);
