@@ -1002,7 +1002,6 @@ inline void wait(Context &ctx, std::future<void> &future) {
10021002inline  void  toCPU (Context &ctx, Tensor &tensor, void  *data, size_t  bufferSize,
10031003                  CopyData &op) {
10041004  wgpuQueueSubmit (ctx.queue , 1 , &op.commandBuffer );
1005-   wgpuCommandBufferRelease (op.commandBuffer );
10061005  CallbackData callbackData = {op.readbackBuffer , bufferSize, data, &op.promise ,
10071006                               &op.future };
10081007  wgpuQueueOnSubmittedWorkDone (
@@ -1063,14 +1062,9 @@ inline void toCPU(Context &ctx, Tensor &tensor, void *data, size_t bufferSize) {
10631062    wgpuCommandEncoderCopyBufferToBuffer (commandEncoder, tensor.data .buffer , 0 ,
10641063                                         op.readbackBuffer , 0 , bufferSize);
10651064    op.commandBuffer  = wgpuCommandEncoderFinish (commandEncoder, nullptr );
1066-     wgpuComputePassEncoderRelease (computePassEncoder);
1067-     wgpuCommandEncoderRelease (commandEncoder);
10681065    check (op.commandBuffer , " Create command buffer"  , __FILE__, __LINE__);
10691066  }
10701067  toCPU (ctx, tensor, data, bufferSize, op);
1071-   if  (op.readbackBuffer ) {
1072-     wgpuBufferRelease (op.readbackBuffer );
1073-   }
10741068}
10751069
10761070/* *
@@ -1109,12 +1103,9 @@ inline void toCPU(Context &ctx, WGPUBuffer buffer, void *data,
11091103    wgpuCommandEncoderCopyBufferToBuffer (commandEncoder, buffer, 0 ,
11101104                                         op.readbackBuffer , 0 , bufferSize);
11111105    op.commandBuffer  = wgpuCommandEncoderFinish (commandEncoder, nullptr );
1112-     wgpuComputePassEncoderRelease (computePassEncoder);
1113-     wgpuCommandEncoderRelease (commandEncoder);
11141106    check (op.commandBuffer , " Create command buffer"  , __FILE__, __LINE__);
11151107  }
11161108  wgpuQueueSubmit (ctx.queue , 1 , &op.commandBuffer );
1117-   wgpuCommandBufferRelease (op.commandBuffer );
11181109  CallbackData callbackData = {op.readbackBuffer , bufferSize, data, &op.promise ,
11191110                               &op.future };
11201111  wgpuQueueOnSubmittedWorkDone (
@@ -1140,9 +1131,6 @@ inline void toCPU(Context &ctx, WGPUBuffer buffer, void *data,
11401131      },
11411132      &callbackData);
11421133  wait (ctx, op.future );
1143-   if  (op.readbackBuffer ) {
1144-     wgpuBufferRelease (op.readbackBuffer );
1145-   }
11461134}
11471135
11481136
@@ -1229,9 +1217,6 @@ inline void resetCommandBuffer(WGPUDevice &device, Kernel &op) {
12291217        op->totalWorkgroups [2 ]);
12301218    wgpuComputePassEncoderEnd (computePassEncoder);
12311219    op->commandBuffer  = wgpuCommandEncoderFinish (commandEncoder, nullptr );
1232-     wgpuComputePassEncoderRelease (computePassEncoder);
1233-     wgpuCommandEncoderRelease (commandEncoder);
1234- 
12351220    op->used  = false ;
12361221  }
12371222}
@@ -1522,7 +1507,6 @@ inline void dispatchKernel(Context &ctx, Kernel &kernel,
15221507    resetCommandBuffer (ctx.device , kernel);
15231508  }
15241509  wgpuQueueSubmit (ctx.queue , 1 , &kernel->commandBuffer );
1525-   wgpuCommandBufferRelease (kernel->commandBuffer );
15261510  kernel->used  = true ;
15271511  wgpuQueueOnSubmittedWorkDone (
15281512      ctx.queue ,
0 commit comments