 
 
 __global__
-void compute_lb_from_expr_conv_sparse(float_type* __restrict__ lb_array, const float_type* __restrict__ inf_coeff, const float_type* __restrict__ sup_coeff, const float_type* __restrict__ inf_cst, const float_type* __restrict__ input_inf, const float_type* __restrict__ input_sup, const size_t output_size_x, const size_t output_size_y, const size_t output_size_z, long int offset_x, long int offset_y, long int length_x, long int length_y, long int shift_x, long int shift_y)
+void compute_lb_from_expr_conv_sparse(float_type* __restrict__ lb_array, const float_type* __restrict__ inf_coeff, const float_type* __restrict__ sup_coeff, const float_type* __restrict__ inf_cst, const float_type* __restrict__ input_inf, const float_type* __restrict__ input_sup, const size_t num_chunks, const size_t chunk_counter, const size_t output_size_x, const size_t output_size_y, const size_t output_size_z, long int offset_x, long int offset_y, long int length_x, long int length_y, long int shift_x, long int shift_y)
 {
     const size_t last_x = blockIdx.x;
     const size_t last_y = blockIdx.y;
     const size_t last_z = blockIdx.z;
 
-    const size_t n = last_x*gridDim.y*gridDim.z + last_y*gridDim.z + last_z;
+    const size_t local_n = last_x*gridDim.y*gridDim.z + last_y*gridDim.z + last_z;
+    const size_t global_n = last_x*gridDim.y*num_chunks*gridDim.z + last_y*num_chunks*gridDim.z + chunk_counter*gridDim.z + last_z;
 
     const long int min_out_x = offset_x + last_x*shift_x;
     const long int min_out_y = offset_y + last_y*shift_y;
 
-    float_type res_inf = inf_cst[n];
+    float_type res_inf = inf_cst[local_n];
 
     float_type tmp1, tmp2;
 

}


void print_sizes(fppoly_t* fp, const size_t layerno)
{
    size_t free;
    size_t total;


    std::chrono::duration<double> elapsed_seconds = end - start;
    std::cout << "elapsed time: " << elapsed_seconds.count() << "s" << std::endl << std::endl;
}


void update_state_using_previous_layers_conv(elina_manager_t* man, fppoly_t* fp, const size_t layerno)
{
    const size_t num_chunks = predict_size(fp, layerno);

    for(size_t chunk_counter = 0; chunk_counter < num_chunks; chunk_counter++)
    {
        update_state_using_previous_layers_conv_chunk(man, fp, fp->numlayers - 1, num_chunks, chunk_counter);
    }
}


