             {
                 const size_t mat_x = out_x*output_size[1]*output_size[2] + out_y*output_size[2] + out_z;
                 const size_t num_coeff = input_size[2]*filter_size[0]*filter_size[1];
-                size_t actual_coeff = 0;
-                double* coeff = (double*) malloc(num_coeff*sizeof(double));
-                size_t* dim = (size_t*) malloc(num_coeff*sizeof(size_t));
-                size_t i = 0;
 
                 for(size_t x_shift = 0; x_shift < filter_size[0]; x_shift++)
                 {

                            }

                            const size_t filter_index = x_shift*filter_size[1]*input_size[2]*output_size[2] + y_shift*input_size[2]*output_size[2] + inp_z*output_size[2] + out_z;
                            coeff[i] = filter_weights[filter_index];
                            dim[i] = mat_y;
                            actual_coeff++;
                            i++;
                        }
                    }
                }

                const double cst = filter_bias[out_z];

                double* dense_coeff = (double*) calloc(num_pixels, sizeof(double));

                for(size_t i = 0; i < actual_coeff; i++)
                {
                    dense_coeff[dim[i]] = coeff[i];
                }

                expr_t* res = (expr_t*) malloc(sizeof(expr_t));

                res->inf_coeff = (double*) malloc(num_pixels*sizeof(double));
                res->sup_coeff = (double*) malloc(num_pixels*sizeof(double));

                res->inf_cst = -cst;
                res->sup_cst = cst;

                for(size_t i = 0; i < num_pixels; i++)
                {
                    res->inf_coeff[i] = -dense_coeff[i];
                    res->sup_coeff[i] = dense_coeff[i];
                }

                copy_dense_expr_host_to_device(expr_array, mat_x, res, num_pixels);

                if(res->inf_coeff)
                {
                    free(res->inf_coeff);
                    res->inf_coeff = nullptr;
                }

                if(res->sup_coeff)
                {
                    free(res->sup_coeff);
                    res->sup_coeff = nullptr;
                }

                free(res);
                res = nullptr;

                free(coeff);
                free(dense_coeff);
                free(dim);
            }
        }
    }
}



}


void device_layer_create_sparse_exprs(expr_t** expr_array, const double* filter_weights, const double* filter_bias,
                               const size_t* input_size, const size_t* output_size, const size_t* filter_size, const size_t* strides,
                               const long int pad_top, const long int pad_left, const size_t num_pixels)
{
    const size_t num_out_neurons = output_size[0]*output_size[1]*output_size[2];

    double* dense_coeff = (double*) calloc(num_out_neurons*num_pixels, sizeof(double));
    double* bias = (double*) calloc(num_out_neurons, sizeof(double));

    for(size_t out_x = 0; out_x < output_size[0]; out_x++)
    {
        for(size_t out_y = 0; out_y < output_size[1]; out_y++)
