Skip to content
This repository was archived by the owner on Jun 3, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
231 commits
Select commit Hold shift + click to select a range
4d386e0
Removed output quantization from conv layers
anmarques Mar 9, 2022
d875f97
Added _Add_ReLU module that enables QATWrapper for quantizaiton.
anmarques Mar 10, 2022
831e474
Removed quantization of output for linear and conv layers by default.…
anmarques Mar 10, 2022
479d3c9
Minor fixes. Style and quality fixes.
anmarques Mar 10, 2022
30be2e4
Added support to freezing bn stats.
anmarques Mar 10, 2022
89b025f
Added mode argument to wrapping of train function in BNWrapper
anmarques Mar 10, 2022
5865ca6
Set BN fusing back as default.
anmarques Mar 10, 2022
91cd835
Set BN fusing back as default.
anmarques Mar 10, 2022
9819a15
Fixed custom freeze_bn_stats.
anmarques Mar 12, 2022
749ca72
Temporary files for evaluating changes to graphs.
anmarques Mar 14, 2022
601cdea
Added support to tensorrt flag. Moved the computation of quantization…
anmarques Mar 17, 2022
f7aecf1
Added support to TensorRT quantization
anmarques Mar 20, 2022
d994b45
Included check to account for when weight_qconfig_kwatgs is None.
anmarques Mar 21, 2022
3099efb
Removed output quantization from conv layers
anmarques Mar 9, 2022
36bc220
Added _Add_ReLU module that enables QATWrapper for quantizaiton.
anmarques Mar 10, 2022
722f866
Removed quantization of output for linear and conv layers by default.…
anmarques Mar 10, 2022
b553482
Minor fixes. Style and quality fixes.
anmarques Mar 10, 2022
aef2347
Added support to freezing bn stats.
anmarques Mar 10, 2022
df88638
Added mode argument to wrapping of train function in BNWrapper
anmarques Mar 10, 2022
d0b6354
Set BN fusing back as default.
anmarques Mar 10, 2022
fbf2206
Set BN fusing back as default.
anmarques Mar 10, 2022
2312af8
Fixed custom freeze_bn_stats.
anmarques Mar 12, 2022
f3bb04b
Temporary files for evaluating changes to graphs.
anmarques Mar 14, 2022
5bca8d7
Added support to tensorrt flag. Moved the computation of quantization…
anmarques Mar 17, 2022
55b0a40
Added support to TensorRT quantization
anmarques Mar 20, 2022
5730071
Included check to account for when weight_qconfig_kwatgs is None.
anmarques Mar 21, 2022
7ceff2c
Rebasing changes
anmarques Mar 30, 2022
4938803
Modified argument names for backwards compatibility.
anmarques Mar 30, 2022
70f5704
Updated documentation to reflect changes.
anmarques Mar 30, 2022
dc773f0
Updated documentation to reflect changes.
anmarques Mar 30, 2022
8e2ddcb
Updated documentation to reflect changes.
anmarques Mar 30, 2022
dc561f8
Fixed default weights data type.
anmarques Mar 30, 2022
8c0a1e8
Style and quality fixes.
anmarques Mar 30, 2022
a771a2a
Removed unused method
anmarques Mar 30, 2022
8f9d9d7
Removed output quantization from conv layers
anmarques Mar 9, 2022
1293a21
Added _Add_ReLU module that enables QATWrapper for quantizaiton.
anmarques Mar 10, 2022
db277ca
Removed quantization of output for linear and conv layers by default.…
anmarques Mar 10, 2022
04a1ddf
Minor fixes. Style and quality fixes.
anmarques Mar 10, 2022
c2bd48e
Added support to freezing bn stats.
anmarques Mar 10, 2022
b5248d4
Added mode argument to wrapping of train function in BNWrapper
anmarques Mar 10, 2022
a64d626
Set BN fusing back as default.
anmarques Mar 10, 2022
6ece7fc
Set BN fusing back as default.
anmarques Mar 10, 2022
c26ec4c
Fixed custom freeze_bn_stats.
anmarques Mar 12, 2022
58b60fe
Temporary files for evaluating changes to graphs.
anmarques Mar 14, 2022
38a502a
Added support to tensorrt flag. Moved the computation of quantization…
anmarques Mar 17, 2022
77e5267
Added support to TensorRT quantization
anmarques Mar 20, 2022
2a25845
Included check to account for when weight_qconfig_kwatgs is None.
anmarques Mar 21, 2022
9ed579d
Removed output quantization from conv layers
anmarques Mar 9, 2022
43cf404
Added _Add_ReLU module that enables QATWrapper for quantization.
anmarques Mar 10, 2022
05a8735
Removed quantization of output for linear and conv layers by default.…
anmarques Mar 10, 2022
458e271
Minor fixes. Style and quality fixes.
anmarques Mar 10, 2022
10b1244
Added support to freezing bn stats.
anmarques Mar 10, 2022
2bd1cfd
Added mode argument to wrapping of train function in BNWrapper
anmarques Mar 10, 2022
4c6c129
Set BN fusing back as default.
anmarques Mar 10, 2022
91831fd
Set BN fusing back as default.
anmarques Mar 10, 2022
37b73da
Fixed custom freeze_bn_stats.
anmarques Mar 12, 2022
8e06b41
Temporary files for evaluating changes to graphs.
anmarques Mar 14, 2022
21acec1
Added support to tensorrt flag. Moved the computation of quantization…
anmarques Mar 17, 2022
9274d5d
Added support to TensorRT quantization
anmarques Mar 20, 2022
e62ba98
Included check to account for when weight_qconfig_kwatgs is None.
anmarques Mar 21, 2022
e6e7aae
Modified argument names for backwards compatibility.
anmarques Mar 30, 2022
a87fb61
Updated documentation to reflect changes.
anmarques Mar 30, 2022
6d8ee7d
Updated documentation to reflect changes.
anmarques Mar 30, 2022
26696f5
Updated documentation to reflect changes.
anmarques Mar 30, 2022
c90694c
Fixed default weights data type.
anmarques Mar 30, 2022
681334c
Style and quality fixes.
anmarques Mar 30, 2022
f9d882b
Removed unused method
anmarques Mar 30, 2022
0ad8722
Merge remote-tracking branch 'origin/quantization-refactor' into quan…
anmarques Mar 30, 2022
e8743fb
Removed output quantization from conv layers
anmarques Mar 9, 2022
6ec4aa7
Added _Add_ReLU module that enables QATWrapper for quantizaiton.
anmarques Mar 10, 2022
2368c17
Removed quantization of output for linear and conv layers by default.…
anmarques Mar 10, 2022
67347f7
Minor fixes. Style and quality fixes.
anmarques Mar 10, 2022
ad5f938
Added support to freezing bn stats.
anmarques Mar 10, 2022
73701a8
Added mode argument to wrapping of train function in BNWrapper
anmarques Mar 10, 2022
82df8ca
Set BN fusing back as default.
anmarques Mar 10, 2022
1a778bd
Set BN fusing back as default.
anmarques Mar 10, 2022
600eaa8
Fixed custom freeze_bn_stats.
anmarques Mar 12, 2022
86c1233
Temporary files for evaluating changes to graphs.
anmarques Mar 14, 2022
1c434c3
Added support to tensorrt flag. Moved the computation of quantization…
anmarques Mar 17, 2022
b414593
Added support to TensorRT quantization
anmarques Mar 20, 2022
694f646
Included check to account for when weight_qconfig_kwatgs is None.
anmarques Mar 21, 2022
50b1151
Removed output quantization from conv layers
anmarques Mar 9, 2022
617f608
Added _Add_ReLU module that enables QATWrapper for quantization.
anmarques Mar 10, 2022
5e21278
Removed quantization of output for linear and conv layers by default.…
anmarques Mar 10, 2022
d98cb52
Minor fixes. Style and quality fixes.
anmarques Mar 10, 2022
aeed0b9
Added support to freezing bn stats.
anmarques Mar 10, 2022
c640cd6
Added mode argument to wrapping of train function in BNWrapper
anmarques Mar 10, 2022
61e7a56
Set BN fusing back as default.
anmarques Mar 10, 2022
118fbdb
Set BN fusing back as default.
anmarques Mar 10, 2022
8db174c
Fixed custom freeze_bn_stats.
anmarques Mar 12, 2022
cfcf1cb
Temporary files for evaluating changes to graphs.
anmarques Mar 14, 2022
1f63f3d
Added support to tensorrt flag. Moved the computation of quantization…
anmarques Mar 17, 2022
84d851e
Added support to TensorRT quantization
anmarques Mar 20, 2022
97329f3
Included check to account for when weight_qconfig_kwatgs is None.
anmarques Mar 21, 2022
840a6bf
Modified argument names for backwards compatibility.
anmarques Mar 30, 2022
5185520
Updated documentation to reflect changes.
anmarques Mar 30, 2022
74ad8ef
Updated documentation to reflect changes.
anmarques Mar 30, 2022
6d57cb2
Updated documentation to reflect changes.
anmarques Mar 30, 2022
43bf768
Fixed default weights data type.
anmarques Mar 30, 2022
afd1df8
Style and quality fixes.
anmarques Mar 30, 2022
44303e1
Removed unused method
anmarques Mar 30, 2022
64b42d5
Removed output quantization from conv layers
anmarques Mar 9, 2022
74d7db5
Added _Add_ReLU module that enables QATWrapper for quantizaiton.
anmarques Mar 10, 2022
71f25cd
Removed quantization of output for linear and conv layers by default.…
anmarques Mar 10, 2022
04c436f
Minor fixes. Style and quality fixes.
anmarques Mar 10, 2022
b76d59e
Added support to freezing bn stats.
anmarques Mar 10, 2022
81bc2d0
Added mode argument to wrapping of train function in BNWrapper
anmarques Mar 10, 2022
a009d20
Set BN fusing back as default.
anmarques Mar 10, 2022
b736ce7
Set BN fusing back as default.
anmarques Mar 10, 2022
e56066e
Fixed custom freeze_bn_stats.
anmarques Mar 12, 2022
75dd790
Temporary files for evaluating changes to graphs.
anmarques Mar 14, 2022
4fd2ced
Added support to tensorrt flag. Moved the computation of quantization…
anmarques Mar 17, 2022
29e32ed
Added support to TensorRT quantization
anmarques Mar 20, 2022
7af19e3
Included check to account for when weight_qconfig_kwatgs is None.
anmarques Mar 21, 2022
a6b2b68
Removed output quantization from conv layers
anmarques Mar 9, 2022
cbc8551
Added _Add_ReLU module that enables QATWrapper for quantizaiton.
anmarques Mar 10, 2022
475fd7e
Removed quantization of output for linear and conv layers by default.…
anmarques Mar 10, 2022
0d0f757
Minor fixes. Style and quality fixes.
anmarques Mar 10, 2022
0e05c94
Added support to freezing bn stats.
anmarques Mar 10, 2022
9dce86e
Added mode argument to wrapping of train function in BNWrapper
anmarques Mar 10, 2022
dd7e24b
Set BN fusing back as default.
anmarques Mar 10, 2022
0c9bef9
Set BN fusing back as default.
anmarques Mar 10, 2022
1f6b56c
Fixed custom freeze_bn_stats.
anmarques Mar 12, 2022
aee8074
Temporary files for evaluating changes to graphs.
anmarques Mar 14, 2022
810158a
Added support to tensorrt flag. Moved the computation of quantization…
anmarques Mar 17, 2022
2782d7f
Added support to TensorRT quantization
anmarques Mar 20, 2022
dafb464
Included check to account for when weight_qconfig_kwatgs is None.
anmarques Mar 21, 2022
5fe18e5
Modified argument names for backwards compatibility.
anmarques Mar 30, 2022
50e0773
Updated documentation to reflect changes.
anmarques Mar 30, 2022
77444f0
Updated documentation to reflect changes.
anmarques Mar 30, 2022
9bebbf0
Updated documentation to reflect changes.
anmarques Mar 30, 2022
bdf80e8
Fixed default weights data type.
anmarques Mar 30, 2022
095f139
Style and quality fixes.
anmarques Mar 30, 2022
afd7430
Removed unused method
anmarques Mar 30, 2022
19cf73e
Merge remote-tracking branch 'origin/quantization-refactor' into quan…
anmarques Mar 31, 2022
fb68527
Removed testing files
anmarques Mar 31, 2022
7309134
Style and quality fixes.
anmarques Mar 31, 2022
a675813
Changed call to get_qat_qconfig to not specify symmetry and data type…
anmarques Apr 5, 2022
850b88a
Merge branch 'main' into quantization-refactor
bfineran Apr 5, 2022
2bbd528
Removed output quantization from conv layers
anmarques Mar 9, 2022
f7e7374
Added _Add_ReLU module that enables QATWrapper for quantizaiton.
anmarques Mar 10, 2022
8a71887
Removed quantization of output for linear and conv layers by default.…
anmarques Mar 10, 2022
2e65700
Minor fixes. Style and quality fixes.
anmarques Mar 10, 2022
b100535
Added support to freezing bn stats.
anmarques Mar 10, 2022
7c9707b
Added mode argument to wrapping of train function in BNWrapper
anmarques Mar 10, 2022
4d8e3ea
Set BN fusing back as default.
anmarques Mar 10, 2022
56d065d
Set BN fusing back as default.
anmarques Mar 10, 2022
508c753
Fixed custom freeze_bn_stats.
anmarques Mar 12, 2022
810c22a
Temporary files for evaluating changes to graphs.
anmarques Mar 14, 2022
9422c87
Added support to tensorrt flag. Moved the computation of quantization…
anmarques Mar 17, 2022
7d66275
Added support to TensorRT quantization
anmarques Mar 20, 2022
15c552b
Included check to account for when weight_qconfig_kwatgs is None.
anmarques Mar 21, 2022
34e7a8f
Removed output quantization from conv layers
anmarques Mar 9, 2022
29af80d
Added _Add_ReLU module that enables QATWrapper for quantization.
anmarques Mar 10, 2022
5d4beba
Removed quantization of output for linear and conv layers by default.…
anmarques Mar 10, 2022
318fe31
Minor fixes. Style and quality fixes.
anmarques Mar 10, 2022
b8e563d
Added support to freezing bn stats.
anmarques Mar 10, 2022
b911a75
Added mode argument to wrapping of train function in BNWrapper
anmarques Mar 10, 2022
e39e90c
Set BN fusing back as default.
anmarques Mar 10, 2022
24363c6
Set BN fusing back as default.
anmarques Mar 10, 2022
242e29b
Fixed custom freeze_bn_stats.
anmarques Mar 12, 2022
3759f59
Temporary files for evaluating changes to graphs.
anmarques Mar 14, 2022
0b677f4
Added support to tensorrt flag. Moved the computation of quantization…
anmarques Mar 17, 2022
df5844d
Added support to TensorRT quantization
anmarques Mar 20, 2022
3a01361
Included check to account for when weight_qconfig_kwatgs is None.
anmarques Mar 21, 2022
3ea4268
Modified argument names for backwards compatibility.
anmarques Mar 30, 2022
cdf316e
Updated documentation to reflect changes.
anmarques Mar 30, 2022
f36cc4d
Updated documentation to reflect changes.
anmarques Mar 30, 2022
416e938
Updated documentation to reflect changes.
anmarques Mar 30, 2022
f56d330
Fixed default weights data type.
anmarques Mar 30, 2022
6a3fa1d
Style and quality fixes.
anmarques Mar 30, 2022
011fce9
Removed unused method
anmarques Mar 30, 2022
30e61f3
Removed output quantization from conv layers
anmarques Mar 9, 2022
757fad6
Added _Add_ReLU module that enables QATWrapper for quantizaiton.
anmarques Mar 10, 2022
398ae3e
Removed quantization of output for linear and conv layers by default.…
anmarques Mar 10, 2022
4da2e8f
Minor fixes. Style and quality fixes.
anmarques Mar 10, 2022
a9f2b40
Added support to freezing bn stats.
anmarques Mar 10, 2022
bbbc1b3
Added mode argument to wrapping of train function in BNWrapper
anmarques Mar 10, 2022
2817614
Set BN fusing back as default.
anmarques Mar 10, 2022
2fb23c0
Set BN fusing back as default.
anmarques Mar 10, 2022
572bfbc
Fixed custom freeze_bn_stats.
anmarques Mar 12, 2022
c397523
Temporary files for evaluating changes to graphs.
anmarques Mar 14, 2022
ebfcae8
Added support to tensorrt flag. Moved the computation of quantization…
anmarques Mar 17, 2022
1edd77d
Added support to TensorRT quantization
anmarques Mar 20, 2022
b26df33
Included check to account for when weight_qconfig_kwatgs is None.
anmarques Mar 21, 2022
2f85a4b
Removed output quantization from conv layers
anmarques Mar 9, 2022
c0940dd
Added _Add_ReLU module that enables QATWrapper for quantizaiton.
anmarques Mar 10, 2022
3b30724
Removed quantization of output for linear and conv layers by default.…
anmarques Mar 10, 2022
ea18f93
Minor fixes. Style and quality fixes.
anmarques Mar 10, 2022
7475a5b
Added support to freezing bn stats.
anmarques Mar 10, 2022
cc0fc7c
Added mode argument to wrapping of train function in BNWrapper
anmarques Mar 10, 2022
2eda233
Set BN fusing back as default.
anmarques Mar 10, 2022
1ed0ac1
Set BN fusing back as default.
anmarques Mar 10, 2022
c07e24a
Fixed custom freeze_bn_stats.
anmarques Mar 12, 2022
cb77f95
Temporary files for evaluating changes to graphs.
anmarques Mar 14, 2022
4299dba
Added support to tensorrt flag. Moved the computation of quantization…
anmarques Mar 17, 2022
b3d7340
Added support to TensorRT quantization
anmarques Mar 20, 2022
6976650
Included check to account for when weight_qconfig_kwatgs is None.
anmarques Mar 21, 2022
bdb1d21
Modified argument names for backwards compatibility.
anmarques Mar 30, 2022
491b071
Updated documentation to reflect changes.
anmarques Mar 30, 2022
e40b509
Updated documentation to reflect changes.
anmarques Mar 30, 2022
10134b8
Updated documentation to reflect changes.
anmarques Mar 30, 2022
4ed31b4
Fixed default weights data type.
anmarques Mar 30, 2022
f5ec19f
Style and quality fixes.
anmarques Mar 30, 2022
cb9d75e
Removed unused method
anmarques Mar 30, 2022
60eed5c
Removed testing files
anmarques Mar 31, 2022
c1c5e14
Style and quality fixes.
anmarques Mar 31, 2022
c014872
Changed call to get_qat_qconfig to not specify symmetry and data type…
anmarques Apr 5, 2022
a324902
Changed default number of activation and weight bits from None to 8.
anmarques Apr 5, 2022
38fb750
Revert "Changed default number of activation and weight bits from Non…
anmarques Apr 5, 2022
28c9422
Revert "Changed call to get_qat_qconfig to not specify symmetry and d…
anmarques Apr 5, 2022
d687ea8
Lumped qconfig properties into a dataclass.
anmarques Apr 5, 2022
94509ce
Lumped qconfig properties into a dataclass.
anmarques Apr 5, 2022
9786433
Lumped qconfig properties into a dataclass.
anmarques Apr 5, 2022
59f68c3
Merge remote-tracking branch 'origin/quantization-refactor' into quan…
anmarques Apr 5, 2022
6922bf9
Resetting conv and linear activation flags to True.
anmarques Apr 5, 2022
2c16ad8
Merge branch 'main' into quantization-refactor
anmarques Apr 7, 2022
e7e47be
Renamed class BNWrapper as _BNWrapper.
anmarques Apr 8, 2022
ffd8195
Added logging messages for when tensorrt forces overriding of configs.
anmarques Apr 8, 2022
808e429
Style and quality fixes.
anmarques Apr 8, 2022
1a57909
ConvInteger quantization conversion for quant refactor (#644)
bfineran Apr 8, 2022
194fb16
Quantization Refactor Tests (#685)
bfineran Apr 8, 2022
5b605f5
Merge branch 'main' into quantization-refactor
bfineran Apr 8, 2022
de70118
Merge branch 'main' into quantization-refactor
anmarques Apr 8, 2022
4f7d425
Merge branch 'main' into quantization-refactor
anmarques Apr 8, 2022
e6b099e
Merge branch 'main' into quantization-refactor
spacemanidol Apr 8, 2022
5f74e31
rebase import fix
Apr 8, 2022
2ea8270
Merge branch 'main' into quantization-refactor
bfineran Apr 8, 2022
c863017
Merge branch 'main' into quantization-refactor
bfineran Apr 8, 2022
5796f4f
update manager serialization test cases for new quantization params
Apr 8, 2022
91243ff
Merge branch 'quantization-refactor' of github.com:neuralmagic/sparse…
Apr 8, 2022
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
48 changes: 26 additions & 22 deletions src/sparseml/pytorch/models/classification/resnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
except Exception:
FloatFunctional = None


__all__ = [
"ResNetSectionSettings",
"ResNet",
Expand Down Expand Up @@ -141,6 +140,28 @@ def required(in_channels: int, out_channels: int, stride: int) -> bool:
return in_channels != out_channels or stride > 1


class _AddReLU(Module):
"""
Wrapper for the FloatFunctional class that enables QATWrapper used to
quantize the first input to the Add operation
"""

def __init__(self, num_channels):
super().__init__()
if FloatFunctional:
self.functional = FloatFunctional()
self.wrap_qat = True
self.qat_wrapper_kwargs = {"num_inputs": 1, "num_outputs": 0}
else:
self.functional = ReLU(num_channels=num_channels, inplace=True)

def forward(self, x, y):
if isinstance(self.functional, FloatFunctional):
return self.functional.add_relu(x, y)
else:
return self.functional(x + y)


class _BasicBlock(Module):
def __init__(self, in_channels: int, out_channels: int, stride: int = 1):
super().__init__()
Expand All @@ -164,11 +185,7 @@ def __init__(self, in_channels: int, out_channels: int, stride: int = 1):
else None
)

self.add_relu = (
FloatFunctional()
if FloatFunctional is not None
else ReLU(num_channels=out_channels, inplace=True)
)
self.add_relu = _AddReLU(out_channels)

self.initialize()

Expand All @@ -181,12 +198,7 @@ def forward(self, inp: Tensor):
out = self.bn2(out)

identity_val = self.identity(inp) if self.identity is not None else inp

if isinstance(self.add_relu, FloatFunctional):
out = self.add_relu.add_relu(out, identity_val)
else:
out += identity_val
out = self.add_relu(out)
out = self.add_relu(identity_val, out)

return out

Expand Down Expand Up @@ -230,11 +242,7 @@ def __init__(
else None
)

self.add_relu = (
FloatFunctional()
if FloatFunctional is not None
else ReLU(num_channels=out_channels, inplace=True)
)
self.add_relu = _AddReLU(out_channels)

self.initialize()

Expand All @@ -252,11 +260,7 @@ def forward(self, inp: Tensor):

identity_val = self.identity(inp) if self.identity is not None else inp

if isinstance(self.add_relu, FloatFunctional):
out = self.add_relu.add_relu(out, identity_val)
else:
out += identity_val
out = self.add_relu(out)
out = self.add_relu(identity_val, out)

return out

Expand Down
Loading