* Dispose the memory if the dataId has 0 refCount. Return true if the memory * is released or memory is not managed in this backend, false if memory is * not cleared. * @param dataId * @oaram force Optional, remove the data regardless of refCount
(dataId: DataId, force = false)
| 174 | * @oaram force Optional, remove the data regardless of refCount |
| 175 | */ |
| 176 | override disposeData(dataId: DataId, force = false): boolean { |
| 177 | if (this.data.has(dataId)) { |
| 178 | this.data.get(dataId).refCount--; |
| 179 | if (!force && this.data.get(dataId).refCount > 0) { |
| 180 | return false; |
| 181 | } |
| 182 | |
| 183 | const {complexTensorInfos} = this.data.get(dataId); |
| 184 | |
| 185 | if (complexTensorInfos != null) { |
| 186 | this.disposeData(complexTensorInfos.real.dataId, true); |
| 187 | this.disposeData(complexTensorInfos.imag.dataId, true); |
| 188 | } |
| 189 | |
| 190 | this.data.delete(dataId); |
| 191 | } |
| 192 | return true; |
| 193 | } |
| 194 | |
| 195 | disposeIntermediateTensorInfo(tensorInfo: TensorInfo): void { |
| 196 | this.disposeData(tensorInfo.dataId); |
no test coverage detected