File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed
Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -1270,6 +1270,8 @@ def choose_qparams_affine_with_min_max(
12701270 if eps is None :
12711271 eps = torch .finfo (min_val .dtype ).eps
12721272
1273+ scale_device = min_val .device
1274+
12731275 if preserve_zero :
12741276 min_val_neg = torch .min (min_val , torch .zeros_like (min_val ))
12751277 max_val_pos = torch .max (max_val , torch .zeros_like (max_val ))
@@ -1316,7 +1318,9 @@ def choose_qparams_affine_with_min_max(
13161318 scale = torch .clamp (scale , min = eps )
13171319 else :
13181320 assert mapping_type == MappingType .ASYMMETRIC
1319- scale = (max_val_pos - min_val_neg ) / float (quant_max - quant_min )
1321+ scale = (max_val_pos - min_val_neg ) / torch .tensor (
1322+ float (quant_max - quant_min ), dtype = scale_dtype , device = scale_device
1323+ )
13201324 scale = torch .clamp (scale , min = eps )
13211325 if zero_point_domain == ZeroPointDomain .NONE :
13221326 zero_point = None
You can’t perform that action at this time.
0 commit comments