Add an option to tf_gen_op_wrapper_py to make it able to run the genrule

locally.

PiperOrigin-RevId: 185439892
This commit is contained in:
Guangda Lai 2018-02-12 14:52:47 -08:00 committed by TensorFlower Gardener
parent 5760acee1e
commit 41402e7d92

View File

@ -498,6 +498,9 @@ def tf_gen_op_wrappers_cc(name,
# is invalid to specify both "hidden" and "op_whitelist".
# cc_linkopts: Optional linkopts to be added to tf_cc_binary that contains the
# specified ops.
# gen_locally: if True, the genrule to generate the Python library will be run
# without sandboxing. This would help when the genrule depends on symlinks
# which may not be supported in the sandbox.
def tf_gen_op_wrapper_py(name,
out=None,
hidden=None,
@ -508,7 +511,8 @@ def tf_gen_op_wrapper_py(name,
generated_target_name=None,
op_whitelist=[],
cc_linkopts=[],
api_def_srcs=[]):
api_def_srcs=[],
gen_locally=False):
if (hidden or hidden_file) and op_whitelist:
fail('Cannot pass specify both hidden and op_whitelist.')
@ -563,6 +567,7 @@ def tf_gen_op_wrapper_py(name,
outs=[out],
srcs=api_def_srcs + [hidden_file],
tools=[tool_name] + tf_binary_additional_srcs(),
local = (1 if gen_locally else 0),
cmd=("$(location " + tool_name + ") " + api_def_args_str +
" @$(location " + hidden_file + ") " +
("1" if require_shape_functions else "0") + " > $@"))
@ -572,6 +577,7 @@ def tf_gen_op_wrapper_py(name,
outs=[out],
srcs=api_def_srcs,
tools=[tool_name] + tf_binary_additional_srcs(),
local = (1 if gen_locally else 0),
cmd=("$(location " + tool_name + ") " + api_def_args_str + " " +
op_list_arg + " " +
("1" if require_shape_functions else "0") + " " +