Subversion Repositories ScreenTimer

Rev

Blame | Last modification | View Log | Download | RSS feed

  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 "ref_functions.h"
  20.  
  21. void arm_fully_connected_q15_ref(const q15_t * pV,  // pointer to vector
  22.                                  const q15_t * pM,  // pointer to matrix
  23.                                  const uint16_t dim_vec,    // length of the vector
  24.                                  const uint16_t num_of_rows,    // numCol of A
  25.                                  const uint16_t bias_shift, // amount of left-shift for bias
  26.                                  const uint16_t out_shift,  // amount of right-shift for output
  27.                                  const q15_t * bias, q15_t * pOut,  // output operand
  28.                                  q15_t * vec_buffer)
  29. {
  30.     for (int i = 0; i < num_of_rows; i++)
  31.     {
  32. #ifndef ARM_NN_TRUNCATE
  33.         int       ip_out = (bias[i] << bias_shift) + (0x1 << (out_shift - 1));
  34. #else
  35.         int       ip_out = bias[i] << bias_shift;
  36. #endif
  37.         for (int j = 0; j < dim_vec; j++)
  38.         {
  39.             ip_out += pV[j] * pM[i * dim_vec + j];
  40.         }
  41.         pOut[i] = (q15_t) __SSAT((ip_out >> out_shift), 16);
  42.     }
  43. }
  44.