Pablo Tello | 9ceebbe | 2018-01-10 16:44:13 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2017 ARM Limited. |
| 3 | * |
| 4 | * SPDX-License-Identifier: MIT |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | * of this software and associated documentation files (the "Software"), to |
| 8 | * deal in the Software without restriction, including without limitation the |
| 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
| 10 | * sell copies of the Software, and to permit persons to whom the Software is |
| 11 | * furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included in all |
| 14 | * copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 22 | * SOFTWARE. |
| 23 | */ |
| 24 | |
| 25 | #include "winograd_gemm.hpp" |
| 26 | using namespace winograd; |
| 27 | |
| 28 | |
| 29 | template <int otr, int otc, int kr, int kc> |
| 30 | template <typename T> |
| 31 | WinogradGEMM<otr, otc, kr, kc>::WeightsTransform<T>::WeightsTransform( |
| 32 | const T* const input, |
| 33 | T* const output, |
| 34 | const int matrix_stride, /** Stride across matrices in the output. */ |
| 35 | const int matrix_row_stride, /** Stride across rows of the matrix. */ |
| 36 | const int n_output_channels, |
| 37 | const int n_input_channels |
| 38 | ) : inptr(input), outptr(output), |
| 39 | matrix_stride(matrix_stride), matrix_row_stride(matrix_row_stride), |
| 40 | n_output_channels(n_output_channels), n_input_channels(n_input_channels) |
| 41 | { |
| 42 | } |
| 43 | |
| 44 | |
| 45 | template <int otr, int otc, int kr, int kc> |
| 46 | template <typename T> |
| 47 | unsigned int WinogradGEMM<otr, otc, kr, kc>::WeightsTransform<T>::get_window() const |
| 48 | { |
| 49 | // TODO When the weights transform supports multithreading, return the number |
| 50 | // of output channels. For now we return 1 to indicate that the weights must |
| 51 | // be transformed as a single block. |
| 52 | // return n_output_channels; |
| 53 | return 1; |
| 54 | } |
| 55 | |
| 56 | |
| 57 | template <int otr, int otc, int kr, int kc> |
| 58 | template <typename T> |
| 59 | void WinogradGEMM<otr, otc, kr, kc>::WeightsTransform<T>::run( |
| 60 | const unsigned int start, const unsigned int stop |
| 61 | ) |
| 62 | { |
| 63 | // TODO When the weights transform supports multithreading call execute for a |
| 64 | // portion of the output channels. |
| 65 | (void) start; |
| 66 | (void) stop; |
| 67 | |
| 68 | // For now, just do all of the work. |
| 69 | execute( |
| 70 | n_output_channels, |
| 71 | n_input_channels, |
| 72 | inptr, |
| 73 | outptr, |
| 74 | matrix_stride, |
| 75 | matrix_row_stride |
| 76 | ); |
| 77 | } |