Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/tensorflow/lite/python/wrap_toco.py: 60%
15 statements
« prev ^ index » next coverage.py v7.4.0, created at 2024-01-03 07:57 +0000
« prev ^ index » next coverage.py v7.4.0, created at 2024-01-03 07:57 +0000
1# Copyright 2019 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"""Wraps toco interface with python lazy loader."""
16# We need to import pywrap_tensorflow prior to the toco wrapper.
17# pylint: disable=invalid-import-order,g-bad-import-order
18from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
19from tensorflow.python import _pywrap_toco_api
21# TODO(b/137402359): Remove lazy loading wrapper
24def wrapped_toco_convert(model_flags_str, toco_flags_str, input_data_str,
25 debug_info_str, enable_mlir_converter):
26 """Wraps TocoConvert with lazy loader."""
27 return _pywrap_toco_api.TocoConvert(
28 model_flags_str,
29 toco_flags_str,
30 input_data_str,
31 False, # extended_return
32 debug_info_str,
33 enable_mlir_converter)
36def wrapped_experimental_mlir_quantize(
37 input_data_str, disable_per_channel, fully_quantize, inference_type,
38 input_data_type, output_data_type, enable_numeric_verify,
39 enable_whole_model_verify, denylisted_ops, denylisted_nodes,
40 enable_variable_quantization):
41 """Wraps experimental mlir quantize model."""
42 return _pywrap_toco_api.ExperimentalMlirQuantizeModel(
43 input_data_str, disable_per_channel, fully_quantize, inference_type,
44 input_data_type, output_data_type, enable_numeric_verify,
45 enable_whole_model_verify, denylisted_ops, denylisted_nodes,
46 enable_variable_quantization)
49def wrapped_experimental_mlir_sparsify(input_data_str):
50 """Wraps experimental mlir sparsify model."""
51 return _pywrap_toco_api.ExperimentalMlirSparsifyModel(input_data_str)
54def wrapped_register_custom_opdefs(custom_opdefs_list):
55 """Wraps RegisterCustomOpdefs with lazy loader."""
56 return _pywrap_toco_api.RegisterCustomOpdefs(custom_opdefs_list)
59def wrapped_retrieve_collected_errors():
60 """Wraps RetrieveCollectedErrors with lazy loader."""
61 return _pywrap_toco_api.RetrieveCollectedErrors()
64def wrapped_flat_buffer_file_to_mlir(model, input_is_filepath):
65 """Wraps FlatBufferFileToMlir with lazy loader."""
66 return _pywrap_toco_api.FlatBufferToMlir(model, input_is_filepath)