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
This commit is contained in:
Jared Duke 2020-08-14 13:27:01 -07:00 committed by TensorFlower Gardener
parent 2f8072659a
commit ba337c699f
2 changed files with 4 additions and 2 deletions
tensorflow/lite

View File

@ -647,7 +647,8 @@ def gen_zipped_test_file(name, file, toco, flags):
cmd = (("$(locations :generate_examples) --toco $(locations {0}) " +
" --zip_to_output {1} {2} $(@D)").format(toco, file, flags)),
outs = [file],
tools = [
# `exec_tools` is required for PY3 compatibility in place of `tools`.
exec_tools = [
":generate_examples",
toco,
],

View File

@ -162,7 +162,8 @@ def format_result(t):
values = ["{:.9f}".format(value) for value in list(t.flatten())]
return ",".join(values)
else:
return _pywrap_string_util.SerializeAsHexString(t.flatten())
# SerializeAsHexString returns bytes in PY3, so decode if appropriate.
return _pywrap_string_util.SerializeAsHexString(t.flatten()).decode("utf-8")
def write_examples(fp, examples):