2 * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved
3 * Copyright 2017 The TensorFlow Authors. All Rights Reserved.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 #ifndef __NNFW_CKER_TENSOR_UTILS_H__
19 #define __NNFW_CKER_TENSOR_UTILS_H__
21 #include "cker/Types.h"
22 #include "cker/PortableTensorUtils.h"
23 #include "cker/NeonTensorUtils.h"
24 #include "cker/neon/neon_check.h"
34 void VectorBatchVectorAssign(const float *vector, int v_size, int n_batch, float *batch_vector)
36 PortableVectorBatchVectorAssign(vector, v_size, n_batch, batch_vector);
39 bool IsZeroVector(const float *vector, int v_size)
41 return NEON_OR_PORTABLE(IsZeroVector, vector, v_size);
44 void ApplyActivationToVector(const float *vector, int v_size,
45 FusedActivationFunctionType activation, float *result)
47 PortableApplyActivationToVector(vector, v_size, activation, result);
50 void SymmetricQuantizeFloats(const float *values, const int size, int8_t *quantized_values,
51 float *min, float *max, float *scaling_factor)
53 return NEON_OR_PORTABLE(SymmetricQuantizeFloats, values, size, quantized_values, min, max,
57 void MatrixBatchVectorMultiplyAccumulate(const int8_t *matrix, const int m_rows, const int m_cols,
58 const int8_t *vector, const float *scaling_factors,
59 int n_batch, float *result, int result_stride)
61 NEON_OR_PORTABLE(MatrixBatchVectorMultiplyAccumulate, matrix, m_rows, m_cols, vector,
62 scaling_factors, n_batch, result, result_stride);
65 void MatrixBatchVectorMultiplyAccumulate(const float *matrix, int m_rows, int m_cols,
66 const float *vector, int n_batch, float *result,
69 NEON_OR_PORTABLE(MatrixBatchVectorMultiplyAccumulate, matrix, m_rows, m_cols, vector, n_batch,
70 result, result_stride);
73 void MatrixBatchVectorMultiplyAccumulate(const int8_t *matrix, const int m_rows, const int m_cols,
74 const int8_t *vectors, const float *scaling_factors,
75 int n_batch, int32_t *scratch, float *result,
78 NEON_OR_PORTABLE(MatrixBatchVectorMultiplyAccumulate, matrix, m_rows, m_cols, vectors,
79 scaling_factors, n_batch, scratch, result, result_stride);
82 void ZeroVector(float *vector, int v_size) { PortableZeroVector(vector, v_size); }
87 #endif // __NNFW_CKER_TENSOR_UTILS_H__