id
stringlengths
15
25
source
stringclasses
1 value
chunk_index
int64
0
393k
token_count
int32
449
512
text
stringlengths
203
7.95k
combine_chunk_391900
combine.txt
391,900
512
(**kwargs) def __exit__(self, exc_type, exc_val, exc_tb): if self._traceme: self._traceme.Stop() def trace_wrapper(trace_name, **trace_kwargs): """Decorator alternative to `with Trace(): ...`. It's faster. Args: trace_name: The name of the trace event, or a callable to be traced, in which...
combine_chunk_391901
combine.txt
391,901
512
with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or im...
combine_chunk_391902
combine.txt
391,902
512
es': ['.*'], 'start_name_regexes': ['.*'], 'trim_name_regexes': [], 'show_name_regexes': ['.*'], 'hide_name_regexes': [], 'account_displayed_op_only': False, 'select': ['micros'], ...
combine_chunk_391903
combine.txt
391,903
512
s=0, min_cpu_micros=0, min_peak_bytes=0, min_residual_bytes=0, min_output_bytes=0): """Show operation time and memory consumptions. Args: min_micros: Only show profiler nodes with execution time no less than this. It sums accelerator and cpu times. ...
combine_chunk_391904
combine.txt
391,904
512
max_depth): """Set the maximum depth of display. The depth depends on profiling view. For 'scope' view, it's the depth of name scope hierarchy (tree), for 'op' view, it's the number of operation types (list), etc. Args: max_depth: Maximum depth of the data structure to display. Returns:...
combine_chunk_391905
combine.txt
391,905
512
erator_micros'] = min_accelerator_micros self._options['min_cpu_micros'] = min_cpu_micros return self def with_min_parameters(self, min_params): """Only show profiler nodes holding no less than 'min_params' parameters. 'Parameters' normally refers the weights of in TensorFlow variables. It refle...
combine_chunk_391906
combine.txt
391,906
512
OpLogProto proto. For example, user can select profiler nodes placed on gpu:0 with: `account_type_regexes=['.*gpu:0.*']` If none of a node's properties match the specified regexes, the node is not displayed nor accounted. Args: account_type_regexes: A list of regexes specifying the types. ...
combine_chunk_391907
combine.txt
391,907
512
as it's types match 'account_type_regexes', even if it is hidden from the output, say, by hide_name_regexes. Returns: self """ self._options['account_displayed_op_only'] = is_true return self def with_empty_output(self): """Do not generate side-effect outputs.""" self._option...
combine_chunk_391908
combine.txt
391,908
512
'] = copy.copy(attributes) return self def with_step(self, step): """Which profile step to use for profiling. The 'step' here refers to the step defined by `Profiler.add_step()` API. Args: step: When multiple steps of profiles are available, select which step's profile to use. If -1,...
combine_chunk_391909
combine.txt
391,909
512
) tf_export(v1=['profiler.OpLogProto'])(OpLogProto) <|file|>tensorflow/tensorflow/python/profiler/integration_test/mnist_testing_utils.py # Copyright 2020 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance wi...
combine_chunk_391910
combine.txt
391,910
512
x = tf.keras.layers.BatchNormalization()(x) x = tf.keras.layers.Flatten()(x) + tf.keras.layers.Flatten()(x) x = tf.keras.layers.Dense( 10, activation="softmax", kernel_initializer=tf.keras.initializers.TruncatedNormal(seed=99))( x) model = tf.keras.Model(inputs=inputs, outputs=x) ...
combine_chunk_391911
combine.txt
391,911
512
(graph): """Helper to serialize a graph to string.""" if graph: return graph.as_graph_def(add_shapes=True).SerializeToString() else: return b'' def _build_options(options): """Build tfprof.OptionsProto. Args: options: A dictionary of options. Returns: tfprof.OptionsProto. """ opts = ...
combine_chunk_391912
combine.txt
391,912
512
Proto. """ opts = tfprof_options_pb2.AdvisorOptionsProto() if options is None: return opts for checker, checker_opts in options.items(): checker_ops_pb = tfprof_options_pb2.AdvisorOptionsProto.CheckerOption() for k, v in checker_opts.items(): checker_ops_pb[k] = v opts.checkers[checker].Me...
combine_chunk_391913
combine.txt
391,913
512
_graph_string(self._graph), op_log.SerializeToString()) def __del__(self): print_mdl.DeleteProfiler() def add_step(self, step, run_meta): """Add statistics of a step. Args: step: int, An id used to group one or more different `run_meta` together. When profiling with the profile_...
combine_chunk_391914
combine.txt
391,914
512
sys.stderr.write('Cannot parse returned proto: %s.\n' % e) return tfprof_node def profile_name_scope(self, options): """Profile the statistics of graph nodes, organized by name scope. Args: options: A dict of options. See core/profiler/g3doc/options.md. Returns: a GraphNodeProto t...
combine_chunk_391915
combine.txt
391,915
512
run_meta=None, op_log=None, cmd='scope', options=_DEFAULT_PROFILE_OPTIONS): """Profile model. Tutorials and examples can be found in: https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/profiler/g3doc/python_api.md Args: graph: tf.Graph....
combine_chunk_391916
combine.txt
391,916
512
try: tfprof_node.ParseFromString(ret) except message.DecodeError as e: sys.stderr.write('Cannot parse returned proto: %s.\n' % e) elif cmd == 'graph' or cmd == 'scope': tfprof_node = tfprof_output_pb2.GraphNodeProto() ret = print_mdl.PrintModelAnalysis(graph_str, run_meta_str, ...
combine_chunk_391917
combine.txt
391,917
512
Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # ...
combine_chunk_391918
combine.txt
391,918
512
_tracer_level: Adjust device (TPU/GPU) tracing level. Values are: `1` - enabled, `0` - disabled [default value is `1`] delay_ms: Requests for all hosts to start profiling at a timestamp that is `delay_ms` away from the current time. `delay_ms` is in milliseconds. If zero, each host will start prof...
combine_chunk_391919
combine.txt
391,919
512
' 'server and profiler APIs at the same time.') raise errors.AlreadyExistsError(None, None, 'Another profiler is running.') except Exception: _profiler = None raise @tf_export('profiler.experimental.stop', v1=[]) def stop(save=True): ...
combine_chunk_391920
combine.txt
391,920
512
` can be provided to fine tune the profiler's behavior. """ self._logdir = logdir self._options = options def __enter__(self): start(self._logdir, self._options) def __exit__(self, typ, value, tb): stop() <|file|>tensorflow/tensorflow/python/profiler/profile_context.py # Copyright 201...
combine_chunk_391921
combine.txt
391,921
512
debug: tracing step: %d\n' % step) # Enable tracing, perform auto profiling or auto dump. if not run_metadata: run_metadata = config_pb2.RunMetadata() if not options: options = config_pb2.RunOptions( trace_level=config_pb2.RunOptions.FULL_TRACE) old_t...
combine_chunk_391922
combine.txt
391,922
512
(100, 200, 3), dump_steps=[200]) as pctx: opts = tf.profiler.ProfileOptionBuilder.time_and_memory() pctx.add_auto_profiling('op', opts, [150, 200]) train_loop(). # Tracing only. with profile_context.tfprof.ProfileContext('/tmp/train_dir') as pctx: ...
combine_chunk_391923
combine.txt
391,923
512
_steps[:]) self._rng = random.Random(111) self._fetched = set() self._slow_path_steps = self._dump_steps | self._trace_steps self._trace_next_step = False self._dump_next_step = False self._step = 0 self._traced_steps = 0 self._auto_profiles = [] self._profiler = None self._view...
combine_chunk_391924
combine.txt
391,924
512
ables tracing and adds traces to profiler at next step.""" if not self._enabled: return self._trace_next_step = True self._slow_path_steps.add(self._step) def dump_next_step(self): """Enable tracing and dump profiles at next step.""" if not self._enabled: return self._dump_next_st...
combine_chunk_391925
combine.txt
391,925
512
dump_steps or self._dump_next_step): return if self._debug: sys.stderr.write('debug: dumping file at step: %d\n' % step) gfile.MakeDirs(self._profiler_dir) filename = os.path.join(compat.as_bytes(self._profiler_dir), compat.as_bytes('profile_%d' % step)) self.pro...
combine_chunk_391926
combine.txt
391,926
512
) return self else: return self def __exit__(self, exec_type, exec_value, exec_tb): if not self._enabled: return print_mdl.DeleteProfiler() setattr(session.BaseSession, 'run', self.old_run) setattr(session.BaseSession, '__init__', self.old_init) setattr(session.BaseSession...
combine_chunk_391927
combine.txt
391,927
512
'__version__', '__git_version__', '__compiler_version__', '__cxx11_abi_flag__', '__monolithic_build__', ]) # Expose symbols minus dunders, unless they are allowlisted above. # This is necessary to export our dunders. __all__ = [s for s in dir() if s in _exported_dunders or not s.startswith('_')] <...
combine_chunk_391928
combine.txt
391,928
512
"""Get Op properties.""" props = tf_item.TF_GetOpProperties(self.tf_item) properties = {} for key, values in props.items(): prop = [] for value in values: # TODO(petebu): Make this conversion to a dictionary be done in the C++ # wrapper for performance. prop.append( ...
combine_chunk_391929
combine.txt
391,929
512
tensorflow.python.grappler import cost_analyzer from tensorflow.python.grappler import tf_optimizer from tensorflow.python.platform import gfile from tensorflow.python.training import saver def get_metagraph(): """Constructs and returns a MetaGraphDef from the input file.""" with gfile.GFile(FLAGS.input) as inpu...
combine_chunk_391930
combine.txt
391,930
512
Input file path. Accept SavedModel, MetaGraphDef, and GraphDef in " "either binary or text format.") parser.add_argument( "--fetch", type=str, default=None, help="The names of the fetch node delimited by comma.") parser.add_argument( "--rewriter_config", type=str, def...
combine_chunk_391931
combine.txt
391,931
512
/grappler/_pywrap_cost_analyzer.pyi # Copyright 2023 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENS...
combine_chunk_391932
combine.txt
391,932
512
type device_properties_pb2.NamedDevice. If None, a device list will be created based on the spec of the local machine. """ self._tf_cluster = None self._generate_timeline = not disable_timeline if devices is None: self._tf_cluster = tf_cluster.TF_NewCluster(allow_soft_placement, ...
combine_chunk_391933
combine.txt
391,933
512
_DeterminePeakMemoryUsage(item.tf_item, self._tf_cluster) @contextlib.contextmanager def Provision(allow_soft_placement=True, disable_detailed_stats=True, disable_timeline=True, devices=None): cluster = Cluster(allow_soft_pl...
combine_chunk_391934
combine.txt
391,934
512
(arg0: str, arg1: int) -> None: ... <|file|>tensorflow/tensorflow/python/grappler/_pywrap_model_analyzer.pyi # Copyright 2023 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obt...
combine_chunk_391935
combine.txt
391,935
512
arsed = parser.parse_known_args() app.run(main=main, argv=[sys.argv[0]] + unparsed) <|file|>tensorflow/tensorflow/python/grappler/model_analyzer.py # Copyright 2017 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in c...
combine_chunk_391936
combine.txt
391,936
512
import _pywrap_tf_optimizer as tf_opt from tensorflow.python.grappler import cluster as gcluster _OPTIMIZE_GRAPH_CLUSTER_LOCK = threading.Lock() is_oss = True # Updated by copybara. def OptimizeGraph(config_proto, metagraph, verbose=True, graph_id=b'graph_to_op...
combine_chunk_391937
combine.txt
391,937
512
have run yet. cluster.Shutdown() if is_oss: out_graph = graph_pb2.GraphDef.FromString(out_graph) return out_graph <|file|>tensorflow/tensorflow/python/grappler/cost_analyzer.py # Copyright 2017 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "Licens...
combine_chunk_391938
combine.txt
391,938
512
specified. Returns: A string with the formatted memory usage. """ if cluster is None: cluster = gcluster.Cluster( disable_detailed_stats=True, disable_timeline=True) item = gitem.Item(metagraph) peak_usage = cluster.DeterminePeakMemoryUsage(item) report = "" for device, snapshot in peak...
combine_chunk_391939
combine.txt
391,939
512
1: bool) -> Cluster: ... def TF_NewVirtualCluster(arg0: list[bytes]) -> Cluster: ... def TF_ShutdownCluster(arg0: Cluster) -> None: ... <|file|>tensorflow/tensorflow/c/experimental/saved_model/internal/testdata/gen_saved_models.py # Copyright 2020 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apa...
combine_chunk_391940
combine.txt
391,940
512
ypes.float32) @def_function.function( input_signature=[tensor_spec.TensorSpec((), dtypes.float32)]) def compute(self, value): return self.initialized_variable + value to_save = Module() saved_model.save( to_save, export_dir=os.path.join(base_dir, "UninitializedVariable")) def _gen_si...
combine_chunk_391941
combine.txt
391,941
512
ops from tensorflow.python.framework import tensor_spec from tensorflow.python.module import module from tensorflow.python.ops import io_ops from tensorflow.python.ops import lookup_ops from tensorflow.python.ops import variables from tensorflow.python.platform import test from tensorflow.python.saved_model import sav...
combine_chunk_391942
combine.txt
391,942
512
_spec.TensorSpec(shape=None, dtype=dtypes.string)]) def lookup(self, word): return self.table.lookup(word) def get_simple_session(): ops.disable_eager_execution() sess = session_lib.Session() variables.Variable(1.) sess.run(variables.global_variables_initializer()) return sess MODULE_CTORS = { "...
combine_chunk_391943
combine.txt
391,943
512
ed protos test data containing GraphDefs with lots of nodes and large nodes for Merger::Read and Merger::Merge. """ from collections.abc import Sequence import os from absl import app from absl import flags import numpy as np from tensorflow.python.compat import v2_compat from tensorflow.python.eager import def_fun...
combine_chunk_391944
combine.txt
391,944
512
.py # Copyright 2021 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
combine_chunk_391945
combine.txt
391,945
512
with tf.compat.v1.assert_integer. x_supported_dtypes = [ tf.float16, tf.float32, tf.float64, tf.int32, tf.int64, tf.string ] random_dtype_index = fh.get_int(min_int=0, max_int=5) x_dtype = x_supported_dtypes[random_dtype_index] x_shape = fh.get_int_list(min_length=0, max_length=6, min_int=0, max_int=10...
combine_chunk_391946
combine.txt
391,946
512
_MIN_INT = -10000 _MAX_INT = 10000 _MIN_FLOAT = -10000.0 _MAX_FLOAT = 10000.0 _MIN_LENGTH = 0 _MAX_LENGTH = 10000 # Max shape can be 8 in length and randomized from 0-8 without running into an # OOM error. _MIN_SIZE = 0 _MAX_SIZE = 8 _TF_DTYPES = [ tf.half, tf.float16, tf.float32, tf.float64, tf.bfloat16, tf....
combine_chunk_391947
combine.txt
391,947
512
(self, min_length=_MIN_LENGTH, max_length=_MAX_LENGTH, min_int=_MIN_INT, max_int=_MAX_INT): """Consume a signed integer list with given constraints. Args: min_length: The minimum length of the list. max_length: The maximum ...
combine_chunk_391948
combine.txt
391,948
512
[index] def get_string(self, byte_count=_MAX_INT): """Consume a string with given constraints based on a consumed bool. Args: byte_count: Byte count that defaults to _MAX_INT. Returns: Consumed string based on input bytes and constraints. """ return self.fdp.ConsumeString(byte_count...
combine_chunk_391949
combine.txt
391,949
512
License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on...
combine_chunk_391950
combine.txt
391,950
512
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== """This is a Python API fuzzer for tf.constant.""" import athe...
combine_chunk_391951
combine.txt
391,951
512
__ == "__main__": main() <|file|>tensorflow/tensorflow/security/fuzzing/py/annotation_types.py # Copyright 2023 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy o...
combine_chunk_391952
combine.txt
391,952
512
Float4e2m1fn = _create_dtype_wrapper("Float4e2m1fn", _dtypes.float4_e2m1fn) Float16 = _create_dtype_wrapper("Float16", _dtypes.float16) Float32 = _create_dtype_wrapper("Float32", _dtypes.float32) Float64 = _create_dtype_wrapper("Float64", _dtypes.float64) Half = _create_dtype_wrapper("Half", _dtypes.float16) Int2 = _cr...
combine_chunk_391953
combine.txt
391,953
512
obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for...
combine_chunk_391954
combine.txt
391,954
512
FuzzingHelper # pyrefly: ignore[missing-import] import tensorflow as tf @atheris.instrument_func def TestOneInput(input_bytes): """Test randomized integer fuzzing input for tf.raw_ops.DataFormatVecPermute.""" fh = FuzzingHelper(input_bytes) dtype = fh.get_tf_dtype() # Max shape can be 8 in length and ran...
combine_chunk_391955
combine.txt
391,955
512
fuzzing input for tf.raw_ops.Acosh.""" fh = FuzzingHelper(data) # tf.raw_ops.Acos takes tf.bfloat16, tf.half, tf.float32, tf.float64, # tf.complex64, tf.complex128, but get_random_numeric_tensor only generates # tf.float16, tf.float32, tf.float64, tf.int32, tf.int64 dtype = fh.get_tf_dtype(allowed_set=[tf.f...
combine_chunk_391956
combine.txt
391,956
512
is.Setup(sys.argv, TestOneInput, enable_python_coverage=True) atheris.Fuzz() if __name__ == "__main__": main() <|file|>tensorflow/tensorflow/security/fuzzing/raggedCountSparseOutput_fuzz.py # Copyright 2021 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "Lice...
combine_chunk_391957
combine.txt
391,957
512
software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ==============================================================...
combine_chunk_391958
combine.txt
391,958
512
atheris.Setup(sys.argv, TestOneInput, enable_python_coverage=True) atheris.Fuzz() if __name__ == "__main__": main() <|file|>tensorflow/tensorflow/lite/kernels/pywrap_variable_ops.pyi # Copyright 2023 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License");...
combine_chunk_391959
combine.txt
391,959
512
either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== def TFLRegisterListOps(arg0: int) -> None: ... <|file|>tensorflow/tensorflow/lite/kernels/gradient/pywrap_...
combine_chunk_391960
combine.txt
391,960
512
.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License....
combine_chunk_391961
combine.txt
391,961
512
= "" for i in range(len(lst)): if i % 2 == 0: out_str += "shape:" else: out_str += "type:" out_str += lst[i] out_str += "," return out_str[:-1] def get_operator_type(op_name, conversion_log): if op_name in conversion_log.built_in_ops: return "BUILT-IN" elif op_name in conversi...
combine_chunk_391962
combine.txt
391,962
512
post_training_quant_enabled: A boolean, whether post-training quantization is enabled. dot_before: A string, the dot representation of the model before the conversion. dot_after: A string, the dot representation of the model after the conversion. toco_err_log: A string, the lo...
combine_chunk_391963
combine.txt
391,963
512
_after.op_list: supported_type = get_operator_type(op, toco_conversion_log_after) post_op_profile += ("<tr><td>" + op + "</td><td>" + supported_type + "</td></tr>") html_dict["<!--REPEAT_TABLE1_ROWS-->"] = pre_op_profile html_dict["<!--REPEAT_TABLE2_ROWS-->"] = post_op_pro...
combine_chunk_391964
combine.txt
391,964
512
Failed to generate HTML: file '{0}' doesn't exist.".format( template_filename)) toco_log_before_path = os.path.join(conversion_log_dir, "toco_log_before.pb") toco_log_after_path = os.path.join(conversion_log_dir, "toco_log_after.pb") dot_before_path = os.path.join(conversion_log_dir, "toco_tf_graph.dot")...
combine_chunk_391965
combine.txt
391,965
512
process_coco_minival.py # Copyright 2019 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Un...
combine_chunk_391966
combine.txt
391,966
512
to a list of detection dicts, with each mapping: 'category_id' to COCO category id (starting with 1) & 'bbox' to a list of dimension-normalized [top, left, bottom, right] bounding-box values. """ # Read JSON data into a dict. with open(instances_file, 'r') as annotation_dump: data_dic...
combine_chunk_391967
combine.txt
391,967
512
['bbox'] # bbox format is [x, y, width, height] # Refer: http://cocodataset.org/#format-data top = bbox[1] left = bbox[0] bottom = top + bbox[3] right = left + bbox[2] if (top > image_data_dict['height'] or left > image_data_dict['width'] or bottom > image_data_dict['height'] or righ...
combine_chunk_391968
combine.txt
391,968
512
] object_instance.bounding_box.normalized_bottom = detection_dict['bbox'][2] object_instance.bounding_box.normalized_right = detection_dict['bbox'][3] object_instance.class_id = detection_dict['category_id'] # Copy image. shutil.copy2( os.path.join(images_folder_path, image_dict['file_...
combine_chunk_391969
combine.txt
391,969
512
under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== """Too...
combine_chunk_391970
combine.txt
391,970
512
rc_dir): raise ValueError('Invalid path to ilsvrc_dir') if not path.exists(_validation_file_path(ilsvrc_dir)): raise ValueError('Invalid path to ilsvrc_dir, cannot find validation file.') if not path.exists(_synset_array_path(ilsvrc_dir)): raise ValueError( 'Invalid path to ilsvrc_dir, cannot fi...
combine_chunk_391971
combine.txt
391,971
512
'Full path name to the output stripped TFLite file.') flags.mark_flag_as_required('input_tflite_file') flags.mark_flag_as_required('output_tflite_file') def main(_): model = flatbuffer_utils.read_model(FLAGS.input_tflite_file) flatbuffer_utils.strip_strings(model) flatbuffer_utils.write_model(model, FLAGS.out...
combine_chunk_391972
combine.txt
391,972
512
.mark_flag_as_required('input_tflite_file') flags.mark_flag_as_required('output_tflite_file') def main(_): buffers_to_skip = FLAGS.buffers_to_skip ops_to_skip = [op.upper() for op in FLAGS.ops_to_skip] ops_operands_to_skip = {} for op_operands_to_skip in FLAGS.ops_operands_to_skip: op_name, indices = op_o...
combine_chunk_391973
combine.txt
391,973
512
.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitat...
combine_chunk_391974
combine.txt
391,974
512
denylisted_ops: Optional[List[str]] = None, denylisted_nodes: Optional[List[str]] = None, fully_quantize: bool = False) -> None: """Initializes debugger options. Args: layer_debug_metrics: a dict to specify layer debug functions {function_name_str: function} where t...
combine_chunk_391975
combine.txt
391,975
512
TensorFlow Lite debug mode models. This can run the TensorFlow Lite converted models equipped with debug ops and collect debug information. This debugger calculates statistics from user-defined post-processing functions as well as default ones. """ def __init__(self, quant_debug_model_path: ...
combine_chunk_391976
combine.txt
391,976
512
ibrated_model = self.converter.convert() # Converter should be already set up with all options self._init_from_converter( self._debug_options, self.converter, self.calibrated_model, float_model=self.float_model) else: self._quant_interpreter = _interpreter.I...
combine_chunk_391977
combine.txt
391,977
512
: bool) -> bytes: if not self.converter: raise ValueError('No converter found, use this function with the ' 'converter option in the constructor.') return convert.mlir_quantize( self.calibrated_model, disable_per_channel=self.converter._experimental_disable_per_chan...
combine_chunk_391978
combine.txt
391,978
512
, denylisted_nodes=options.denylisted_nodes) self._quant_interpreter = _interpreter.Interpreter( model_content=self.quant_model) self._float_interpreter = None if float_model is not None: self._float_interpreter = _interpreter.Interpreter( model_content=float_model) def _s...
combine_chunk_391979
combine.txt
391,979
512
refly: ignore[bad-index] for metric_name, metric_fn in self._layer_debug_metrics.items(): layer_statistics[tensor_name][metric_name].append(metric_fn(diffs)) if self._debug_options.layer_direct_compare_metrics is not None: for tensor_detail in self._get_numeric_verify_tensor_details(): ...
combine_chunk_391980
combine.txt
391,980
512
_interpreter.invoke() quant_tensor_data = self._get_output_tensors(self._quant_interpreter) # Run float model if it's initialized. float_tensor_data = [] if self._float_interpreter: self._set_input_tensors( self._float_interpreter, tensor_data, initialize) self._floa...
combine_chunk_391981
combine.txt
391,981
512
]: """Returns output tensors of given TFLite model Interpreter. Args: interpreter: a tf.lite.Interpreter object with allocated tensors. Returns: a list of numpy arrays representing output tensor results. """ outputs = [] for output_detail in interpreter.get_output_details(): ...
combine_chunk_391982
combine.txt
391,982
512
statistics into file, in csv format. Args: file: file, or file-like object to write. """ # order of `fields` is the order of fields in csv. fields = ['op_name', 'tensor_idx'] + list(self._layer_debug_metrics.keys()) if self._debug_options.layer_direct_compare_metrics is not None: field...
combine_chunk_391983
combine.txt
391,983
512
wrap_modify_model_interface from tensorflow.lite.tools.optimize.python import modify_model_interface_constants as mmi_constants def _parse_type_to_int(dtype, flag): """Converts a tflite type to it's integer representation. Args: dtype: tf.DType representing the inference type. flag: str representing the ...
combine_chunk_391984
combine.txt
391,984
512
the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is dis...
combine_chunk_391985
combine.txt
391,985
512
mi_constants.STR_TO_TFLITE_TYPES[FLAGS.input_type] output_type = mmi_constants.STR_TO_TFLITE_TYPES[FLAGS.output_type] mmi_lib.modify_model_interface(FLAGS.input_tflite_file, FLAGS.output_tflite_file, input_type, output_type) print('Successfully m...
combine_chunk_391986
combine.txt
391,986
512
to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ===============================================...
combine_chunk_391987
combine.txt
391,987
512
def __init__(self, value: int) -> None: ... def __eq__(self, other: object) -> bool: ... def __hash__(self) -> int: ... def __index__(self) -> int: ... def __int__(self) -> int: ... def __ne__(self, other: object) -> bool: ... @property def name(self) -> str: ... @property def value...
combine_chunk_391988
combine.txt
391,988
512
file. """ if not gfile.Exists(input_tflite_file): raise RuntimeError('Input file not found at %r\n' % input_tflite_file) with gfile.GFile(input_tflite_file, 'rb') as input_file_handle: model_bytearray = bytearray(input_file_handle.read()) return read_model_from_bytearray(model_bytearray) def read_mod...
combine_chunk_391989
combine.txt
391,989
512
which will grow automatically if needed builder = flatbuffers.Builder(1024) model_offset = model_object.Pack(builder) builder.Finish(model_offset, file_identifier=_TFLITE_FILE_IDENTIFIER) model_bytearray = bytes(builder.Output()) model_bytearray = model_bytearray + extra_buffer return model_bytearray def...
combine_chunk_391990
combine.txt
391,990
512
generator (default value is 0). buffers_to_skip: The list of buffer indices to skip. The weights in these buffers are left unmodified. """ # The input to the random seed generator. The default value is 0. random.seed(random_seed) # Parse model buffers which store the model weights buffers = model...
combine_chunk_391991
combine.txt
391,991
512
input tflite model. map_custom_op_renames: A mapping from old to new custom op names. """ for op_code in model.operatorCodes: if op_code.customCode: op_code_str = op_code.customCode.decode('ascii') if op_code_str in map_custom_op_renames: op_code.customCode = map_custom_op_renames[op_co...
combine_chunk_391992
combine.txt
391,992
512
)) # Convert to hex values = [int(x, base=16) for x in values_text] model_bytearray.extend(values) return bytes(model_bytearray) def xxd_output_to_object(input_cc_file): """Converts xxd output C++ source file to object. Args: input_cc_file: Full path name to th C++ source file dumped by...
combine_chunk_391993
combine.txt
391,993
512
_endiness: The destined endianness format of the buffers in model. """ if model is None: return # Get all the constant buffers, byte swapping them as per their data types buffer_swapped = [] types_of_16_bits = [ schema_fb.TensorType.FLOAT16, schema_fb.TensorType.INT16, schema_fb.TensorTy...
combine_chunk_391994
combine.txt
391,994
512
byte swapped to to_endiness format. """ if tflite_model is None: return None # Load TFLite Flatbuffer byte array into an object. model = convert_bytearray_to_object(tflite_model) # Byte swapping the constant buffers as per their data types byte_swap_tflite_model_obj(model, from_endiness, to_endine...
combine_chunk_391995
combine.txt
391,995
512
): raise err if isinstance(op, schema_fb.Operator): if not is_opt_1_type: enum_val = getattr(schema_fb.BuiltinOptions2, base_type_name) opts_creator = schema_fb.BuiltinOptions2Creator raw_ops = op.BuiltinOptions2() actual_enum_val = op.BuiltinOptions2Type() else: enum_val...
combine_chunk_391996
combine.txt
391,996
512
long_description='\n'.join(DOCLINES[2:]), url='https://developers.google.com/edge/litert', author='Google, LLC', author_email='packages@tensorflow.org', license='Apache 2.0', include_package_data=True, has_ext_modules=lambda: True, keywords='tflite tensorflow tensor machine learning', c...
combine_chunk_391997
combine.txt
391,997
512
to zip file.") flags.DEFINE_string("file_directory", None, "Path to the files to be zipped.") def main(_): with zipfile.ZipFile(FLAGS.export_zip_path, mode="w") as zf: for root, _, files in os.walk(FLAGS.file_directory): for f in files: if f.endswith(".java"): zf.write(os.path.join(root...
combine_chunk_391998
combine.txt
391,998
512
ite_file) if __name__ == '__main__': app.run(main) <|file|>tensorflow/tensorflow/lite/tools/visualize.py #!/usr/bin/env python # Copyright 2017 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the ...
combine_chunk_391999
combine.txt
391,999
512
px; } .tooltip {color: blue;} .tooltip .tooltipcontent { visibility: hidden; color: black; background-color: yellow; padding: 5px; border-radius: 4px; position: absolute; z-index: 1; } .tooltip:hover .tooltipcontent { visibility: visible; } .edges line { stroke: #333; } text { fo...