From 45fcb8f2d3e24ec52d418b93303f1afa0fac6496 Mon Sep 17 00:00:00 2001 From: Sami Kama Date: Fri, 2 Feb 2018 14:36:07 -0800 Subject: [PATCH] Fixes for PR comments and build failures --- tensorflow/contrib/BUILD | 5 +- tensorflow/contrib/cmake/python_modules.txt | 2 + .../contrib/tensorrt/python/trt_convert.py | 6 +- tensorflow/tensorflow.bzl | 55 ++++++++++--------- third_party/gpus/cuda_configure.bzl | 14 ++--- third_party/tensorrt/BUILD.tpl | 2 - 6 files changed, 43 insertions(+), 41 deletions(-) diff --git a/tensorflow/contrib/BUILD b/tensorflow/contrib/BUILD index 738b74c929e..93a0308ddd8 100644 --- a/tensorflow/contrib/BUILD +++ b/tensorflow/contrib/BUILD @@ -105,8 +105,9 @@ py_library( "//tensorflow/contrib/training:training_py", "//tensorflow/contrib/util:util_py", "//tensorflow/python:util", - ] + if_mpi(["//tensorflow/contrib/mpi_collectives:mpi_collectives_py"]) - + if_tensorrt(["//tensorflow/contrib/tensorrt:init_py"]), + ] + if_mpi(["//tensorflow/contrib/mpi_collectives:mpi_collectives_py"]) + if_tensorrt([ + "//tensorflow/contrib/tensorrt:init_py", + ]), ) diff --git a/tensorflow/contrib/cmake/python_modules.txt b/tensorflow/contrib/cmake/python_modules.txt index 9ce8b3cc9cd..52f37b1e3b7 100644 --- a/tensorflow/contrib/cmake/python_modules.txt +++ b/tensorflow/contrib/cmake/python_modules.txt @@ -405,6 +405,8 @@ tensorflow/contrib/summary tensorflow/contrib/tensorboard tensorflow/contrib/tensorboard/plugins tensorflow/contrib/tensorboard/plugins/projector +# TODO(sami): Add cmake implementations +# tensorflow/contrib/tensorrt/python tensorflow/contrib/tensor_forest tensorflow/contrib/tensor_forest/client tensorflow/contrib/tensor_forest/hybrid diff --git a/tensorflow/contrib/tensorrt/python/trt_convert.py b/tensorflow/contrib/tensorrt/python/trt_convert.py index 2d056610cd0..51618312821 100644 --- a/tensorflow/contrib/tensorrt/python/trt_convert.py +++ b/tensorflow/contrib/tensorrt/python/trt_convert.py @@ -46,11 +46,11 @@ def CreateInferenceGraph(input_graph_def, def py2bytes(inp): return inp def py3bytes(inp): - return inp.encode('utf-8',errors='surrogateescape') + return inp.encode('utf-8', errors='surrogateescape') if _six.PY2: - to_bytes=py2bytes + to_bytes = py2bytes else: - to_bytes=py3bytes + to_bytes = py3bytes out_names = [] for i in outputs: diff --git a/tensorflow/tensorflow.bzl b/tensorflow/tensorflow.bzl index 2534c88c187..f78bee5630a 100644 --- a/tensorflow/tensorflow.bzl +++ b/tensorflow/tensorflow.bzl @@ -1303,36 +1303,37 @@ def tf_extension_copts(): # This function attempts to append init_module_name to list of # exported functions in version script def _append_init_to_versionscript_impl(ctx): - modName=ctx.attr.module_name - isVS=ctx.attr.is_version_script - if isVS: - ctx.actions.expand_template( - template=ctx.file.template_file, - output=ctx.outputs.versionscript, - substitutions={ - "global:":"global:\n init_%s;\n PyInit_*;"%(modName), - }, - is_executable=False, - ) - else: - ctx.actions.expand_template( - template=ctx.file.template_file, - output=ctx.outputs.versionscript, - substitutions={ - "*tensorflow*":"*tensorflow*\ninit_%s\nPyInit_*\n"%(modName), - }, - is_executable=False, - ) + mod_name = ctx.attr.module_name + if ctx.attr.is_version_script: + ctx.actions.expand_template( + template=ctx.file.template_file, + output=ctx.outputs.versionscript, + substitutions={ + "global:":"global:\n init_%s;\n PyInit_*;"%(mod_name), + }, + is_executable=False, + ) + else: + ctx.actions.expand_template( + template=ctx.file.template_file, + output=ctx.outputs.versionscript, + substitutions={ + "*tensorflow*":"*tensorflow*\ninit_%s\nPyInit_*\n"%(mod_name), + }, + is_executable=False, + ) _append_init_to_versionscript= rule( - implementation=_append_init_to_versionscript_impl, - attrs={ - "module_name":attr.string(mandatory=True), - "template_file":attr.label(allow_files=True,single_file=True,mandatory=True), - "is_version_script":attr.bool(default=True,doc='whether target is a ld version script or exported symbol list',mandatory=False), - }, - outputs={"versionscript":"%{name}.lds"}, + implementation=_append_init_to_versionscript_impl, + attrs={ + "module_name":attr.string(mandatory=True), + "template_file":attr.label(allow_files=True,single_file=True,mandatory=True), + "is_version_script":attr.bool(default=True, + doc='whether target is a ld version script or exported symbol list', + mandatory=False), + }, + outputs={"versionscript":"%{name}.lds"}, ) def tf_py_wrap_cc(name, diff --git a/third_party/gpus/cuda_configure.bzl b/third_party/gpus/cuda_configure.bzl index 7504154735e..47cc4a5e69b 100644 --- a/third_party/gpus/cuda_configure.bzl +++ b/third_party/gpus/cuda_configure.bzl @@ -358,8 +358,8 @@ def find_cuda_define(repository_ctx, header_dir, header_file, define): if not h_path.exists: auto_configure_fail("Cannot find %s at %s" % (header_file, str(h_path))) result = repository_ctx.execute( - # Grep one more lines as some #defines are splitted into two lines. - ["grep", "--color=never", "-A1", "-E", define, str(h_path)]) + # Grep one more lines as some #defines are splitted into two lines. + ["grep", "--color=never", "-A1", "-E", define, str(h_path)]) if result.stderr: auto_configure_fail("Error reading %s: %s" % (str(h_path), result.stderr)) @@ -368,14 +368,14 @@ def find_cuda_define(repository_ctx, header_dir, header_file, define): auto_configure_fail("Cannot find line containing '%s' in %s" % (define, h_path)) #split results to lines - lines=result.stdout.split('\n') - lenLines=len(lines) + lines = result.stdout.split('\n') + lenLines = len(lines) for l in range(lenLines): - line=lines[l] + line = lines[l] if define in line: # find the line with define - version=line + version = line if l != lenLines-1 and line[-1] == '\\': # add next line, if multiline - version=version[:-1]+lines[l+1] + version = version[:-1] + lines[l+1] break #remove any comments version = version.split("//")[0] diff --git a/third_party/tensorrt/BUILD.tpl b/third_party/tensorrt/BUILD.tpl index dc7fe0c8c8b..354f17cda56 100644 --- a/third_party/tensorrt/BUILD.tpl +++ b/third_party/tensorrt/BUILD.tpl @@ -5,8 +5,6 @@ licenses(["notice"]) exports_files(["LICENSE"]) -load("@local_config_cuda//cuda:build_defs.bzl", "cuda_default_copts", "if_cuda") - package(default_visibility = ["//visibility:public"]) cc_library(