* Dispose the memory if the dataId has 0 refCount. Return true if the memory * is released or delayed in this backend, false if there are still * references. * @param dataId * @oaram force Optional, remove the data regardless of refCount
(dataId: DataId, force = false)
| 181 | * @oaram force Optional, remove the data regardless of refCount |
| 182 | */ |
| 183 | override disposeData(dataId: DataId, force = false): boolean { |
| 184 | // No-op if already disposed. |
| 185 | if (!this.tensorMap.has(dataId)) { |
| 186 | return true; |
| 187 | } |
| 188 | |
| 189 | const tensorData = this.tensorMap.get(dataId); |
| 190 | if (force) { |
| 191 | tensorData.refCount = 0; |
| 192 | } else { |
| 193 | tensorData.refCount--; |
| 194 | } |
| 195 | |
| 196 | if (tensorData.refCount > 0) { |
| 197 | return false; |
| 198 | } |
| 199 | |
| 200 | if (tensorData.complexTensorInfos != null) { |
| 201 | this.disposeData(tensorData.complexTensorInfos.real.dataId); |
| 202 | this.disposeData(tensorData.complexTensorInfos.imag.dataId); |
| 203 | } |
| 204 | |
| 205 | if (this.commandQueueOwnedIds.has(dataId)) { |
| 206 | this.tensorDataPendingDisposal.push(dataId); |
| 207 | return true; |
| 208 | } |
| 209 | |
| 210 | this.releaseResource(dataId); |
| 211 | this.tensorMap.delete(dataId); |
| 212 | |
| 213 | return true; |
| 214 | } |
| 215 | |
| 216 | override memory(): WebGPUMemoryInfo { |
| 217 | return { |
nothing calls this directly
no test coverage detected