Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix (jit): remove patcher #752

Merged
merged 3 commits into from
Dec 1, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Remove unused variable
  • Loading branch information
Giuseppe5 committed Dec 1, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 92fdeae296190cf859a65d6fb087576159a8ad07
2 changes: 1 addition & 1 deletion src/brevitas/core/quant/delay.py
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ def __init__(self, quant_delay_steps):
super(_DelayQuant, self).__init__()
self.quant_delay_steps: int = brevitas.jit.Attribute(quant_delay_steps, int)

@brevitas.jit.script_method_110_disabled
@brevitas.jit.script_method
def forward(self, x: Tensor, y: Tensor) -> Tensor:
if self.quant_delay_steps > 0:
self.quant_delay_steps = self.quant_delay_steps - 1
4 changes: 2 additions & 2 deletions src/brevitas/core/quant/int_base.py
Original file line number Diff line number Diff line change
@@ -61,7 +61,7 @@ def __init__(
self.narrow_range = narrow_range
self.delay_wrapper = DelayWrapper(quant_delay_steps)

@brevitas.jit.script_method_110_disabled
@brevitas.jit.script_method
def to_int(self, scale: Tensor, zero_point: Tensor, bit_width: Tensor, x: Tensor) -> Tensor:
y = x / scale
y = y + zero_point
@@ -134,7 +134,7 @@ def __init__(
self.narrow_range = narrow_range
self.delay_wrapper = DelayWrapper(quant_delay_steps)

@brevitas.jit.script_method_110_disabled
@brevitas.jit.script_method
def to_int(
self, pre_scale: Tensor, pre_zero_point: Tensor, bit_width: Tensor,
x: Tensor) -> Tensor:
3 changes: 0 additions & 3 deletions src/brevitas/jit.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Copyright (C) 2023, Advanced Micro Devices, Inc. All rights reserved.
# SPDX-License-Identifier: BSD-3-Clause

from packaging import version
import torch

from brevitas.config import JIT_ENABLED
@@ -17,12 +16,10 @@ def _disabled(fn):
script = torch.jit.script
ScriptModule = torch.jit.ScriptModule
Attribute = torch.jit.Attribute
script_method_110_disabled = script_method

else:

script_method = _disabled
script = _disabled
script_method_110_disabled = _disabled
ScriptModule = torch.nn.Module
Attribute = lambda val, type: val
Loading