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

Update op_def_struct.h to fix memory leak #888

Merged
merged 3 commits into from
Feb 9, 2025
Merged
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
8 changes: 4 additions & 4 deletions include/op_def_struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -286,18 +286,18 @@ struct OrtLiteCustomStructV2 : public OrtLiteCustomOp {
};

template <typename RType, typename... Args>
OrtLiteCustomOp* CreateLiteCustomOpV2(const char* op_name,
std::shared_ptr<OrtLiteCustomOp> CreateLiteCustomOpV2(const char* op_name,
wenbingl marked this conversation as resolved.
Show resolved Hide resolved
const char* execution_provider,
RType (*custom_compute_fn)(Args...)) {
using LiteOp = OrtLiteCustomStructV2<FunctionKernel<RType, Args...>>;
return std::make_unique<LiteOp>(op_name, execution_provider, custom_compute_fn).release();
return std::make_shared<LiteOp>(op_name, execution_provider, custom_compute_fn);
}

template <typename OpKernel>
OrtLiteCustomOp* CreateLiteCustomOpV2(const char* op_name,
std::shared_ptr<OrtLiteCustomOp> CreateLiteCustomOpV2(const char* op_name,
const char* execution_provider) {
using LiteOp = OrtLiteCustomStructV2<OpKernel>;
return std::make_unique<LiteOp>(op_name, execution_provider).release();
return std::make_shared<LiteOp>(op_name, execution_provider);
}

} // namespace Custom
Expand Down