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 (quantizer): fix shapes for mse/hqo optimization #1128

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions src/brevitas/core/stats/stats_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,7 @@ def evaluate_loss(self, x, candidate):
self.set_observer_mode(False)
quant_value = self.proxy_forward(x)
quant_value = _unpack_quant_tensor(quant_value)
quant_value = quant_value.view(x.shape)
loss = self.mse_loss_fn(x, quant_value)
self.set_local_loss_mode(False)
self.restore_observer_mode()
Expand Down
1 change: 1 addition & 0 deletions src/brevitas/export/inference/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from brevitas.proxy.float_parameter_quant import WeightFloatQuantProxyFromInjector
from brevitas.proxy.float_runtime_quant import ActFloatQuantProxyFromInjector
from brevitas.proxy.float_runtime_quant import ActFloatQuantProxyFromInjectorBase
from brevitas.proxy.groupwise_int_runtime_quant import GroupwiseActQuantProxyFromInjector
from brevitas.proxy.parameter_quant import BiasQuantProxyFromInjector
from brevitas.proxy.parameter_quant import WeightQuantProxyFromInjector
from brevitas.proxy.runtime_quant import ActQuantProxyFromInjector
Expand Down
3 changes: 0 additions & 3 deletions src/brevitas/quant/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,6 @@ class MSEAsymmetricScale(ExtendedInjector):

mse_scale = MSEAsymmetricScaleSubInjector
scaling_impl_type = ScalingImplType.PARAMETER_FROM_STATS
scaling_stats_input_view_shape_impl = nn.Identity()

@value
def inner_stats_input_view_shape_impl(scaling_per_output):
Expand All @@ -561,7 +560,6 @@ class MSESymmetricScale(ExtendedInjector):

mse_scale = MSESymmetricScaleSubInjector
scaling_impl_type = ScalingImplType.PARAMETER_FROM_STATS
scaling_stats_input_view_shape_impl = nn.Identity()

@value
def inner_stats_input_view_shape_impl(scaling_per_output):
Expand All @@ -583,7 +581,6 @@ class MSEZeroPoint(ExtendedInjector):
"""

mse_zero_point = MSEZeroPointSubInjector
zero_point_stats_input_view_shape_impl = nn.Identity()

@value
def inner_stats_input_view_shape_impl(scaling_per_output):
Expand Down
Loading