• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2021 The TensorFlow Authors. All Rights Reserved.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14# ==============================================================================
15"""Python TFLite metrics helper."""
16import os
17from typing import Optional, Text
18
19# pylint: disable=g-import-not-at-top
20if not os.path.splitext(__file__)[0].endswith(
21    os.path.join('tflite_runtime', 'metrics_portable')):
22  # This file is part of tensorflow package.
23  from tensorflow.lite.python.metrics import metrics_interface  # type: ignore
24else:
25  # This file is part of tflite_runtime package.
26  from tflite_runtime import metrics_interface  # type: ignore
27# pylint: enable=g-import-not-at-top
28
29
30class TFLiteMetrics(metrics_interface.TFLiteMetricsInterface):
31  """TFLite metrics helper."""
32
33  def __init__(self,
34               model_hash: Optional[Text] = None,
35               model_path: Optional[Text] = None) -> None:
36    pass
37
38  def increase_counter_debugger_creation(self):
39    pass
40
41  def increase_counter_interpreter_creation(self):
42    pass
43
44  def increase_counter_converter_attempt(self):
45    pass
46
47  def increase_counter_converter_success(self):
48    pass
49
50  def set_converter_param(self, name, value):
51    pass
52
53  def set_converter_error(self, error_data):
54    pass
55
56  def set_converter_latency(self, value):
57    pass
58
59
60class TFLiteConverterMetrics(TFLiteMetrics):
61  """Similar to TFLiteMetrics but specialized for converter."""
62
63  def __del__(self):
64    pass
65
66  def set_export_required(self):
67    pass
68
69  def export_metrics(self):
70    pass
71