Skip to content

Commit

Permalink
修正了resize op与Prelu op执行时可能出现的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhangZhiPku authored Jan 31, 2024
1 parent 4303112 commit a2b4197
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions ppq/executor/op/torch/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -1454,8 +1454,14 @@ def Resize_forward(op: Operation, values: List[torch.Tensor], ctx: TorchBackendC
value = values[0]
# Not used roi
# roi = input_value[1] if len(input_value) > 1 else None
scale_factor = values[2].cpu() if len(values) > 2 else None
size = values[-1].cpu().tolist() if (len(values) == 4 and values[-1] != None) else None
# PATCH 20240131
# IF RESIZE HAS ONLY 2 INPUT, THEN MARK SECOND INPUT AS SCALES
if len(values) == 2:
scale_factor = values[-1].cpu()
else:
scale_factor = values[2].cpu() if len(values) > 2 else None
size = values[-1].cpu().tolist() if (len(values) == 4 and values[-1] != None) else None

mode = op.attributes.get('mode', 'nearest')
if mode == 'cubic':
mode = 'bicubic'
Expand Down Expand Up @@ -2133,7 +2139,7 @@ def ReduceL2_forward(op: Operation, values: List[torch.Tensor], ctx: TorchBacken

def PRelu_forward(op: Operation, values: List[torch.Tensor], ctx: TorchBackendContext = None, **kwargs):
input_data, weight = values
output = F.prelu(input_data, weight)
output = F.prelu(input_data, weight.squeeze())
return output


Expand Down

0 comments on commit a2b4197

Please sign in to comment.