Frees allocated device-side memory
(self)
| 118 | self.free() |
| 119 | |
| 120 | def free(self): |
| 121 | """ |
| 122 | Frees allocated device-side memory |
| 123 | """ |
| 124 | # Free any device memory allocated manually |
| 125 | if not cutlass_cppgen.use_rmm: |
| 126 | for name, buf in self.buffers.items(): |
| 127 | if isinstance(buf, DevicePtrWrapper): |
| 128 | err, = cudart.cudaFree(buf.ptr) |
| 129 | if err != cudart.cudaError_t.cudaSuccess: |
| 130 | raise RuntimeError(f"cudaFree failed with error {err}") |
| 131 | |
| 132 | if hasattr(self, "workspace_buffer") and isinstance(self.workspace_buffer, DevicePtrWrapper): |
| 133 | err, = cudart.cudaFree(self.workspace_buffer.ptr) |
| 134 | if err != cudart.cudaError_t.cudaSuccess: |
| 135 | raise RuntimeError(f"cudaFree failed with error {err}") |
| 136 | del self.workspace_buffer |