Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[Paddle-TRT] fix_fill_constant #44481

Merged
merged 3 commits into from
Jul 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions paddle/fluid/inference/tensorrt/convert/fill_constant_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ class FillConstantOpConverter : public OpConverter {
PADDLE_GET_CONST(std::string, op_desc.GetAttr("str_value"));
std::vector<int64_t> shape =
PADDLE_GET_CONST(std::vector<int64_t>, op_desc.GetAttr("shape"));
if (str_value == "") {
float value = PADDLE_GET_CONST(float, op_desc.GetAttr("value"));
str_value = std::to_string(value);
}
std::unique_ptr<framework::Tensor> out_tensor(new framework::Tensor());
out_tensor->Resize(phi::make_ddim(shape));
nvinfer1::DataType trt_dtype = nvinfer1::DataType::kFLOAT;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,14 @@ def generate_shapelist_data(attrs: List[Dict[str, Any]]):
for dtype in [5, 2, 3]:
for str_value in ["2", "23", "-1"]:
self.num_input = num_input
value = float(str_value)
if np.random.choice([False, True]):
str_value = str_value
else:
str_value = ""
dics = [{
"str_value": str_value,
"value": value,
"shape": shape,
"dtype": dtype
}, {
Expand Down