 
                         for(size_t out_z = 0; out_z < output_size_z; out_z++)
                         {
-                            const size_t mat_out = out_x*output_size_y*output_size_z + out_y*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 float_type prev_inf_coeff = expr_inf_coeff[a];

    const long int min_out_x = offset_x + last_x*shift_x;
    const long int min_out_y = offset_y + last_y*shift_y;

    const long int max_out_x = min_out_x + length_x;
    const long int max_out_y = min_out_y + length_y;

    float_type inf_cst = 0;
    float_type sup_cst = 0;

    float_type tmp1, tmp2;
    float_type maxRes, maxMul;

    for(long int out_x = min_out_x; out_x < max_out_x; out_x++)
    {
        if((out_x < 0) || (out_x >= output_size_x))
        {
            continue;
        }

        for(long int out_y = min_out_y; out_y < max_out_y; out_y++)
        {
            if((out_y < 0 || out_y >= output_size_y))
            {
                continue;
            }

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

                const float_type prev_inf_coeff = expr_inf_coeff[mat_out];
                const float_type prev_sup_coeff = expr_sup_coeff[mat_out];

                    continue;
                }

                const size_t mat_y = (out_x*stride_x - pad_x + x_shift)*input_size_y*input_size_z + (out_y*stride_y - pad_y + y_shift)*input_size_z + inp_z;

                //if(out_x == 0 && out_y == 0 && out_z == 0)
                //printf("%lu ", mat_y);
