Skip to content

Commit

Permalink
[PaddleV3] 添加 pytorchaten::aten_linalg_vector_norm 的算子映射并修复相关模型 (
Browse files Browse the repository at this point in the history
#1076)

* [Add] pytorch aten::linalg_vector_norm and fix models

* [Update] black.list
  • Loading branch information
megemini authored Oct 31, 2024
1 parent c20a276 commit 4fd7f4e
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 8 deletions.
1 change: 0 additions & 1 deletion test_benchmark/PyTorch/GRU/deploy_infer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import numpy as np
import paddle
import paddle.fluid as fluid
from paddle.inference import Config
from paddle.inference import create_predictor

Expand Down
8 changes: 2 additions & 6 deletions test_benchmark/PyTorch/GRU/pd_infer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from __future__ import print_function
import paddle.fluid as fluid
import paddle
import sys
import os
Expand All @@ -14,11 +13,8 @@
# trace
paddle.enable_static()
exe = paddle.static.Executor(paddle.CPUPlace())
[prog, inputs, outputs] = fluid.io.load_inference_model(
dirname="pd_model_trace/inference_model/",
executor=exe,
model_filename="model.pdmodel",
params_filename="model.pdiparams")
[prog, inputs, outputs] = paddle.static.load_inference_model(
path_prefix="pd_model_trace/inference_model/model", executor=exe)
result = exe.run(prog, feed={inputs[0]: input_data}, fetch_list=outputs)
abs_diff = np.max(np.abs(pytorch_result - result[0]))
print(abs_diff)
Expand Down
1 change: 0 additions & 1 deletion test_benchmark/PyTorch/black.list
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ CamembertForQuestionAnswering
DPRContextEncoder
EasyOCR_detector
EasyOCR_recognizer
GRU
MiniFasNet
MockingBird
Roberta
Expand Down
4 changes: 4 additions & 0 deletions x2paddle/op_mapper/pytorch2paddle/aten.py
Original file line number Diff line number Diff line change
Expand Up @@ -4198,6 +4198,10 @@ def aten_norm(mapper, graph, node):
return current_inputs, current_outputs


# pytorch has one more param: `dtype`, which is not used.
aten_linalg_vector_norm = aten_norm


def aten___not__(mapper, graph, node):
""" 构造对bool型取负的PaddleLayer。
TorchScript示例:
Expand Down

0 comments on commit 4fd7f4e

Please sign in to comment.