Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
maximum_minimum.h
00001 /* Copyright 2017 The TensorFlow Authors. All Rights Reserved. 00002 00003 Licensed under the Apache License, Version 2.0 (the "License"); 00004 you may not use this file except in compliance with the License. 00005 You may obtain a copy of the License at 00006 00007 http://www.apache.org/licenses/LICENSE-2.0 00008 00009 Unless required by applicable law or agreed to in writing, software 00010 distributed under the License is distributed on an "AS IS" BASIS, 00011 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00012 See the License for the specific language governing permissions and 00013 limitations under the License. 00014 ==============================================================================*/ 00015 #ifndef TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_MAXIMUM_MINIMUM_H_ 00016 #define TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_MAXIMUM_MINIMUM_H_ 00017 00018 #include "tensorflow/lite/kernels/internal/common.h" 00019 #include "tensorflow/lite/kernels/internal/types.h" 00020 00021 namespace tflite { 00022 namespace reference_ops { 00023 00024 template <typename T, typename Op> 00025 void MaximumMinimumBroadcast4DSlow(const RuntimeShape& unextended_input1_shape, 00026 const T* input1_data, 00027 const RuntimeShape& unextended_input2_shape, 00028 const T* input2_data, 00029 const RuntimeShape& unextended_output_shape, 00030 T* output_data, Op op) { 00031 TFLITE_DCHECK_LE(unextended_input1_shape.DimensionsCount(), 4); 00032 TFLITE_DCHECK_LE(unextended_input2_shape.DimensionsCount(), 4); 00033 TFLITE_DCHECK_LE(unextended_output_shape.DimensionsCount(), 4); 00034 const RuntimeShape output_shape = 00035 RuntimeShape::ExtendedShape(4, unextended_output_shape); 00036 00037 NdArrayDesc<4> desc1; 00038 NdArrayDesc<4> desc2; 00039 NdArrayDescsForElementwiseBroadcast(unextended_input1_shape, 00040 unextended_input2_shape, &desc1, &desc2); 00041 00042 for (int b = 0; b < output_shape.Dims(0); ++b) { 00043 for (int y = 0; y < output_shape.Dims(1); ++y) { 00044 for (int x = 0; x < output_shape.Dims(2); ++x) { 00045 for (int c = 0; c < output_shape.Dims(3); ++c) { 00046 auto out_idx = Offset(output_shape, b, y, x, c); 00047 auto in1_idx = SubscriptToIndex(desc1, b, y, x, c); 00048 auto in2_idx = SubscriptToIndex(desc2, b, y, x, c); 00049 auto in1_val = input1_data[in1_idx]; 00050 auto in2_val = input2_data[in2_idx]; 00051 output_data[out_idx] = op(in1_val, in2_val); 00052 } 00053 } 00054 } 00055 } 00056 } 00057 00058 } // namespace reference_ops 00059 } // namespace tflite 00060 00061 #endif // TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_MAXIMUM_MINIMUM_H_
Generated on Wed Jul 13 2022 16:03:35 by
