1 /*
2 * Copyright (C) 2010-2018 Arm Limited or its affiliates. All rights reserved.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 *
6 * Licensed under the Apache License, Version 2.0 (the License); you may
7 * not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
14 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19 #include "arm_math.h"
20 #include "arm_nnfunctions.h"
21
arm_nn_mult_q7_ref(q7_t * pSrcA,q7_t * pSrcB,q7_t * pDst,const uint16_t out_shift,uint32_t blockSize)22 void arm_nn_mult_q7_ref(q7_t * pSrcA,
23 q7_t * pSrcB,
24 q7_t * pDst,
25 const uint16_t out_shift,
26 uint32_t blockSize) {
27 uint16_t i;
28
29 for (i = 0; i < blockSize; i++)
30 {
31 q31_t product = pSrcA[i] * pSrcB[i];
32 #ifndef ARM_NN_TRUNCATE
33 pDst[i] = (q7_t)__SSAT((product + (0x1 << (out_shift - 1)))>>out_shift, 8);
34 #else
35 pDst[i] = (q7_t)__SSAT(product >> out_shift, 8);
36 #endif
37 }
38 }
39
arm_nn_mult_q15_ref(q15_t * pSrcA,q15_t * pSrcB,q15_t * pDst,const uint16_t out_shift,uint32_t blockSize)40 void arm_nn_mult_q15_ref(q15_t * pSrcA,
41 q15_t * pSrcB,
42 q15_t * pDst,
43 const uint16_t out_shift,
44 uint32_t blockSize) {
45 uint16_t i;
46
47 for (i = 0; i < blockSize; i++)
48 {
49 q31_t product = pSrcA[i] * pSrcB[i];
50 #ifndef ARM_NN_TRUNCATE
51 pDst[i] = (q15_t)__SSAT((product + (0x1 << (out_shift - 1)))>>out_shift, 16);
52 #else
53 pDst[i] = (q15_t)__SSAT(product >> out_shift, 16);
54 #endif
55
56
57 }
58 }
59