                 {
                     if(!((y_val < 0) || (y_val >= (long int)input_size_y)))
                     {
-                        const size_t mat_in = (out_x*stride_x + x_shift + min_out_x*stride_x - pad_x)*input_size_y*input_size_z + (out_y*stride_y + y_shift + min_out_y*stride_y - pad_y)*input_size_z + inp_z;
-                        const size_t b = n*input_size_x*input_size_y*input_size_z + mat_in;
+                        const size_t mat_in = (out_x*stride_x + x_shift)*((length_y - 1)*stride_y + filter_size_y)*input_size_z + (out_y*stride_y + y_shift)*input_size_z + inp_z;
+                        const size_t b = n*((length_x - 1)*stride_x + filter_size_x)*((length_y - 1)*stride_y + filter_size_y)*input_size_z + mat_in;
 
                         float_type inf_coeff = res_inf_coeff[b];
                         float_type sup_coeff = res_sup_coeff[b];
 
                         for(size_t out_z = 0; out_z < output_size_z; out_z++)
                         {
-                            const size_t mat_out = (out_x + min_out_x)*output_size_y*output_size_z + (out_y + min_out_y)*output_size_z + out_z;
-                            const size_t a = n*output_size_x*output_size_y*output_size_z + mat_out;
+                            const size_t mat_out = out_x*length_y*output_size_z + out_y*output_size_z + out_z;
+                            const size_t a = n*length_x*length_y*output_size_z + mat_out;
 
                             const float_type prev_inf_coeff = expr_inf_coeff[a];
                             const float_type prev_sup_coeff = expr_sup_coeff[a];

            for(size_t out_z = 0; out_z < output_size_z; out_z++)
            {
                size_t i = (out_x + min_out_x)*output_size_y*output_size_z + (out_y + min_out_y)*output_size_z + out_z;
                size_t mat_out = n*output_size_x*output_size_y*output_size_z + i;

                elina_double_interval_mul(&tmp1, &tmp2, inf_coeff[mat_out], sup_coeff[mat_out], input_inf[i], input_sup[i]);
                res_sup = res_sup + tmp2;

    cudaFree(linf_cst);
    cudaFree(lsup_cst);

    /*
    cudaFree(linf_coeff_tmp);
    cudaFree(lsup_coeff_tmp);
    */
    cudaFree(linf_cst_tmp);
    cudaFree(lsup_cst_tmp);

