Skip to content

Commit e89b5a8

Browse files
committed
[NNCF] Add get_bias_shape_legacy function (openvinotoolkit#3249)
Changes: Moved and renamed backend-specific class method from common layer attributes in nncf/common/graph/layer_attributes.py to self-contained function in nncf/common/graph/utils.py - layer_attributes.get_bias_shape -> get_bias_shape_legacy(layer_attributes: WeightedLayerAttributes) Reason for changes: (openvinotoolkit#3249) Torch and Tensorflow backend-specific methods need to be removed from common layer attributes and all related calls need to be replaced by their corresponding legacy function calls
1 parent 61d0cc4 commit e89b5a8

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

nncf/common/graph/utils.py

+12
Original file line numberDiff line numberDiff line change
@@ -178,3 +178,15 @@ def get_target_dim_for_compression_legacy(
178178
if layer_attributes.transpose:
179179
return 1
180180
return 0
181+
182+
183+
def get_bias_shape_legacy(
184+
layer_attributes: WeightedLayerAttributes) -> int:
185+
"""
186+
Returns hard-coded bias shape only for Torch and Tensorflow models.
187+
188+
:param layer_attributes: layer attributes of NNCFNode.
189+
:return: bias shape.
190+
"""
191+
if isinstance(layer_attributes, LinearLayerAttributes):
192+
return layer_attributes.out_features if layer_attributes.with_bias is True else 0

0 commit comments

Comments
 (0)