Skip to content

Commit

Permalink
ONNX (finn): add QuantIdentity handler
Browse files Browse the repository at this point in the history
Signed-off-by: Alessandro Pappalardo <[email protected]>
  • Loading branch information
volcacius committed Sep 8, 2020
1 parent 7f12633 commit 59f1fdd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 6 additions & 1 deletion brevitas/onnx/finn/handler/act.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import torch
from torch import Tensor

from brevitas.nn import QuantReLU, QuantHardTanh
from brevitas.nn import QuantReLU, QuantHardTanh, QuantIdentity
from .base import FINNQuantInputHandler, FINNQuantIOHandler
from ..function.act import QuantReLUPlaceholderFunction, QuantHardTanhPlaceholderFunction

Expand Down Expand Up @@ -133,3 +133,8 @@ def prepare_for_symbolic_execution(self, module: QuantHardTanh):
def symbolic_execution(self, inp: Tensor):
ret = QuantHardTanhPlaceholderFunction.apply(inp, *self.symbolic_kwargs.values())
return ret


class FINNQuantIdentityHandler(FINNQuantHardTanhHandler):
handled_layer = QuantIdentity

3 changes: 2 additions & 1 deletion brevitas/onnx/finn/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from .transform import move_quant_attributes_into_annotations
from .handler.parameter import FINNQuantConv2dHandler, FINNQuantLinearHandler
from .handler.parameter import FINNQuantConv1dHandler
from .handler.act import FINNQuantHardTanhHandler, FINNQuantReLUHandler
from .handler.act import FINNQuantHardTanhHandler, FINNQuantReLUHandler, FINNQuantIdentityHandler
from .handler.acc import FINNQuantAvgPool2dHandler


Expand All @@ -15,6 +15,7 @@ class FINNManager(BaseManager):
FINNQuantConv1dHandler,
FINNQuantConv2dHandler,
FINNQuantReLUHandler,
FINNQuantIdentityHandler,
FINNQuantHardTanhHandler,
FINNQuantAvgPool2dHandler]

Expand Down

0 comments on commit 59f1fdd

Please sign in to comment.