| 34 | } |
| 35 | |
| 36 | int main(int argc, char **argv) { |
| 37 | try { |
| 38 | int device = argc > 1 ? atoi(argv[1]) : 0; |
| 39 | af::setDevice(device); |
| 40 | af::info(); |
| 41 | |
| 42 | // setup image and device copies of kernels |
| 43 | img = randu(640, 480); |
| 44 | dx = array(5, 1, h_dx); // 5x1 kernel |
| 45 | spread = array(1, 5, h_spread); // 1x5 kernel |
| 46 | kernel = matmul(dx, spread); // 5x5 kernel |
| 47 | |
| 48 | printf("full 2D convolution: %.5f seconds\n", timeit(full)); |
| 49 | printf("separable, device pointers: %.5f seconds\n", timeit(dsep)); |
| 50 | |
| 51 | // ensure values are all the same across versions |
| 52 | if (fail(full_out, dsep_out)) { throw af::exception("full != dsep"); } |
| 53 | } catch (af::exception &e) { fprintf(stderr, "%s\n", e.what()); } |
| 54 | |
| 55 | return 0; |
| 56 | } |