| 2886 | } |
| 2887 | |
| 2888 | void col2img( |
| 2889 | const matrix<float>& output, |
| 2890 | tensor& data, |
| 2891 | long n, |
| 2892 | long filter_nr, |
| 2893 | long filter_nc, |
| 2894 | long stride_y, |
| 2895 | long stride_x, |
| 2896 | long padding_y, |
| 2897 | long padding_x |
| 2898 | ) |
| 2899 | { |
| 2900 | const auto d = data.host() + data.k()*data.nr()*data.nc()*n; |
| 2901 | const rectangle boundary = get_rect(data); |
| 2902 | |
| 2903 | DLIB_CASSERT(output.size() != 0); |
| 2904 | const float* t = &output(0,0); |
| 2905 | |
| 2906 | // now fill in the Toeplitz output matrix for the n-th sample in data. |
| 2907 | const long max_r = data.nr() + padding_y-(filter_nr-1); |
| 2908 | const long max_c = data.nc() + padding_x-(filter_nc-1); |
| 2909 | for (long r = -padding_y; r < max_r; r+=stride_y) |
| 2910 | { |
| 2911 | for (long c = -padding_x; c < max_c; c+=stride_x) |
| 2912 | { |
| 2913 | for (long k = 0; k < data.k(); ++k) |
| 2914 | { |
| 2915 | for (long y = 0; y < filter_nr; ++y) |
| 2916 | { |
| 2917 | for (long x = 0; x < filter_nc; ++x) |
| 2918 | { |
| 2919 | long xx = c+x; |
| 2920 | long yy = r+y; |
| 2921 | if (boundary.contains(xx,yy)) |
| 2922 | d[(k*data.nr() + yy)*data.nc() + xx] += *t; |
| 2923 | ++t; |
| 2924 | } |
| 2925 | } |
| 2926 | } |
| 2927 | } |
| 2928 | } |
| 2929 | } |
| 2930 | |
| 2931 | void tensor_conv::operator() ( |
| 2932 | const bool add_to_output, |