# VLSI-Friendly Filtering Algorithms for Deep Neural Networks
## 3 Preliminary Remarks
\begin{array}{cccc}x_{0}&x_{1}&\cdots&x_{M -1}\\ x_{1}&x_{2}&\cdots&x_{M}\\ \vdots&\vdots&\ddots&\vdots\\ \dots x_{M-1}&x_{M}&\cdots&x_{2M-2}\\ x_{M}&x_{M+1}&\cdots&x_{2M-1}\\ x_{M+1}&x_{M+2}&\cdots&x_{2M}\\ \vdots&\vdots&\ddots&\vdots\\ \dots x_{2M-1}&x_{2M}&\cdots&x_{3M-2}\\ \vdots&\vdots&\vdots&\vdots\\ \vdots&\vdots&\vdots&\vdots\\ \vdots&\vdots&\vdots&\vdots\\ \vdots&\vdots&\ddots&\vdots\\ \vdots&\vdots&\ddots&\vdots\\ \vdots&\vdots&\ddots&\vdots\\ \vdots&\vdots&\ddots&\vdots\\ x_{KM-1}&x_{KM}&\cdots&x_{(K-1)M-2}\end{array} \right]\left[ \begin{array}{c}w_{0} \\ w_{1}\\ \vdots\\ w_{M-1}\end{array} \right] \tag{6}\]  
By examining this description, it becomes evident that the matrix \(\textbf{X}_{KM\times M}\) possesses a block structure and comprises \(K\) submatrices of Hankel type. Thus, the calculation of the sliding dot product, taking into account the imposed conditions, comes down to multiplying the sequence of \(K\) sub-matrices (i.e. the Hankel matrices) by the vector \(\textbf{W}_{M\times 1}\) and then combining the individual calculation results. Hence, we establish the fundamental filtering operation in DNNs as multiplying the Hankel sub-matrix (formed from the current input data sequence using a sliding window of size \(M\)) by a vector whose elements are the impulse response coefficients of an \(M\)-order FIR filter. There are efficient algorithms for multiplying Hankel matrices by a vector. However, they are mainly focused on large matrices, the order of which is a power of two [44,45]. But in most cases of image processing in neural networks, the impulse responses of FIR filters are short and contain an odd number of coefficients. Under these conditions, we are dealing with Hankel matrices of small orders. When multiplying small-size Hankel matrices by small-length vectors, known algorithms are inefficient or even counterproductive. Therefore, we have developed our own algorithms explicitly focused on calculating matrix-vector products with Hankel matrices of small orders. So, we define the basic filtering macrooperation as:  
\[\textbf{Y}_{M\times 1}=\textbf{X}_{M}\textbf{W}_{M\times 1} \tag{7}\]  
where:  
\[\textbf{X}_{M}=\left[ \begin{array}{cccc}x_{0}&x_{1}&\cdots&x_{M-1}\\ x_{1}&x_{2}&\cdots&x_{M}\\ \vdots&\vdots&\ddots&\vdots\\ x_{M-1}&x_{M}&\cdots&x_{2M-2}\end{array} \right],\]  
\[\textbf{Y}_{M\times 1}=\left[y_{0}^{(M)},y_{1}^{(M)},\ldots,y_{M-1}^{(M)} \right]^{\text{T}},\]  
\[\textbf{W}_{M\times 1}=\left[w_{0}^{(M)},w_{1}^{(M)},\ldots,w_{M-1}^{(M)} \right]^{\text{T}}.\]  
(Kindly take note that from this point forward, the superscript \(M\) will signify quantities associated with the basic filtering macrooperation employing an \(M\)-order filter). We emphasise once again that, as a rule, small-order filters are used in deep neural networks when the impulse response vectors contain a small number of elements. And almost always, we are dealing with an odd number of records. Based on the information provided above, this article aims to create and describe resource-efficient filtering algorithms for FIR filters with widely used orders: \(M=3\), \(5\), \(7\), and \(9\).