Skip to content

Clean up cuTENSOR plan memory #212

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

Merged
merged 1 commit into from
Jun 30, 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
5 changes: 4 additions & 1 deletion ext/TensorOperationscuTENSORExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,10 @@ function plan_trace(@nospecialize(A::AbstractArray), Ainds::ModeType,
plan_pref = Ref{cutensorPlanPreference_t}()
cutensorCreatePlanPreference(handle(), plan_pref, algo, jit)

return CuTensorPlan(desc[], plan_pref[]; workspacePref=workspace)
plan = CuTensorPlan(desc[], plan_pref[]; workspacePref=workspace)
Copy link
Owner

Choose a reason for hiding this comment

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

So how does this work; the OperationDescriptor and PlanPreference are copied by the CuTensorPlan constructor, so the original copies need to be destroyed afterwards?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think they are used, and then no longer needed. To be honest, I didn’t check precisely what is going on the first time and just copied this over from the cuTENSOR implementation for reductions, so now I just adapted the changes from the PR there

cuTENSOR.cutensorDestroyOperationDescriptor(desc[])
cuTENSOR.cutensorDestroyPlanPreference(plan_pref[])
return plan
end

end
Loading