@@ -292,93 +292,5 @@ def test_invalid_channels(self):
292
292
self .evaluate (self ._adjust_saturation_in_yiq_tf (x_np , scale ))
293
293
294
294
295
- # TODO: get rid of sessions
296
- class AdjustHueInYiqBenchmark (tf .test .Benchmark ):
297
- def _benchmark_adjust_hue_in_yiq (self , device , cpu_count ):
298
- image_shape = [299 , 299 , 3 ]
299
- burn_iters = 100
300
- benchmark_iters = 1000
301
- config = tf .compat .v1 .ConfigProto ()
302
- tag = device + "_%s" % (cpu_count if cpu_count is not None else "all" )
303
- if cpu_count is not None :
304
- config .inter_op_parallelism_threads = 1
305
- config .intra_op_parallelism_threads = cpu_count
306
- with self .cached_session ("" , graph = tf .Graph (), config = config ) as sess :
307
- with tf .device (device ):
308
- inputs = tf .Variable (
309
- tf .random .uniform (image_shape , dtype = tf .dtypes .float32 ) * 255 ,
310
- trainable = False ,
311
- dtype = tf .dtypes .float32 ,
312
- )
313
- delta = tf .constant (0.1 , dtype = tf .dtypes .float32 )
314
- outputs = distort_image_ops .adjust_hsv_in_yiq (inputs , delta , 1 , 1 )
315
- run_op = tf .group (outputs )
316
- sess .run (tf .compat .v1 .global_variables_initializer ())
317
- benchmark_values = self .run_op_benchmark (
318
- sess ,
319
- run_op ,
320
- burn_iters = burn_iters ,
321
- min_iters = benchmark_iters ,
322
- name = "benchmarkAdjustSaturationInYiq_299_299_3_%s" % (tag ),
323
- )
324
- print (
325
- "benchmarkAdjustSaturationInYiq_299_299_3_%s step_time: %.2f us"
326
- % (tag , benchmark_values ["wall_time" ] * 1e6 )
327
- )
328
-
329
- def benchmark_adjust_hue_in_yiqCpu1 (self ):
330
- self ._benchmark_adjust_hue_in_yiq ("/cpu:0" , 1 )
331
-
332
- def benchmark_adjust_hue_in_yiqCpuAll (self ):
333
- self ._benchmark_adjust_hue_in_yiq ("/cpu:0" , None )
334
-
335
- def benchmark_adjust_hue_in_yiq_gpu_all (self ):
336
- self ._benchmark_adjust_hue_in_yiq (tf .test .gpu_device_name (), None )
337
-
338
-
339
- # TODO: get rid of sessions
340
- class AdjustSaturationInYiqBenchmark (tf .test .Benchmark ):
341
- def _benchmark_adjust_saturation_in_yiq (self , device , cpu_count ):
342
- image_shape = [299 , 299 , 3 ]
343
- burn_iters = 100
344
- benchmark_iters = 1000
345
- config = tf .compat .v1 .ConfigProto ()
346
- tag = device + "_%s" % (cpu_count if cpu_count is not None else "all" )
347
- if cpu_count is not None :
348
- config .inter_op_parallelism_threads = 1
349
- config .intra_op_parallelism_threads = cpu_count
350
- with self .cached_session ("" , graph = tf .Graph (), config = config ) as sess :
351
- with tf .device (device ):
352
- inputs = tf .Variable (
353
- tf .random .uniform (image_shape , dtype = tf .dtypes .float32 ) * 255 ,
354
- trainable = False ,
355
- dtype = tf .dtypes .float32 ,
356
- )
357
- scale = tf .constant (0.1 , dtype = tf .dtypes .float32 )
358
- outputs = distort_image_ops .adjust_hsv_in_yiq (inputs , 0 , scale , 1 )
359
- run_op = tf .group (outputs )
360
- sess .run (tf .compat .v1 .global_variables_initializer ())
361
- benchmark_values = self .run_op_benchmark (
362
- sess ,
363
- run_op ,
364
- burn_iters = burn_iters ,
365
- min_iters = benchmark_iters ,
366
- name = "benchmarkAdjustSaturationInYiq_299_299_3_%s" % (tag ),
367
- )
368
- print (
369
- "benchmarkAdjustSaturationInYiq_299_299_3_%s step_time: %.2f us"
370
- % (tag , benchmark_values ["wall_time" ] * 1e6 )
371
- )
372
-
373
- def benchmark_adjust_saturation_in_yiq_cpu1 (self ):
374
- self ._benchmark_adjust_saturation_in_yiq ("/cpu:0" , 1 )
375
-
376
- def benchmark_adjust_saturation_in_yiq_cpu_all (self ):
377
- self ._benchmark_adjust_saturation_in_yiq ("/cpu:0" , None )
378
-
379
- def benchmark_adjust_saturation_in_yiq_gpu_all (self ):
380
- self ._benchmark_adjust_saturation_in_yiq (tf .test .gpu_device_name (), None )
381
-
382
-
383
295
if __name__ == "__main__" :
384
296
sys .exit (pytest .main ([__file__ ]))
0 commit comments