Skip to content

Commit

Permalink
[luci] Support SignatureDef in pass value test (Samsung#7978)
Browse files Browse the repository at this point in the history
This will revise eval_result_verifier to read tflite SignatureDef and
use output tensor order according to the SignatureDef's outputs value.

ONE-DCO-1.0-Signed-off-by: SaeHie Park <[email protected]>
  • Loading branch information
seanshpark authored Nov 11, 2021
1 parent 47df282 commit 3d9daa7
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions compiler/luci-pass-value-test/eval_result_verifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@
interpreter = tf.lite.Interpreter(tflite_model)
interpreter.allocate_tensors()

# Read SignatureDef and get output tensor id orders for remapping
full_signatures = interpreter._get_full_signature_list()
full_signatures_outputs_remap = None
if full_signatures != None:
signature_serving_default = full_signatures.get('serving_default', None)
if signature_serving_default != None:
signature_outputs = signature_serving_default['outputs']

full_signatures_outputs_remap = []
for index, (key, value) in enumerate(signature_outputs.items()):
full_signatures_outputs_remap.append(value)

# Generate random input data.
num_inputs = len(interpreter.get_input_details())
for i in range(num_inputs):
Expand Down Expand Up @@ -64,6 +76,8 @@
output_shape = [int(i) for i in shape_file.read().split(',')]
luci_output_data = np.reshape(output_data, output_shape)
output_tensor = output_details["index"]
if full_signatures_outputs_remap != None:
output_tensor = full_signatures_outputs_remap[idx]
intp_output_data = interpreter.get_tensor(output_tensor)
try:
if output_details["dtype"] == np.uint8:
Expand Down

0 comments on commit 3d9daa7

Please sign in to comment.