aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/python/kernel_tests/matrix_inverse_op_test.py
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <gardener@tensorflow.org>2018-10-08 13:46:12 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-10-08 13:51:07 -0700
commitb052c51374f558c25a29c70918d79205dfec808b (patch)
treefd2eb631b27c5facc6c27a17cfa3c6feb539136d /tensorflow/python/kernel_tests/matrix_inverse_op_test.py
parent76ab96c8a5b2d77dfc191c94ff54fd5e52c561f2 (diff)
Add tf.BenchmarkConfig that returns a session config appropriate for benchmarking. At the moment, it returns a default config with only Grappler dependency optimizer disabled. Many benchmarks wrap the subgraph they want to time in control_flow_ops.group() to avoid including the overhead of copying the output back to the Python client in the measurement. In the graph, this only adds a control dependency between the subgraph output and the fetch node, which in turn (often) causes the dependency optimizer to turn all nodes in the graph into no-ops.
PiperOrigin-RevId: 216242463
Diffstat (limited to 'tensorflow/python/kernel_tests/matrix_inverse_op_test.py')
-rw-r--r--tensorflow/python/kernel_tests/matrix_inverse_op_test.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/tensorflow/python/kernel_tests/matrix_inverse_op_test.py b/tensorflow/python/kernel_tests/matrix_inverse_op_test.py
index 720ba806e9..8bda04b53d 100644
--- a/tensorflow/python/kernel_tests/matrix_inverse_op_test.py
+++ b/tensorflow/python/kernel_tests/matrix_inverse_op_test.py
@@ -28,6 +28,7 @@ from tensorflow.python.ops import linalg_ops
from tensorflow.python.ops import math_ops
from tensorflow.python.ops import random_ops
from tensorflow.python.ops import variables
+from tensorflow.python.platform import benchmark
from tensorflow.python.platform import test
@@ -179,7 +180,7 @@ class MatrixInverseBenchmark(test.Benchmark):
for adjoint in False, True:
for shape in self.shapes:
with ops.Graph().as_default(), \
- session.Session() as sess, \
+ session.Session(config=benchmark.benchmark_config()) as sess, \
ops.device("/cpu:0"):
matrix = self._GenerateMatrix(shape)
inv = linalg_ops.matrix_inverse(matrix, adjoint=adjoint)
@@ -193,7 +194,7 @@ class MatrixInverseBenchmark(test.Benchmark):
if test.is_gpu_available(True):
with ops.Graph().as_default(), \
- session.Session() as sess, \
+ session.Session(config=benchmark.benchmark_config()) as sess, \
ops.device("/gpu:0"):
matrix = self._GenerateMatrix(shape)
inv = linalg_ops.matrix_inverse(matrix, adjoint=adjoint)