• 文档 >
  • 量化 >
  • 量化 API 参考 >
  • ObserverBase
快捷键

ObserverBase

类 torch.ao.quantization.observer.ObserverBase(dtype, is_dynamic=False)[source][source] ¶

基础观察器模块。任何观察器实现都应从此类派生。

混合观察者应遵循相同的 API。在正向中,它们将更新观察到的张量的统计信息。并且它们应提供一个计算量化参数的 calculate_qparams 函数,该函数根据收集到的统计信息进行计算。

参数:
  • dtype - 量化节点需要的 dtype 参数,以实现参考模型规范。

  • is_dynamic (布尔值) – 表示观察者是否为动态量化的占位符的指示器

  • 量化(或静态)–

类方法 with_args(**kwargs)[source] ¶

允许创建类工厂的包装器。

这在需要创建具有相同构造函数参数但不同实例的类时非常有用。可以与_callable_args 一起使用。

示例:

>>> Foo.with_args = classmethod(_with_args)
>>> foo_builder = Foo.with_args(a=3, b=4).with_args(answer=42)
>>> foo_instance1 = foo_builder()
>>> foo_instance2 = foo_builder()
>>> id(foo_instance1) == id(foo_instance2)
False
classmethod with_callable_args(**kwargs)[source]

允许在构造时调用需要被调用的类工厂参数的包装器。

当需要创建具有相同构造函数参数但不同实例的类时,这可能很有用,并且这些参数仅在构造时计算。可以与_with_args 一起使用。

示例:

>>> Foo.with_callable_args = classmethod(_with_callable_args)
>>> Foo.with_args = classmethod(_with_args)
>>> foo_builder = Foo.with_callable_args(cur_time=get_time_func).with_args(name="dan")
>>> foo_instance1 = foo_builder()
>>> # wait 50
>>> foo_instance2 = foo_builder()
>>> id(foo_instance1.creation_time) == id(foo_instance2.creation_time)
False

© 版权所有 PyTorch 贡献者。

使用 Sphinx 构建,主题由 Read the Docs 提供。

文档

访问 PyTorch 的全面开发者文档

查看文档

教程

深入了解初学者和高级开发者的教程

查看教程

资源

查找开发资源并获得您的疑问解答

查看资源