-
Notifications
You must be signed in to change notification settings - Fork 825
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
consistent_tensor_infer_cache: fix memory leak #5938
consistent_tensor_infer_cache: fix memory leak #5938
Conversation
@@ -217,8 +217,8 @@ Maybe<void> CheckIsDeviceSupportedByOp(const ParallelDesc& parallel_desc, | |||
// The inferred results can be retrieved by op->NdSbp4BnInOp(obn). | |||
JUST(op->InferNdSbpSignatureIf(nd_sbp_constraints, *parallel_desc, NdSbpInferHint4Ibn)); | |||
} | |||
auto* result = | |||
new ConsistentTensorInferResult(user_op_expr.input_size(), user_op_expr.output_size()); | |||
auto result = std::make_unique<ConsistentTensorInferResult>(user_op_expr.input_size(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里可以直接 make_shared 吗,然后 243 行直接返回
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
没啥必要,这里如果 make_shared 的话只能 std::make_shared<ConsistentTensorInferResult>
(后面要调用 non-const 成员函数),但是返回值要求 std::shared_ptr<const ConsistentTensorInferResult>
,还是需要转换类型,shared_ptr 本身开销比 unique_ptr 大。
detected by clang static analyzer: