Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Branch 197218170 #19409

Merged
merged 91 commits into from
May 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
d86dcdb
Move BUILD file to OVIC folder and add model validation.
tensorflower-gardener May 17, 2018
d0607d7
Add evaluation metrics and export results in the new train_and_evalua…
tensorflower-gardener May 17, 2018
9f1d31d
Adapt LLVM ORC interface change in r332541.
May 17, 2018
3f34171
Drop some old dump_graphviz options
tensorflower-gardener May 17, 2018
ec0659b
[TF:XLA] Bump open source llvm revision to r332584
d0k May 17, 2018
9a75743
Methods to stop and reset tf.GradientTape()
alextp May 17, 2018
92416e6
Fixed bug in tf.pad shape logic that made it more restrictive than ne…
tensorflower-gardener May 17, 2018
9d3e17b
Avoid accessing platform/default directly.
tensorflower-gardener May 17, 2018
8e96814
Update SessionTest.testFeedShapeCompatibility to work with C API enab…
skye May 17, 2018
b024794
[XLA] Adds HloLivenessAnalysis and HloModuleDCE.
tensorflower-gardener May 17, 2018
50f3807
Remove misleading declaration-as-default that results in a deleted co…
tensorflower-gardener May 17, 2018
00ee668
Improvements to function._FuncGraph.
skye May 17, 2018
295587d
Improve the error message printed when a WorkerService::GetStatus() c…
mrry May 17, 2018
9bdb7ec
[TF:XLA] remove re-initializations of Literals
nickdesaulniers May 17, 2018
09a5f58
Rename private push/pop API and use from `stop_recording` method.
tomhennigan May 17, 2018
f4162b7
Allows the fizzbuzz example to work when called as fizzbuzz(tf.consta…
alextp May 17, 2018
151e356
Change traverse_test.test_module to traverse a constructed dummy modu…
tensorflower-gardener May 17, 2018
18cb26b
Change loop variable type to be deduced.
tensorflower-gardener May 17, 2018
0f8be44
[XLA:GPU] Unroll multi-output loop fusions
d0k May 17, 2018
9e2ce8f
Use integral power function rather than floating point version. The i…
tensorflower-gardener May 17, 2018
6e7d573
Fix the fizzbuzz example
alextp May 17, 2018
3f197bc
Remove C API staging from importer.py.
skye May 17, 2018
637707c
Internal change
tensorflower-gardener May 17, 2018
622168b
Support 1x1x1xN bias sizes in TFLite's convolution and FC layers.
tensorflower-gardener May 17, 2018
831aa39
Internal Change
tensorflower-gardener May 17, 2018
01dbc6a
Test some distributions stuff in Eager as well as Graph
May 17, 2018
9a815b4
[XLA] Redesign: delete Client::LoadSnapeshot(SessionModule). This is …
tensorflower-gardener May 17, 2018
7911247
Support functools.partial as callable object in tf_inspect.getargspec.
tensorflower-gardener May 17, 2018
b39f1f5
Remove -DGEMMLOWP_ALLOW_SLOW_SCALAR_FALLBACK being added by default t…
May 17, 2018
7232a90
Allows users to specify allow_custom_ops when calling tf.contrib.lite…
tensorflower-gardener May 17, 2018
b106134
[TF:XLA] Do not rely on implementation-defined semantics of DynamicSl…
mkuperst May 17, 2018
8ab1bc7
Automated g4 rollback of changelist 197026249
allenlavoie May 17, 2018
2b03e28
[TF:STREAM_EXECUTOR] move declaration of multi_platform_manager to he…
nickdesaulniers May 17, 2018
5704164
Fix L2Normalization.
tensorflower-gardener May 17, 2018
620bcf0
Basic usability fixes for RNNCell wrappers
allenlavoie May 17, 2018
695c97c
Added CSV parsing to the tf.data programmers guide
May 17, 2018
facd8f5
Support Bool in Cast (TFLite)
miaout17 May 17, 2018
8e2ff05
[XLA] Remove eq_shapes from Identical SlowPath since it is already ch…
blakehechtman May 17, 2018
3ede0fd
Clean up CFG test suite
tensorflower-gardener May 17, 2018
c1ea012
Move runtime.{h,cc,_test.cc} into core/common_runtime/eager as attr_b…
May 17, 2018
0cde87e
[XLA] Use Expm1 in Elu/Selu
majnemer May 17, 2018
95e7d1b
Support combinations stored in a global variable in combinations.py-b…
isaprykin May 17, 2018
479f68c
Delete unused proto schema "graph_explorer.proto".
tensorflower-gardener May 17, 2018
317f3e0
Add more test cases in function_test
toponado-zz May 17, 2018
b669510
Introduce an "indexed array" analysis
May 17, 2018
9249edb
fixing some incorrect documentation in test cases.
itsmeolivia May 17, 2018
f506183
Don't add branch prediction hints when compiling under nvcc.
craigcitro May 17, 2018
f36c935
[XLA] Redesign: delete xla::Computation.
tensorflower-gardener May 17, 2018
485571d
Make V1 metrics distributed-aware. Also fix a bug where assertAllClose
tensorflower-gardener May 17, 2018
56ba844
Misc changes found when debugging an unrelated problem.
May 17, 2018
a3b86f9
boosted_trees: fixed the crash when eval/prediction is attempted with…
yk5 May 17, 2018
e73efbc
Enable optimizations submitted during pre-NIPS freeze:
tensorflower-gardener May 17, 2018
1130e5b
Add NCHW_VECT_W tensor format.
tensorflower-gardener May 17, 2018
24c6a21
Do not force default layout when there is no need to.
tensorflower-gardener May 18, 2018
2dc24b8
markdown fixes
MarkDaoust May 18, 2018
a7fcec1
Handle HloInstruction::ToString() when literal is missing.
tensorflower-gardener May 18, 2018
aca0458
[XLA] Clamp indices in DynamicSlice and DynamicUpdateSlice instead of…
mkuperst May 18, 2018
609b2ce
Move Keras code out of _impl folder and remove API files.
pavithrasv May 18, 2018
4b052cc
Dropping support for cuDNN < 6.
tensorflower-gardener May 18, 2018
1a00b0a
Update downloadable clang to a new revision
ilya-biryukov May 18, 2018
68546a6
Extracts the following optimizations into methods:
tensorflower-gardener May 18, 2018
2934484
Dropping support for CUDA < 8.
tensorflower-gardener May 18, 2018
56b4665
Modify PadInsertion pass so that it matches other passes.
tensorflower-gardener May 18, 2018
247c135
Mark link-time dependency library as alwayslink=1.
tensorflower-gardener May 18, 2018
e451eef
Restructure BUILD rules to be modularly correct
tensorflower-gardener May 18, 2018
0423cf3
Update the docstring on function.Defun to reflect current graph/sessi…
brianwa84 May 18, 2018
d65cf37
Improve TFLite generated example test speed.
miaout17 May 18, 2018
5f6d8e3
[tf.data] Changed internal implementation of `make_csv_dataset`, and …
May 18, 2018
436e569
[TF:XLA] Allow the HloEvaluator to be changed for the HLO interpreter.
nickdesaulniers May 18, 2018
487d2ab
Op version: Populate version in Toco TFLite exporter
miaout17 May 18, 2018
4fce5d6
Automated g4 rollback of changelist 197118212
tensorflower-gardener May 18, 2018
762d815
Validate the file signatures before issusing a content read in GCS. R…
rxsang May 18, 2018
161ba8e
[TF:XLA] Remove underscore prefix from XlaLaunch operator.
hawkinsp May 18, 2018
b16a67d
boosted_trees: allow labels to have rank 1 as other estimators.
yk5 May 18, 2018
042615c
[TF:XLA] Bump open source llvm revision to r332697
May 18, 2018
24df69d
When converting an unsupported op in TOCO, we can possibly infer the …
tensorflower-gardener May 18, 2018
cb34f5e
Add an in-memory evaluator for Estimator. It will run evaluation with…
ispirmustafa May 18, 2018
7787156
Add eager tests for automatic tensor flattening
iganichev May 18, 2018
514bb4f
Enable `SeedStream` construction from other `SeedStream` instances.
jvdillon May 18, 2018
e0bad4c
Expose read-only versions of input tensors in tflite.
tensorflower-gardener May 18, 2018
3c2e7fa
[TF:XLA] Delete the reverseDFS scheduler. With recent improvements to…
dimvar May 18, 2018
7dd3d09
[dataset]: Remove extra `repeat` in the docstring for `shard`.
tensorflower-gardener May 18, 2018
d7893d8
The quantizer should match the patterns for partition variables.
May 18, 2018
6cd54bc
Revert a change to fix TFLite iOS demo app.
miaout17 May 18, 2018
5c107c9
Fixed an issue when add context into params.
May 18, 2018
e04a45e
Remove unused BUILD dependencies
tensorflower-gardener May 18, 2018
4ae7e05
Correct dtype in resource_strided_slice_assign
alextp May 18, 2018
88ec2f6
Skip tests that require unavailable hardware when not using Distribut…
isaprykin May 18, 2018
f4cb597
Improve import error messages.
tensorflower-gardener May 18, 2018
40f53c7
Automated g4 rollback of changelist 197070234
isaprykin May 18, 2018
068fd9c
Merge commit for internal changes
zheng-xq May 19, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 0 additions & 4 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,10 +498,6 @@ def set_cc_opt_flags(environ_cp):
if not is_ppc64le() and not is_windows():
write_to_bazelrc('build:opt --host_copt=-march=native')
write_to_bazelrc('build:opt --define with_default_optimizations=true')
# TODO(mikecase): Remove these default defines once we are able to get
# TF Lite targets building without them.
write_to_bazelrc('build --copt=-DGEMMLOWP_ALLOW_SLOW_SCALAR_FALLBACK')
write_to_bazelrc('build --host_copt=-DGEMMLOWP_ALLOW_SLOW_SCALAR_FALLBACK')

def set_tf_cuda_clang(environ_cp):
"""set TF_CUDA_CLANG action_env.
Expand Down
45 changes: 2 additions & 43 deletions tensorflow/c/eager/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ tf_cuda_library(
"//tensorflow/core:android_tensorflow_lib_lite",
],
"//conditions:default": [
":runtime",
"//tensorflow/c:c_api",
"//tensorflow/c:c_api_internal",
"//tensorflow/core:core_cpu",
"//tensorflow/core/common_runtime/eager:attr_builder",
"//tensorflow/core/common_runtime/eager:context",
"//tensorflow/core/common_runtime/eager:eager_executor",
"//tensorflow/core/common_runtime/eager:execute",
Expand Down Expand Up @@ -70,7 +70,6 @@ tf_cuda_library(
visibility = ["//tensorflow:internal"],
deps = [
":c_api",
":runtime",
"//tensorflow/c:c_api",
"//tensorflow/c:c_api_internal",
"//tensorflow/core:core_cpu",
Expand All @@ -80,6 +79,7 @@ tf_cuda_library(
"//tensorflow/core:framework_lite",
"//tensorflow/core:lib",
"//tensorflow/core:lib_internal",
"//tensorflow/core/common_runtime/eager:attr_builder",
"//tensorflow/core/common_runtime/eager:context",
"//tensorflow/core/common_runtime/eager:eager_executor",
"//tensorflow/core/common_runtime/eager:eager_operation",
Expand Down Expand Up @@ -118,47 +118,6 @@ tf_cuda_cc_test(
],
)

tf_cuda_library(
name = "runtime",
srcs = ["runtime.cc"],
hdrs = ["runtime.h"],
copts = tf_copts(),
visibility = ["//tensorflow:internal"],
deps = select({
"//tensorflow:android": [
"//tensorflow/core:android_tensorflow_lib_lite",
],
"//conditions:default": [
"//tensorflow/c:c_api",
"//tensorflow/core:core_cpu",
"//tensorflow/core/common_runtime/eager:kernel_and_device",
"//tensorflow/core:core_cpu_internal",
"//tensorflow/core:framework",
"//tensorflow/core:framework_internal",
"//tensorflow/core:lib",
"//tensorflow/core:lib_internal",
"//tensorflow/core:protos_all_cc",
],
}),
)

tf_cc_test(
name = "runtime_test",
srcs = ["runtime_test.cc"],
deps = [
":runtime",
"//tensorflow/cc:cc_ops",
"//tensorflow/cc:client_session",
"//tensorflow/cc:ops",
"//tensorflow/cc:scope",
"//tensorflow/core:core_cpu_internal",
"//tensorflow/core:framework",
"//tensorflow/core:lib",
"//tensorflow/core:test",
"//tensorflow/core:test_main",
],
)

cc_library(
name = "tape",
hdrs = ["tape.h"],
Expand Down
2 changes: 1 addition & 1 deletion tensorflow/c/eager/c_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ limitations under the License.
#include "tensorflow/c/c_api.h"
#include "tensorflow/c/c_api_internal.h"
#include "tensorflow/c/eager/c_api_internal.h"
#include "tensorflow/c/eager/runtime.h"
#ifdef TENSORFLOW_EAGER_USE_XLA
#include "tensorflow/compiler/tf2xla/xla_op_registry.h"
#endif // TENSORFLOW_EAGER_USE_XLA
#include "tensorflow/core/common_runtime/copy_tensor.h"
#include "tensorflow/core/common_runtime/device_factory.h"
#include "tensorflow/core/common_runtime/device_mgr.h"
#include "tensorflow/core/common_runtime/device_set.h"
#include "tensorflow/core/common_runtime/eager/attr_builder.h"
#include "tensorflow/core/common_runtime/eager/copy_to_device_node.h"
#include "tensorflow/core/common_runtime/eager/execute.h"
#include "tensorflow/core/common_runtime/function.h"
Expand Down
2 changes: 1 addition & 1 deletion tensorflow/c/eager/c_api_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ limitations under the License.

#include "tensorflow/c/c_api.h"
#include "tensorflow/c/c_api_internal.h"
#include "tensorflow/c/eager/runtime.h"
#include "tensorflow/core/common_runtime/device_factory.h"
#include "tensorflow/core/common_runtime/eager/attr_builder.h"
#include "tensorflow/core/common_runtime/eager/context.h"
#include "tensorflow/core/common_runtime/eager/eager_executor.h"
#include "tensorflow/core/common_runtime/eager/eager_operation.h"
Expand Down
4 changes: 2 additions & 2 deletions tensorflow/compiler/jit/build_xla_launch_ops_pass.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ static Status BuildLaunchNode(
Graph* graph, Node** node) {
NodeDef def;
def.set_name(graph->NewName(nodename));
def.set_op("_XlaLaunch");
def.set_op("XlaLaunch");
def.set_device(device_name);
AddNodeAttr("Tconstants", constant_dtypes, &def);
AddNodeAttr("Targs", arg_dtypes, &def);
Expand Down Expand Up @@ -79,7 +79,7 @@ static Status ReplaceNodeWithXlaLaunch(Graph* graph, Node* node) {
node->input_types().begin() + num_constant_args,
node->input_types().begin() + num_constant_args + num_nonconst_args);

// Build a _XlaLaunch operator to execute the function body.
// Build a XlaLaunch operator to execute the function body.
Node* launch_node;
TF_RETURN_IF_ERROR(BuildLaunchNode(
graph->NewName(node->name()), node->type_string(), node->def().attr(),
Expand Down
2 changes: 1 addition & 1 deletion tensorflow/compiler/jit/encapsulate_subgraphs_pass.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Status EncapsulateSubgraphsInFunctions(
std::unique_ptr<Graph>* graph_out, FunctionLibraryDefinition* library);

// The attribute that marks function calls produced by the encapsulate
// subgraphs pass and that should in turn be compiled via _XlaLaunch operators.
// subgraphs pass and that should in turn be compiled via XlaLaunch operators.
extern const char* const kXlaCompiledKernelAttr;

// Does `node` have the kXlaCompiledKernelAttr attribute?
Expand Down
5 changes: 2 additions & 3 deletions tensorflow/compiler/jit/kernels/xla_launch_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,9 @@ XlaLocalLaunchOp::~XlaLocalLaunchOp() {
VLOG(1) << "XlaLocalLaunchOp destroyed";
}

REGISTER_KERNEL_BUILDER(Name("_XlaLaunch").Device(DEVICE_CPU),
XlaLocalLaunchOp);
REGISTER_KERNEL_BUILDER(Name("XlaLaunch").Device(DEVICE_CPU), XlaLocalLaunchOp);

REGISTER_KERNEL_BUILDER(Name("_XlaLaunch")
REGISTER_KERNEL_BUILDER(Name("XlaLaunch")
.Device(DEVICE_GPU)
.HostMemory("constants")
.HostMemory("resources"),
Expand Down
4 changes: 2 additions & 2 deletions tensorflow/compiler/jit/ops/xla_ops.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ limitations under the License.

namespace tensorflow {

REGISTER_OP("_XlaLaunch")
REGISTER_OP("XlaLaunch")
.Input("constants: Tconstants")
.Attr("Tconstants: list(type) >= 0")
.Input("args: Targs")
Expand All @@ -28,7 +28,7 @@ REGISTER_OP("_XlaLaunch")
.Attr("Tresults: list(type) >= 0")
.Attr("function: func")
// XLA random-number generation ops are stateful.
// TODO(phawkins): create stateful and non-stateful variants of _XlaLaunch.
// TODO(phawkins): create stateful and non-stateful variants of XlaLaunch.
.SetIsStateful()
.Doc("XLA Launch Op. For use by the XLA JIT only.");

Expand Down
3 changes: 1 addition & 2 deletions tensorflow/compiler/jit/xla_compilation_cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,7 @@ Status XlaCompilationCache::BuildSignature(

namespace {

// Builds a XlaCompiler::Argument vector from the arguments to the _XlaLaunch
// op.
// Builds a XlaCompiler::Argument vector from the arguments to the XlaLaunch op.
Status BuildArguments(const std::map<int, Tensor>& constant_args,
const std::map<int, OptionalTensor>& variable_args,
OpKernelContext* ctx,
Expand Down
5 changes: 1 addition & 4 deletions tensorflow/compiler/jit/xla_compile_on_demand_op.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,8 @@ limitations under the License.
namespace tensorflow {

// An OpKernel that compiles an op to an XLA computation and runs it. Unlike
// _XlaLaunch this doesn't rely on any rewrites of the graphdef - it will run a
// XlaLaunch this doesn't rely on any rewrites of the graphdef - it will run a
// vanilla TensorFlow op as long as the bridge supports it.
//
// Importantly _XlaLaunch assumes all input and output tensors are on the host,
// whereas XlacompileOnDemandOp works with tensors in device memory.
class XlaCompileOnDemandOp : public OpKernel {
public:
explicit XlaCompileOnDemandOp(OpKernelConstruction* ctx) : OpKernel(ctx) {}
Expand Down
4 changes: 2 additions & 2 deletions tensorflow/compiler/jit/xla_device_ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace tensorflow {

// Dummy OpKernel, used for kernels assigned to an XLA device that should be
// compiled. Should never be called at runtime since such ops should be
// rewritten to a _XlaLaunch op. If it is called, it means the placer placed an
// rewritten to a XlaLaunch op. If it is called, it means the placer placed an
// operator on an XLA device but the compiler did not compile it.
class XlaDeviceDummyOp : public OpKernel {
public:
Expand All @@ -42,7 +42,7 @@ class XlaDeviceDummyOp : public OpKernel {
};

#define REGISTER_XLA_LAUNCH_KERNEL(DEVICE, KERNEL, TYPES) \
REGISTER_KERNEL_BUILDER(Name("_XlaLaunch") \
REGISTER_KERNEL_BUILDER(Name("XlaLaunch") \
.Device(DEVICE) \
.HostMemory("constants") \
.HostMemory("resources"), \
Expand Down
10 changes: 5 additions & 5 deletions tensorflow/compiler/tests/dense_layer_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,16 @@ def InLabels(labels, substr):


def XlaLaunchOpCount(labels):
"""Count how many _XlaLaunch labels are present."""
return sum("_XlaLaunch(" in x for x in labels)
"""Count how many XlaLaunch labels are present."""
return sum("XlaLaunch(" in x for x in labels)


class DenseLayerTest(test.TestCase):

def testDenseLayerAutoJit(self):
"""Tests dense layer compilation in auto-jit mode.

Dense layer should be compiled into a single _XlaLaunch op in auto-jit mode.
Dense layer should be compiled into a single XlaLaunch op in auto-jit mode.
"""

os.environ["TF_XLA_FLAGS"] = ("--tf_xla_cpu_global_jit")
Expand Down Expand Up @@ -83,7 +83,7 @@ def testDenseLayerJitScopeDefinedShape(self):
"""Tests that the dense layer node is properly compiled in jit scope.

Dense layer with static shape input tensor should be compiled into a single
_XlaLaunch op by XLA.
XlaLaunch op by XLA.
"""

with self.test_session() as sess:
Expand All @@ -110,7 +110,7 @@ def testDenseLayerJitScopeUndefinedShape(self):
Dense layer uses shape op to get shape of input tensor if its shape is not
fully defined. XLA does not cluster shape op with other operators. But in
experimental_jit_scope, XLA is forced to compile shape op into its own
cluster, causing dense layer to be split into TWO _XlaLaunch ops.
cluster, causing dense layer to be split into TWO XlaLaunch ops.
"""

with self.test_session() as sess:
Expand Down
51 changes: 51 additions & 0 deletions tensorflow/compiler/tests/eager_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,57 @@ def f(x):
self.assertEqual(30, dy.numpy())


class ExcessivePaddingTest(XLATestCase):
"""Test that eager execution works with TPU flattened tensors.

Tensors that would normally be excessively padded when written
to TPU memory are reshaped to 1-D flat tensors.

This test case verifies that such tensors work with eager execution.

The flattening currently only happens on TPU, but tests should work
fine with all backends as flattening is transparent.
"""

def testFromConstant(self):
with self.test_scope():
# Create constant of shape [100, 2, 1]. This tensor would be
# excessively padded on TPU.
tensor = constant_op.constant(100 * [[[10.0], [2.0]]])
# Use reduce_sum since it requires correctly working with
# a particular dimension.
reduced = math_ops.reduce_sum(tensor, axis=1)
self.assertAllEqual(100 * [[12.0]], reduced)

def testFromOperation(self):
with self.test_scope():
tensor = array_ops.ones([3, 100, 2, 2])
reduced = math_ops.reduce_sum(tensor, axis=[0, 2, 3])
self.assertAllEqual(100 * [12.0], reduced)

def testAsFunctionInput(self):
with self.test_scope():

@function.defun(compiled=True)
def f(x):
return math_ops.reduce_sum(x, axis=2)

tensor = constant_op.constant(100 * [[[10.0, 2.0]]])
reduced = f(tensor)
self.assertAllEqual(100 * [[12.0]], reduced)

def testAsFunctionOutput(self):
with self.test_scope():

@function.defun(compiled=True)
def f(x):
return x * constant_op.constant(100 * [[[10.0, 2.0]]])

y = f(3)
reduced = math_ops.reduce_sum(y, axis=2)
self.assertAllEqual(100 * [[36.0]], reduced)


if __name__ == '__main__':
ops.enable_eager_execution(
config=config_pb2.ConfigProto(log_device_placement=True))
Expand Down
16 changes: 8 additions & 8 deletions tensorflow/compiler/tests/jit_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ def InLabels(labels, substr):


def MetadataHasXlaLaunch(run_metadata):
"""Returns true if there is a _XlaLaunch kernel in run_metadata's timeline."""
"""Returns true if there is a XlaLaunch kernel in run_metadata's timeline."""

# TODO(phawkins): find a less hacky way to test whether a kernel ran.
return InLabels(RunMetadataLabels(run_metadata), "_XlaLaunch")
return InLabels(RunMetadataLabels(run_metadata), "XlaLaunch")


class JitLaunchTest(test.TestCase):
Expand All @@ -90,8 +90,8 @@ class JitLaunchTest(test.TestCase):
# Verifies that the outputs match and that XLA was invoked. 'fn' must take
# the same number of tensors as arguments that are in 'args', and must return
# a tuple of output tensors.
# If 'require_kernel_launch' is True, then we verify that a _XlaLaunch node
# actually ran. However, it is sometimes possible for _XlaLaunch ops to be
# If 'require_kernel_launch' is True, then we verify that a XlaLaunch node
# actually ran. However, it is sometimes possible for XlaLaunch ops to be
# constant-folded away, so the check is optional.
def _compare(self, fn, args, require_kernel_launch=True, noinline=None):
with session_lib.Session(config=NoRewriteSessionConfig()) as sess:
Expand Down Expand Up @@ -441,14 +441,14 @@ def Forward(x):
self.assertFalse(InLabels(labels, "Log"))
self.assertTrue(InLabels(labels, "Reciprocal"))
self.assertTrue(InLabels(labels, "Mul"))
self.assertFalse(InLabels(labels, "_XlaLaunch"))
self.assertFalse(InLabels(labels, "XlaLaunch"))

# Compile the backprop. One _XlaLaunch.
# Compile the backprop. One XlaLaunch.
labels = _Run(compiled=True)
self.assertFalse(InLabels(labels, "Log"))
self.assertFalse(InLabels(labels, "Reciprocal"))
self.assertFalse(InLabels(labels, "Mul"))
self.assertTrue(InLabels(labels, "_XlaLaunch"))
self.assertTrue(InLabels(labels, "XlaLaunch"))


class ElementWiseFusionTest(test.TestCase):
Expand Down Expand Up @@ -482,7 +482,7 @@ def simpleTest(self, arg0, arg1, global_jit_level):
trace_level=config_pb2.RunOptions.FULL_TRACE))

labels = RunMetadataLabels(run_metadata)
count = sum("_XlaLaunch(" in x for x in labels)
count = sum("XlaLaunch(" in x for x in labels)

return output, count

Expand Down
17 changes: 11 additions & 6 deletions tensorflow/compiler/tests/unary_ops_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,7 @@ def testFloatOps(self):
math_ops.expm1,
np.array([[-1, 1]], dtype=dtype),
expected=np.array([[-0.63212056, 1.71828183]], dtype=dtype),
rtol=1e-5,
atol=1e-6)
rtol=1e-5)

self._assertOpOutputMatchesExpected(
math_ops.floor,
Expand Down Expand Up @@ -335,13 +334,19 @@ def testFloatOps(self):

self._assertOpOutputMatchesExpected(
nn_ops.elu,
np.array([[-1, 0, 1]], dtype=dtype),
expected=np.array([[-0.63212056, 0, 1]], dtype=dtype))
np.array([[-1, 0, 1, -1e-6]], dtype=dtype),
expected=np.array([[-0.63212056, 0, 1, -9.999995e-07]], dtype=dtype),
rtol=1e-5,
atol=1e-6)

self._assertOpOutputMatchesExpected(
nn_ops.selu,
np.array([[-1, 0, 1]], dtype=dtype),
expected=np.array([[-1.11133074, 0., 1.05070099]], dtype=dtype))
np.array([[-1, 0, 1, -1e-5]], dtype=dtype),
expected=np.array(
[[-1.11133074, 0., 1.05070099, -1.758090550379974e-05]],
dtype=dtype),
rtol=1e-5,
atol=1e-6)

self._assertOpOutputMatchesExpected(
nn_ops.relu,
Expand Down