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.

concat.py 945 B

12345678910111213141516171819202122232425
  1. # MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
  2. #
  3. # Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
  4. #
  5. # Unless required by applicable law or agreed to in writing,
  6. # software distributed under the License is distributed on an
  7. # "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  8. from typing import Iterable
  9. from ...tensor import Tensor
  10. from .. import concat as Float
  11. from .module import QATModule
  12. class Concat(Float.Concat, QATModule):
  13. r"""A :class:`~.QATModule` to do functional :func:`~.concat` with QAT support.
  14. Could be applied with :class:`~.Observer` and :class:`~.quantization.fake_quant.FakeQuantize`.
  15. """
  16. def forward(self, inps: Iterable[Tensor], axis: int = 0):
  17. return self.apply_quant_activation(super().forward(inps, axis))
  18. @classmethod
  19. def from_float_module(cls, float_module):
  20. return cls(name=float_module.name)