Skip to content

Commit ba337c6

Browse files
jdduketensorflower-gardener
authored andcommitted
Use exec_tools for TFLite generate_examples genrule
This is required for PY3 compatibility when the target is used as a tool dependency from a genrule. PiperOrigin-RevId: 326718880 Change-Id: I9ff432642564db9620711139351f196e782434fd
1 parent 2f80726 commit ba337c6

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

tensorflow/lite/build_def.bzl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,8 @@ def gen_zipped_test_file(name, file, toco, flags):
647647
cmd = (("$(locations :generate_examples) --toco $(locations {0}) " +
648648
" --zip_to_output {1} {2} $(@D)").format(toco, file, flags)),
649649
outs = [file],
650-
tools = [
650+
# `exec_tools` is required for PY3 compatibility in place of `tools`.
651+
exec_tools = [
651652
":generate_examples",
652653
toco,
653654
],

tensorflow/lite/testing/zip_test_utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ def format_result(t):
162162
values = ["{:.9f}".format(value) for value in list(t.flatten())]
163163
return ",".join(values)
164164
else:
165-
return _pywrap_string_util.SerializeAsHexString(t.flatten())
165+
# SerializeAsHexString returns bytes in PY3, so decode if appropriate.
166+
return _pywrap_string_util.SerializeAsHexString(t.flatten()).decode("utf-8")
166167

167168

168169
def write_examples(fp, examples):

0 commit comments

Comments
 (0)