• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2017 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include "Operations.h"
18 #include "CpuOperationUtils.h"
19 
20 #include "tensorflow/contrib/lite/kernels/internal/optimized/optimized_ops.h"
21 
22 namespace android {
23 namespace nn {
24 
l2normFloat32(const float * inputData,const Shape & inputShape,float * outputData,const Shape & outputShape)25 bool l2normFloat32(const float* inputData, const Shape& inputShape,
26                    float* outputData, const Shape& outputShape) {
27     tflite::optimized_ops::L2Normalization<tflite::FusedActivationFunctionType::kNone>(
28             inputData, convertShapeToDims(inputShape),
29             outputData, convertShapeToDims(outputShape));
30 
31     return true;
32 }
33 
l2normQuant8(const uint8_t * inputData,const Shape & inputShape,uint8_t * outputData,const Shape & outputShape)34 bool l2normQuant8(const uint8_t* inputData, const Shape& inputShape,
35                   uint8_t* outputData, const Shape& outputShape) {
36     tflite::optimized_ops::L2Normalization(
37             inputData, convertShapeToDims(inputShape),
38             inputShape.offset,
39             outputData, convertShapeToDims(outputShape));
40 
41     return true;
42 }
43 
localResponseNormFloat32(const float * inputData,const Shape & inputShape,int32_t radius,float bias,float alpha,float beta,float * outputData,const Shape & outputShape)44 bool localResponseNormFloat32(const float* inputData, const Shape& inputShape,
45                               int32_t radius, float bias, float alpha, float beta,
46                               float* outputData, const Shape& outputShape) {
47     tflite::optimized_ops::LocalResponseNormalization(
48             inputData, convertShapeToDims(inputShape),
49             radius, bias, alpha, beta,
50             outputData, convertShapeToDims(outputShape));
51 
52     return true;
53 }
54 }  // namespace nn
55 }  // namespace android
56