MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / disable_cudnn_autotune

Function disable_cudnn_autotune

tensorflow/python/framework/test_util.py:1568–1610  ·  view source on GitHub ↗

Disable autotuning during the call to this function. Some tests want to base assertions on a graph being isomorphic with a copy. To ensure this, this decorator disables autotuning. Args: func: Function to run with CuDNN autotuning turned off. Returns: Decorated function.

(func)

Source from the content-addressed store, hash-verified

1566
1567
1568def disable_cudnn_autotune(func):
1569 """Disable autotuning during the call to this function.
1570
1571 Some tests want to base assertions on a graph being isomorphic with a copy.
1572 To ensure this, this decorator disables autotuning.
1573
1574 Args:
1575 func: Function to run with CuDNN autotuning turned off.
1576
1577 Returns:
1578 Decorated function.
1579 """
1580
1581 def decorator(f):
1582
1583 def decorated(self, *args, **kwargs):
1584 original_tf_cudnn_use_autotune = os.environ.get("TF_CUDNN_USE_AUTOTUNE")
1585 os.environ["TF_CUDNN_USE_AUTOTUNE"] = "false"
1586 original_xla_flags = os.environ.get("XLA_FLAGS")
1587 new_xla_flags = "--xla_gpu_autotune_level=0"
1588 if original_xla_flags:
1589 new_xla_flags = original_xla_flags + " " + new_xla_flags
1590 os.environ["XLA_FLAGS"] = new_xla_flags
1591
1592 result = f(self, *args, **kwargs)
1593
1594 if (original_tf_cudnn_use_autotune is None):
1595 del os.environ["TF_CUDNN_USE_AUTOTUNE"]
1596 else:
1597 os.environ["TF_CUDNN_USE_AUTOTUNE"] = original_tf_cudnn_use_autotune
1598 if (original_xla_flags is None):
1599 del os.environ["XLA_FLAGS"]
1600 else:
1601 os.environ["XLA_FLAGS"] = original_xla_flags
1602
1603 return result
1604
1605 return decorated
1606
1607 if func is not None:
1608 return decorator(func)
1609
1610 return decorator
1611
1612
1613# The description is just for documentation purposes.

Callers

nothing calls this directly

Calls 1

decoratorFunction · 0.70

Tested by

no test coverage detected