aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/python/ops/image_ops_test.py
diff options
context:
space:
mode:
Diffstat (limited to 'tensorflow/python/ops/image_ops_test.py')
-rw-r--r--tensorflow/python/ops/image_ops_test.py62
1 files changed, 30 insertions, 32 deletions
diff --git a/tensorflow/python/ops/image_ops_test.py b/tensorflow/python/ops/image_ops_test.py
index 35fdee4fad..ff86df6346 100644
--- a/tensorflow/python/ops/image_ops_test.py
+++ b/tensorflow/python/ops/image_ops_test.py
@@ -602,20 +602,19 @@ class AdjustHueBenchmark(test.Benchmark):
if cpu_count is not None:
config.inter_op_parallelism_threads = 1
config.intra_op_parallelism_threads = cpu_count
- with session.Session("", graph=ops.Graph(), config=config) as sess:
- with ops.device(device):
- inputs = variables.Variable(
- random_ops.random_uniform(image_shape, dtype=dtypes.float32) * 255,
- trainable=False,
- dtype=dtypes.float32)
- delta = constant_op.constant(0.1, dtype=dtypes.float32)
- outputs = image_ops.adjust_hue(inputs, delta)
- run_op = control_flow_ops.group(outputs)
- sess.run(variables.global_variables_initializer())
- for i in xrange(warmup_rounds + benchmark_rounds):
- if i == warmup_rounds:
- start = time.time()
- sess.run(run_op)
+ with self.benchmark_session(config=config, device=device) as sess:
+ inputs = variables.Variable(
+ random_ops.random_uniform(image_shape, dtype=dtypes.float32) * 255,
+ trainable=False,
+ dtype=dtypes.float32)
+ delta = constant_op.constant(0.1, dtype=dtypes.float32)
+ outputs = image_ops.adjust_hue(inputs, delta)
+ run_op = control_flow_ops.group(outputs)
+ sess.run(variables.global_variables_initializer())
+ for i in xrange(warmup_rounds + benchmark_rounds):
+ if i == warmup_rounds:
+ start = time.time()
+ sess.run(run_op)
end = time.time()
step_time = (end - start) / benchmark_rounds
tag = device + "_%s" % (cpu_count if cpu_count is not None else "_all")
@@ -646,21 +645,20 @@ class AdjustSaturationBenchmark(test.Benchmark):
if cpu_count is not None:
config.inter_op_parallelism_threads = 1
config.intra_op_parallelism_threads = cpu_count
- with session.Session("", graph=ops.Graph(), config=config) as sess:
- with ops.device(device):
- inputs = variables.Variable(
- random_ops.random_uniform(image_shape, dtype=dtypes.float32) * 255,
- trainable=False,
- dtype=dtypes.float32)
- delta = constant_op.constant(0.1, dtype=dtypes.float32)
- outputs = image_ops.adjust_saturation(inputs, delta)
- run_op = control_flow_ops.group(outputs)
- sess.run(variables.global_variables_initializer())
- for _ in xrange(warmup_rounds):
- sess.run(run_op)
- start = time.time()
- for _ in xrange(benchmark_rounds):
- sess.run(run_op)
+ with self.benchmark_session(config=config, device=device) as sess:
+ inputs = variables.Variable(
+ random_ops.random_uniform(image_shape, dtype=dtypes.float32) * 255,
+ trainable=False,
+ dtype=dtypes.float32)
+ delta = constant_op.constant(0.1, dtype=dtypes.float32)
+ outputs = image_ops.adjust_saturation(inputs, delta)
+ run_op = control_flow_ops.group(outputs)
+ sess.run(variables.global_variables_initializer())
+ for _ in xrange(warmup_rounds):
+ sess.run(run_op)
+ start = time.time()
+ for _ in xrange(benchmark_rounds):
+ sess.run(run_op)
end = time.time()
step_time = (end - start) / benchmark_rounds
tag = device + "_%s" % (cpu_count if cpu_count is not None else "_all")
@@ -699,7 +697,7 @@ class ResizeBilinearBenchmark(test.Benchmark):
deps = [resize_op]
benchmark_op = control_flow_ops.group(*deps)
- with session.Session() as sess:
+ with self.benchmark_session() as sess:
sess.run(variables.global_variables_initializer())
results = self.run_op_benchmark(
sess,
@@ -747,7 +745,7 @@ class ResizeBicubicBenchmark(test.Benchmark):
deps = [resize_op]
benchmark_op = control_flow_ops.group(*deps)
- with session.Session() as sess:
+ with self.benchmark_session() as sess:
sess.run(variables.global_variables_initializer())
results = self.run_op_benchmark(
sess,
@@ -804,7 +802,7 @@ class ResizeAreaBenchmark(test.Benchmark):
deps = [resize_op]
benchmark_op = control_flow_ops.group(*deps)
- with session.Session() as sess:
+ with self.benchmark_session() as sess:
sess.run(variables.global_variables_initializer())
results = self.run_op_benchmark(
sess,