You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

elemwise.py 654 B

1234567891011121314151617181920
  1. from ..functional.elemwise import _elwise
  2. from ..tensor import Tensor
  3. from .module import Module
  4. class Elemwise(Module):
  5. r"""A :class:`~.Module` to do :mod:`~.functional.elemwise` operator. Could be replaced with :class:`~.QATModule`
  6. version :class:`~.qat.Elemwise` using :func:`~.quantize.quantize_qat`.
  7. Args:
  8. method: the elemwise method, support the following string.
  9. It will do the normal elemwise operator for float.
  10. """
  11. def __init__(self, method, **kwargs):
  12. super().__init__(**kwargs)
  13. self.method = method
  14. def forward(self, *inps):
  15. return _elwise(*inps, mode=self.method)