/src/Simd/src/Simd/SimdAvx512bwSynetQuantizedMergedConvolution.cpp
Line | Count | Source |
1 | | /* |
2 | | * Simd Library (http://ermig1979.github.io/Simd). |
3 | | * |
4 | | * Copyright (c) 2011-2025 Yermalayeu Ihar. |
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 deal |
8 | | * in the Software without restriction, including without limitation the rights |
9 | | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
10 | | * 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 |
14 | | * all 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 | | #include "Simd/SimdSynetQuantizedMergedConvolution.h" |
25 | | #include "Simd/SimdSynetQuantizeLinear.h" |
26 | | #include "Simd/SimdSynetConvolution8iCommon.h" |
27 | | #include "Simd/SimdSynet.h" |
28 | | #include "Simd/SimdMath.h" |
29 | | #include "Simd/SimdBase.h" |
30 | | #include "Simd/SimdCpu.h" |
31 | | #include "Simd/SimdLog.h" |
32 | | |
33 | | namespace Simd |
34 | | { |
35 | | #if defined(SIMD_AVX512BW_ENABLE) && defined(SIMD_SYNET_ENABLE) |
36 | | namespace Avx512bw |
37 | | { |
38 | | typedef Base::SynetQuantizedMergedConvolution::AlgParam AlgParam; |
39 | | |
40 | | //------------------------------------------------------------------------------------------------ |
41 | | |
42 | | SynetQuantizedMergedConvolutionCdc::SynetQuantizedMergedConvolutionCdc(const MergConvParam& p) |
43 | 0 | : Avx2::SynetQuantizedMergedConvolutionCdc(p) |
44 | 0 | { |
45 | 0 | SetSize(F, 4, 2); |
46 | 0 | SetInputConvolution(p.conv[0], _alg, _inputConvolution); |
47 | 0 | SetDepthwisePreprocess(p.conv[1], _alg, _depthwisePreprocess); |
48 | 0 | SetDepthwiseConvolution(p.conv[1], _alg, _depthwiseConvolution); |
49 | 0 | SetOutputConvolution(p.conv[2], _alg, _outputConvolution); |
50 | 0 | SetAddInputToOutput(p.conv[2], _alg, _addInputToOutput); |
51 | 0 | } |
52 | | |
53 | | //------------------------------------------------------------------------------------------------ |
54 | | |
55 | | SynetQuantizedMergedConvolutionCd::SynetQuantizedMergedConvolutionCd(const MergConvParam& p) |
56 | 0 | : Avx2::SynetQuantizedMergedConvolutionCd(p) |
57 | 0 | { |
58 | 0 | SetSize(F, 4, 2); |
59 | 0 | SetInputConvolution(p.conv[0], _alg, _inputConvolution); |
60 | 0 | SetDepthwisePreprocess(p.conv[1], _alg, _depthwisePreprocess); |
61 | 0 | SetDepthwiseConvolution(p.conv[1], _alg, _depthwiseConvolution); |
62 | 0 | } |
63 | | |
64 | | //------------------------------------------------------------------------------------------------ |
65 | | |
66 | | SynetQuantizedMergedConvolutionDc::SynetQuantizedMergedConvolutionDc(const MergConvParam& p) |
67 | 0 | : Avx2::SynetQuantizedMergedConvolutionDc(p) |
68 | 0 | { |
69 | 0 | SetSize(F, 4, 2); |
70 | 0 | SetDepthwisePreprocess(p.conv[0], _alg, _depthwisePreprocess); |
71 | 0 | SetDepthwiseConvolution(p.conv[0], _alg, _depthwiseConvolution); |
72 | 0 | SetOutputConvolution(p.conv[1], _alg, _outputConvolution); |
73 | 0 | SetAddInputToOutput(p.conv[1], _alg, _addInputToOutput); |
74 | 0 | } |
75 | | |
76 | | //------------------------------------------------------------------------------------------------ |
77 | | |
78 | | void* SynetQuantizedMergedConvolutionInit(size_t batch, const SimdConvolutionParameters* convs, size_t count, int add) |
79 | 0 | { |
80 | 0 | MergConvParam param(batch, convs, count, add); |
81 | 0 | if (!param.Valid(SimdTensorData8u, SimdTensorData8u)) |
82 | 0 | return NULL; |
83 | 0 | else if (SynetQuantizedMergedConvolutionCdc::Preferable(param)) |
84 | 0 | return new SynetQuantizedMergedConvolutionCdc(param); |
85 | 0 | else if (SynetQuantizedMergedConvolutionCd::Preferable(param)) |
86 | 0 | return new SynetQuantizedMergedConvolutionCd(param); |
87 | 0 | else if (SynetQuantizedMergedConvolutionDc::Preferable(param)) |
88 | 0 | return new SynetQuantizedMergedConvolutionDc(param); |
89 | 0 | return new Base::SynetQuantizedMergedConvolutionRef(param); |
90 | 0 | } |
91 | | } |
92 | | #endif |
93 | | } |