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

Function run_v2_only

tensorflow/python/framework/test_util.py:1283–1317  ·  view source on GitHub ↗

Execute the decorated test only if running in v2 mode. This function is intended to be applied to tests that exercise v2 only functionality. If the test is run in v1 mode it will simply be skipped. `deprecated_graph_mode_only`, `run_v1_only`, `run_v2_only`, and `run_in_graph_and_eager_mode

(func=None)

Source from the content-addressed store, hash-verified

1281
1282
1283def run_v2_only(func=None):
1284 """Execute the decorated test only if running in v2 mode.
1285
1286 This function is intended to be applied to tests that exercise v2 only
1287 functionality. If the test is run in v1 mode it will simply be skipped.
1288
1289 `deprecated_graph_mode_only`, `run_v1_only`, `run_v2_only`, and
1290 `run_in_graph_and_eager_modes` are available decorators for different
1291 v1/v2/eager/graph combinations.
1292
1293 Args:
1294 func: function to be annotated. If `func` is None, this method returns a
1295 decorator the can be applied to a function. If `func` is not None this
1296 returns the decorator applied to `func`.
1297
1298 Returns:
1299 Returns a decorator that will conditionally skip the decorated test method.
1300 """
1301
1302 def decorator(f):
1303 if tf_inspect.isclass(f):
1304 raise ValueError("`run_v2_only` only supports test methods.")
1305
1306 def decorated(self, *args, **kwargs):
1307 if not tf2.enabled():
1308 self.skipTest("Test is only compatible with v2")
1309
1310 return f(self, *args, **kwargs)
1311
1312 return decorated
1313
1314 if func is not None:
1315 return decorator(func)
1316
1317 return decorator
1318
1319
1320def run_gpu_only(func=None):

Callers

nothing calls this directly

Calls 1

decoratorFunction · 0.70

Tested by

no test coverage detected