xref: /aosp_15_r20/external/libopus/dnn/x86/x86_dnn_map.c (revision a58d3d2adb790c104798cd88c8a3aff4fa8b82cc)
1 /* Copyright (c) 2018-2019 Mozilla
2                  2023 Amazon */
3 /*
4    Redistribution and use in source and binary forms, with or without
5    modification, are permitted provided that the following conditions
6    are met:
7 
8    - Redistributions of source code must retain the above copyright
9    notice, this list of conditions and the following disclaimer.
10 
11    - Redistributions in binary form must reproduce the above copyright
12    notice, this list of conditions and the following disclaimer in the
13    documentation and/or other materials provided with the distribution.
14 
15    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16    ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18    A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
19    CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20    EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21    PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22    PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23    LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24    NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27 
28 #ifdef HAVE_CONFIG_H
29 #include "config.h"
30 #endif
31 
32 #include "x86/x86cpu.h"
33 #include "nnet.h"
34 
35 #if defined(OPUS_HAVE_RTCD)
36 
37 #if (defined(OPUS_X86_MAY_HAVE_SSE2) && !defined(OPUS_X86_PRESUME_AVX2))
38 
39 void (*const DNN_COMPUTE_LINEAR_IMPL[OPUS_ARCHMASK + 1])(
40          const LinearLayer *linear,
41          float *out,
42          const float *in
43 ) = {
44   compute_linear_c,                /* non-sse */
45   compute_linear_c,
46   MAY_HAVE_SSE2(compute_linear),
47   MAY_HAVE_SSE4_1(compute_linear), /* sse4.1  */
48   MAY_HAVE_AVX2(compute_linear)  /* avx  */
49 };
50 
51 void (*const DNN_COMPUTE_ACTIVATION_IMPL[OPUS_ARCHMASK + 1])(
52          float *output,
53          const float *input,
54          int N,
55          int activation
56 ) = {
57   compute_activation_c,                /* non-sse */
58   compute_activation_c,
59   MAY_HAVE_SSE2(compute_activation),
60   MAY_HAVE_SSE4_1(compute_activation), /* sse4.1  */
61   MAY_HAVE_AVX2(compute_activation)  /* avx  */
62 };
63 
64 void (*const DNN_COMPUTE_CONV2D_IMPL[OPUS_ARCHMASK + 1])(
65          const Conv2dLayer *conv,
66          float *out,
67          float *mem,
68          const float *in,
69          int height,
70          int hstride,
71          int activation
72 ) = {
73   compute_conv2d_c,                /* non-sse */
74   compute_conv2d_c,
75   MAY_HAVE_SSE2(compute_conv2d),
76   MAY_HAVE_SSE4_1(compute_conv2d), /* sse4.1  */
77   MAY_HAVE_AVX2(compute_conv2d)  /* avx  */
78 };
79 
80 #endif
81 
82 
83 #endif
84