MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / build_tflite_inputs

Function build_tflite_inputs

tensorflow/lite/testing/generate_examples_lib.py:435–459  ·  view source on GitHub ↗
(tflite_model_binary)

Source from the content-addressed store, hash-verified

433 continue
434
435 def build_tflite_inputs(tflite_model_binary):
436 # Build input values and output values of the given tflite model.
437 interpreter = tf.lite.Interpreter(model_content=tflite_model_binary)
438 interpreter.allocate_tensors()
439
440 input_details = interpreter.get_input_details()
441 input_values = []
442 for input_detail in input_details:
443 # TODO(yunluli): Set proper min max value according to dtype.
444 input_value = create_tensor_data(
445 input_detail["dtype"],
446 input_detail["shape"],
447 min_value=0,
448 max_value=255)
449 interpreter.set_tensor(input_detail["index"], input_value)
450 input_values.append(input_value)
451
452 interpreter.invoke()
453
454 output_details = interpreter.get_output_details()
455 output_values = []
456 for output_detail in output_details:
457 output_values.append(interpreter.get_tensor(output_detail["index"]))
458
459 return input_values, output_values
460
461 def build_example(label, param_dict_real):
462 """Build the model with parameter values set in param_dict_real.

Callers 1

build_exampleFunction · 0.85

Calls 9

allocate_tensorsMethod · 0.95
get_input_detailsMethod · 0.95
set_tensorMethod · 0.95
invokeMethod · 0.95
get_output_detailsMethod · 0.95
get_tensorMethod · 0.95
create_tensor_dataFunction · 0.85
InterpreterMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected