1# Lint as: python2, python3 2# Copyright 2021 The TensorFlow Authors. All Rights Reserved. 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"""Stub to make pywrap metrics wrapper accessible.""" 17 18from __future__ import absolute_import 19from __future__ import division 20from __future__ import print_function 21 22from tensorflow.lite.python import wrap_toco 23from tensorflow.lite.python.metrics_wrapper import converter_error_data_pb2 24from tensorflow.lite.python.metrics_wrapper._pywrap_tensorflow_lite_metrics_wrapper import MetricsWrapper # pylint: disable=unused-import 25 26 27def retrieve_collected_errors(): 28 """Returns and clears the list of collected errors in ErrorCollector. 29 30 The RetrieveCollectedErrors function in C++ returns a list of serialized proto 31 messages. This function will convert them to ConverterErrorData instances. 32 33 Returns: 34 A list of ConverterErrorData. 35 """ 36 serialized_message_list = wrap_toco.wrapped_retrieve_collected_errors() 37 return list( 38 map(converter_error_data_pb2.ConverterErrorData.FromString, 39 serialized_message_list)) 40