     float_type* linf_cst_tmp;
     float_type* lsup_cst_tmp;
 
-    cudaMalloc((void**) &linf_coeff_tmp, num_out_neurons_last_layer*sizeof(float_type*));
-    cudaMalloc((void**) &lsup_coeff_tmp, num_out_neurons_last_layer*sizeof(float_type*));
+    cudaMalloc((void**) &linf_coeff_tmp, num_out_neurons_last_layer*sizeof(float_type));
+    cudaMalloc((void**) &lsup_coeff_tmp, num_out_neurons_last_layer*sizeof(float_type));
     cudaMalloc((void**) &linf_cst_tmp, num_out_neurons_last_layer*sizeof(float_type));
     cudaMalloc((void**) &lsup_cst_tmp, num_out_neurons_last_layer*sizeof(float_type));
 

    std::cout << "shift_x " << shift_x << " shift_y " << shift_y << std::endl;

    size_t current_size = 4*num_out_neurons_last_layer*length_x*length_y*fp->layers[layerno]->input_size[2]*sizeof(float_type);
    size_t last_size;

    size_t maximum_size = 0;

    std::cout << "Size: " << current_size << " bytes" << std::endl;
    std::cout << std::endl;

    int k = layerno - 1;

    while(k >= 0)
    {

    std::cout << "shift_x " << shift_x << " shift_y " << shift_y << std::endl;

    size_t current_size = 4*num_out_neurons_last_layer*length_x*length_y*fp->layers[layerno]->input_size[2]*sizeof(float_type);
    size_t last_size = 0;

    size_t maximum_size = 0;

    std::cout << "Size: " << current_size << " bytes" << std::endl;
    std::cout << std::endl;

    int k;

    if(fp->layers[layerno]->type == RESIDUAL)
    {
        const size_t predecessor1 = fp->layers[layerno]->predecessors[0] - 1;
        const size_t predecessor2 = fp->layers[layerno]->predecessors[1] - 1;

        char* predecessor_map = (char*) calloc(layerno, sizeof(char));
        int iter = predecessor1;

        while(iter >= 0)
        {
            predecessor_map[iter] = 1;
            iter = fp->layers[iter]->predecessors[0] - 1;
        }

        iter =  predecessor2;
        int common_predecessor = 0;

        while(iter >= 0)
        {
            if(predecessor_map[iter] == 1)
            {
                common_predecessor = iter;

                break;
            }

            iter = fp->layers[iter]->predecessors[0] - 1;
        }

        free(predecessor_map);

        long int copy_offset_x = offset_x;
        long int copy_offset_y = offset_y;

        long int copy_length_x = length_x;
        long int copy_length_y = length_y;

        long int copy_shift_x = shift_x;
        long int copy_shift_y = shift_y;

        size_t copy_current_size = current_size;
        size_t copy_last_size = last_size;

        iter = predecessor1;

        while(iter != common_predecessor)
        {
            predict_size_of_conv_layer(fp, copy_current_size, copy_last_size, copy_offset_x, copy_offset_y, copy_length_x, copy_length_y, copy_shift_x, copy_shift_y, iter, num_out_neurons_last_layer);

            if(copy_last_size + copy_current_size + current_size > maximum_size)
            {
                maximum_size = copy_last_size + copy_current_size + current_size;
            }

            iter = fp->layers[iter]->predecessors[0] - 1;
        }

        iter = predecessor2;

        while(iter != common_predecessor)
        {
            predict_size_of_conv_layer(fp, current_size, last_size, offset_x, offset_y, length_x, length_y, shift_x, shift_y, iter, num_out_neurons_last_layer);

            if(last_size + current_size + copy_current_size > maximum_size)
            {
                maximum_size = last_size + current_size + copy_current_size;
            }

            iter = fp->layers[iter]->predecessors[0] - 1;
        }

        if(copy_length_x > length_x)
        {
            std::swap(copy_current_size, current_size);

            std::swap(offset_x, copy_offset_x);
            std::swap(offset_y, copy_offset_y);

            std::swap(length_x, copy_length_x);
            std::swap(length_y, copy_length_y);

            std::swap(shift_x, copy_shift_x);
            std::swap(shift_y, copy_shift_y);
        }

        k = common_predecessor;
    }
    else
    {
        k = fp->layers[layerno]->predecessors[0] - 1;
    }

    while(k >= 0)
    {
