# OmniSR-M: A Rock Sheet with a Multi-Branch Structure Image Super-Resolution Lightweight Method
## 2 Materials and Methods
### Omnidirectional Self-Attention Mechanism Module  
In 2023, [PERSON] et al. introduced a novel module called the Omnidirectional Self-Attention (OSA) mechanism [18]. Unlike the BAM and CBAM approaches, the OSA module aims to provide a more comprehensive self-attention mechanism to improve the performance of models. This attention mechanism module differs from existing self-attention mechanisms in that it considers both spatial and channel contextual information. The OSA module is able to transfer spatial and channel information compactly, which better solves the problem that important features will be distributed in different dimensions as the depth of the model deepens, and this mechanism is important for lightweight models. The OSA module first embeds the input feature \(X\in R^{HW\times C}\) into the query matrix \(Q^{s}\), the key matrix \(K^{s}\), and the value matrix \(V^{s}\), and generates a spatial attention map (SAM) with a size of \(R^{(H\times W)\times(H\times W)}\) by calculating the correlation between the query matrix \(Q^{s}\) and the key matrix \(K^{s}\), where \(H,W\) and \(C\) are the width, height, and the channel number of the input, respectively. At this stage, a windowing strategy can be used to reduce resource overhead. Subsequently, the spatial attention map is applied to the value matrix \(V^{s}\) to compute the aggregated results for the spatial context, a step that typically involves multiplying the spatial attention map with the value matrix and summing the results to generate an intermediate aggregated feature map. Next, the input query matrix and key matrix are rotated to generate the transposed query matrix \(Q^{c}\), the transposed key matrix \(K^{c}\), and the value matrix \(V^{c}\), with dimensions changed to \(C\times(H\times W)\), respectively, for the channel autodidactic operation. A channel attention map of size \(R^{C\times C}\) is generated by calculating the correlation between a query and a key, modeling the relationship between different channels. The channel attention map is then applied to the value matrix \(V^{c}\) to compute the aggregation result of the channel context. This step typically involves multiplying the channel attention map with the value matrix and summing the results to generate features of the channel context. Finally, the final aggregation result \(Y_{OSA}\) is obtained by reverse-rotating the output of the channel's self-attention, which is a tensor of size \(R^{(H\times W)\times C}\) containing the output of the entire OSA block. This process can be represented as follows:  
\[Q^{s} =X\cdot W_{q} \tag{7}\] \[K^{s} =X\cdot W_{k}\] (8) \[V^{s} =X\cdot W_{p}\] (9) \[Y_{s} =SoftMax\Big{(}Q^{s}K^{sT}\Big{)}\cdot V^{s} \tag{10}\]  
where \(Q^{s}\) is the spatial query matrix, \(K^{s}\) is the spatial key matrix, \(V^{s}\) is the spatial value matrix, \(X\in R^{HW\times C}\) denotes the input features, \(T\) is the transpose operation, \(Y_{s}\) is the spatial aggregation features, and \(SoftMax\) is the activation function. \[Q^{c}=\mathcal{R}\big{(}Q^{\prime}\big{)} \tag{11}\]  
Figure 2: Spatial attention mechanism. \[K^{c}=\mathcal{R}\big{(}K^{\prime}\big{)} \tag{12}\]  
\[V^{c}=\mathcal{R}\big{(}V^{\prime}\big{)} \tag{13}\]  
\[Y_{c}=SoftMax\Big{(}K^{c}Q^{cT}\Big{)}\cdot V^{c} \tag{14}\]  
\[Y_{OSA}=\mathcal{R}^{-1}(Y_{c}) \tag{15}\]  
where \(Q^{c}\) is the channel query matrix; \(K^{c}\) is the channel key matrix; \(V^{c}\) is the channel value matrix; \(Q^{\prime}\), \(K^{\prime}\) and \(V^{\prime}\) are obtained by Equations (11)-(13); \(\mathcal{R}\) is the rotate operation, which is applied to \(Q^{\prime}\), \(K^{\prime}\), and \(V^{\prime}\); \(SoftMax\) is the activation function, which will be rotated to \(Q^{c}\), \(K^{c}\), and \(V^{c}\); \(Y_{c}\) is the channel aggregation feature; and \(Y_{OSA}\) is the final aggregation result. OSA is more capable of mining deeper features compared to BAM and CBAM, which only respond to channel-wise and spatial importance without further feature information exchange.