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.
tensor_utils.cc
00001 /* Copyright 2019 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 00016 #include "tensorflow/lite/core/api/tensor_utils.h" 00017 00018 #include <string.h> 00019 00020 namespace tflite { 00021 00022 TfLiteStatus ResetVariableTensor(TfLiteTensor* tensor) { 00023 if (!tensor->is_variable) { 00024 return kTfLiteOk; 00025 } 00026 // TODO(b/115961645): Implement - If a variable tensor has a buffer, reset it 00027 // to the value of the buffer. 00028 int value = 0; 00029 if (tensor->type == kTfLiteInt8) { 00030 value = tensor->params.zero_point; 00031 } 00032 // TODO(b/139446230): Provide a platform header to better handle these 00033 // specific scenarios. 00034 #if __ANDROID__ || defined(__x86_64__) || defined(__i386__) || \ 00035 defined(__i386) || defined(__x86__) || defined(__X86__) || \ 00036 defined(_X86_) || defined(_M_IX86) || defined(_M_X64) 00037 memset(tensor->data.raw, value, tensor->bytes); 00038 #else 00039 char* raw_ptr = tensor->data.raw; 00040 for (int i = 0; i < tensor->bytes; ++i) { 00041 *raw_ptr = value; 00042 raw_ptr++; 00043 } 00044 #endif 00045 return kTfLiteOk; 00046 } 00047 00048 } // namespace tflite
Generated on Wed Jul 13 2022 16:03:36 by
1.7.2