             {
                 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++)
                 {

    cudaMemcpy(strides_tmp, strides, 2*sizeof(size_t), cudaMemcpyHostToHost);

    device_layer_create_sparse_exprs(expr_array, filter_weights_tmp, filter_bias_tmp, input_size_tmp, output_size_tmp,
                                     filter_size_tmp, strides_tmp, has_bias, pad_top, pad_left, num_pixels);

    free(filter_weights_tmp);
    free(filter_bias_tmp);

                            }

                            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;
                            dense_coeff[mat_x*num_pixels + mat_y] = filter_weights[filter_index];
                        }
                    }
                }

                bias[mat_x] = filter_bias[out_z];
            }
        }
    }

    double* dense_coeff_dev;
    double* bias_dev;

    cudaMalloc((void**) &dense_coeff_dev, num_out_neurons*num_pixels*sizeof(double));
    cudaMalloc((void**) &bias_dev, num_out_neurons*sizeof(double));

    cudaMemcpy(dense_coeff_dev, dense_coeff, num_out_neurons*num_pixels*sizeof(double), cudaMemcpyHostToDevice);
    cudaMemcpy(bias_dev, bias, num_out_neurons*sizeof(double), cudaMemcpyHostToDevice);

    device_layer_create_dense_expr<<<num_out_neurons, 1>>>(expr_array, dense_coeff_dev, bias_dev, num_out_neurons, num_pixels);

    cudaFree(dense_coeff_dev);
    cudaFree(bias_dev);

    free(dense_coeff);
    free(bias);
}


