@@ -104,7 +104,10 @@ function plan_elementwise_trinary(
104
104
plan_pref = Ref {cutensorPlanPreference_t} ()
105
105
cutensorCreatePlanPreference (handle (), plan_pref, algo, jit)
106
106
107
- CuTensorPlan (desc[], plan_pref[]; workspacePref= workspace)
107
+ plan = CuTensorPlan (desc[], plan_pref[]; workspacePref= workspace)
108
+ cutensorDestroyOperationDescriptor (desc[])
109
+ cutensorDestroyPlanPreference (plan_pref[])
110
+ return plan
108
111
end
109
112
110
113
function elementwise_binary_execute! (
@@ -186,7 +189,10 @@ function plan_elementwise_binary(
186
189
plan_pref = Ref {cutensorPlanPreference_t} ()
187
190
cutensorCreatePlanPreference (handle (), plan_pref, algo, jit)
188
191
189
- CuTensorPlan (desc[], plan_pref[]; workspacePref= workspace)
192
+ plan = CuTensorPlan (desc[], plan_pref[]; workspacePref= workspace)
193
+ cutensorDestroyOperationDescriptor (desc[])
194
+ cutensorDestroyPlanPreference (plan_pref[])
195
+ return plan
190
196
end
191
197
192
198
function permute! (
@@ -253,7 +259,10 @@ function plan_permutation(
253
259
plan_pref = Ref {cutensorPlanPreference_t} ()
254
260
cutensorCreatePlanPreference (handle (), plan_pref, algo, jit)
255
261
256
- CuTensorPlan (desc[], plan_pref[]; workspacePref= workspace)
262
+ plan = CuTensorPlan (desc[], plan_pref[]; workspacePref= workspace)
263
+ cutensorDestroyOperationDescriptor (desc[])
264
+ cutensorDestroyPlanPreference (plan_pref[])
265
+ return plan
257
266
end
258
267
259
268
function contract! (
@@ -340,7 +349,10 @@ function plan_contraction(
340
349
plan_pref = Ref {cutensorPlanPreference_t} ()
341
350
cutensorCreatePlanPreference (handle (), plan_pref, algo, jit)
342
351
343
- CuTensorPlan (desc[], plan_pref[]; workspacePref= workspace)
352
+ plan = CuTensorPlan (desc[], plan_pref[]; workspacePref= workspace)
353
+ cutensorDestroyOperationDescriptor (desc[])
354
+ cutensorDestroyPlanPreference (plan_pref[])
355
+ return plan
344
356
end
345
357
346
358
function reduce! (
@@ -415,5 +427,8 @@ function plan_reduction(
415
427
plan_pref = Ref {cutensorPlanPreference_t} ()
416
428
cutensorCreatePlanPreference (handle (), plan_pref, algo, jit)
417
429
418
- CuTensorPlan (desc[], plan_pref[]; workspacePref= workspace)
430
+ plan = CuTensorPlan (desc[], plan_pref[]; workspacePref= workspace)
431
+ cutensorDestroyOperationDescriptor (desc[])
432
+ cutensorDestroyPlanPreference (plan_pref[])
433
+ return plan
419
434
end
0 commit comments