Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[Paddle Inference] Add add eye trt converter #48937

Closed
wants to merge 17 commits into from
Closed

[Paddle Inference] Add add eye trt converter #48937

wants to merge 17 commits into from

Conversation

DrRyanHuang
Copy link
Member

PR types

Others

PR changes

Others

Describe

#48292

@paddle-bot
Copy link

paddle-bot bot commented Dec 8, 2022

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

// Declare inputs attr
const int num_rows = PADDLE_GET_CONST(int, op_desc.GetAttr("num_rows"));
int num_columns = PADDLE_GET_CONST(int, op_desc.GetAttr("num_columns"));
const int dtype = PADDLE_GET_CONST(int, op_desc.GetAttr("dtype"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以改成

    auto dtype = static_cast<framework::proto::VarType::Type>(
        PADDLE_GET_CONST(int, op_desc.GetAttr("dtype")));

Comment on lines 79 to 82
if (-1 == num_columns) {
input_shape.d[1] = num_rows;
num_columns = num_rows;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

num_columns为默认值-1时,num_columns=num_rows, 这段逻辑可以放在input_shape.d赋值前

}

std::vector<T> constant_arr(num_rows * num_columns, 0);
for (int i = 0; i < std::min(num_rows, num_columns); i++) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::min(num_rows, num_columns) 放循环外避免多次调用std::min

Comment on lines 52 to 72
nvinfer1::DataType nv_type = nvinfer1::DataType::kFLOAT;
switch (dtype) {
case paddle::framework::proto::VarType::FP32:
nv_type = nvinfer1::DataType::kFLOAT;
typedef float T;
break;
case paddle::framework::proto::VarType::FP16:
nv_type = nvinfer1::DataType::kHALF;
typedef uint16_t T;
break;
case paddle::framework::proto::VarType::INT32:
nv_type = nvinfer1::DataType::kINT32;
typedef int32_t T;
break;
default:
paddle::platform::errors::InvalidArgument(
"Paddle-TRT loads weighths failed, found not supported data type "
"%s.",
dtype);
break;
}
Copy link
Contributor

@zhangjun zhangjun Dec 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里T类型声明编译报错,可以参考convert/fill_constant_op.cc 中写法,进行不同类型数组赋值

for _ in range(6):
if np.random.random() > 0.5:
num_rows = generate_input_attr1()
attr_dic = {"num_rows": num_rows}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以加一个num_columns为-1。两处attr_dic中添加一个dtype字段,37-38行之间添加一层for循环用于dtype赋值,

for dtype in [2, 4, 5]

@DrRyanHuang DrRyanHuang marked this pull request as draft December 11, 2022 05:37
@DrRyanHuang DrRyanHuang marked this pull request as ready for review December 11, 2022 05:40
@DrRyanHuang
Copy link
Member Author

DrRyanHuang commented Dec 11, 2022

2022-12-11 14:07:46 ======================================================================
2022-12-11 14:07:46 ERROR: test (test_trt_convert_eye.TrtConvertEyeTest)
2022-12-11 14:07:46 ----------------------------------------------------------------------
2022-12-11 14:07:46 Traceback (most recent call last):
2022-12-11 14:07:46   File "/mnt/paddle/build/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_eye.py", line 104, in test
2022-12-11 14:07:46     self.run_test()
2022-12-11 14:07:46   File "/mnt/paddle/build/python/paddle/fluid/tests/unittests/ir/inference/auto_scan_test.py", line 773, in run_test
2022-12-11 14:07:46     self.run_test_config(
2022-12-11 14:07:46   File "/mnt/paddle/build/python/paddle/fluid/tests/unittests/ir/inference/auto_scan_test.py", line 130, in run_test_config
2022-12-11 14:07:46     predictor = paddle_infer.create_predictor(pred_config)
2022-12-11 14:07:46 ValueError: 
2022-12-11 14:07:46 
2022-12-11 14:07:46 --------------------------------------
2022-12-11 14:07:46 C++ Traceback (most recent call last):
2022-12-11 14:07:46 --------------------------------------
2022-12-11 14:07:46 0   paddle_infer::Predictor::Predictor(paddle::AnalysisConfig const&)
2022-12-11 14:07:46 1   std::unique_ptr<paddle::PaddlePredictor, std::default_delete<paddle::PaddlePredictor> > paddle::CreatePaddlePredictor<paddle::AnalysisConfig, (paddle::PaddleEngineKind)2>(paddle::AnalysisConfig const&)

2022-12-11 14:07:46 15  phi::enforce::GetCurrentTraceBackString[abi:cxx11](bool)
2022-12-11 14:07:46 
2022-12-11 14:07:46 ----------------------
2022-12-11 14:07:46 Error Message Summary:
2022-12-11 14:07:46 ----------------------
2022-12-11 14:07:46 InvalidArgumentError: The Variable type must be St6vectorIN6paddle7variantIJN3phi11DenseTensorENS2_11TensorArrayESt13unordered_mapINSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEEiSt4hashISB_ESt8equal_toISB_ESaISt4pairIKSB_iEEENS2_15SparseCooTensorEEEESaISM_EE, but the type it holds is N3phi11DenseTensorE.
2022-12-11 14:07:46   [Hint: Expected holder_->Type() == VarTypeTrait<T>::kId, but received holder_->Type():7 != VarTypeTrait<T>::kId:10.] (at /paddle/paddle/fluid/framework/variable.h:58)
2022-12-11 14:07:46   [operator < fetch > error]
2022-12-11 14:07:46 
2022-12-11 14:07:46 ----------------------------------------------------------------------
2022-12-11 14:07:46 Ran 1 test in 2.530s
2022-12-11 14:07:46 
2022-12-11 14:07:46 FAILED (errors=1)

@zhangjun 打扰了,问一下这个 Variable 是指哪个变量呀?🥲

@paddle-bot
Copy link

paddle-bot bot commented Dec 16, 2022

很抱歉,经过我们的反复讨论,你的PR暂未达到合入标准,请阅读飞桨原生算子开发规范,你可以重新提交新的PR,我们先将此PR关闭,感谢你的贡献。
Sorry to inform you that through our discussion, your PR fails to meet the merging standard (Reference: Paddle Custom Operator Design Doc). You can also submit an new one. Thank you.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
contributor External developers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants