注销使用 @dispatch_for_*
注册的函数。
用法
tf.experimental.unregister_dispatch_for(
dispatch_target
)
参数
-
dispatch_target
注销的函数。
抛出
-
ValueError
如果dispatch_target
未使用@dispatch_for
,@dispatch_for_unary_elementwise_apis
或@dispatch_for_binary_elementwise_apis
注册。
这主要用于测试目的。
例子:
# Define a type and register a dispatcher to override `tf.abs`:
class MyTensor(tf.experimental.ExtensionType):
value:tf.Tensor
@dispatch_for_api(tf.abs)
def my_abs(x:MyTensor):
return MyTensor(tf.abs(x.value))
tf.abs(MyTensor(5))
MyTensor(value=<tf.Tensor:shape=(), dtype=int32, numpy=5>)
# Unregister the dispatcher, so `tf.abs` no longer calls `my_abs`.
unregister_dispatch_for(my_abs)
tf.abs(MyTensor(5))
Traceback (most recent call last):
ValueError:Attempt to convert a value ... to a Tensor.
相关用法
- Python tf.experimental.dlpack.from_dlpack用法及代码示例
- Python tf.experimental.numpy.iinfo用法及代码示例
- Python tf.experimental.Optional.has_value用法及代码示例
- Python tf.experimental.dispatch_for_unary_elementwise_apis用法及代码示例
- Python tf.experimental.dispatch_for_api用法及代码示例
- Python tf.experimental.tensorrt.Converter用法及代码示例
- Python tf.experimental.ExtensionType用法及代码示例
- Python tf.experimental.Optional.get_value用法及代码示例
- Python tf.experimental.numpy.issubdtype用法及代码示例
- Python tf.experimental.numpy.unicode_用法及代码示例
- Python tf.experimental.dlpack.to_dlpack用法及代码示例
- Python tf.experimental.async_scope用法及代码示例
- Python tf.experimental.Optional.empty用法及代码示例
- Python tf.experimental.numpy.float16.as_integer_ratio用法及代码示例
- Python tf.experimental.numpy.float64.as_integer_ratio用法及代码示例
- Python tf.experimental.dispatch_for_binary_elementwise_apis用法及代码示例
注:本文由纯净天空筛选整理自tensorflow.org大神的英文原创作品 tf.experimental.unregister_dispatch_for。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。