(&self, tensor: &Tensor)
| 247 | |
| 248 | #[inline] |
| 249 | fn get_or_upload(&self, tensor: &Tensor) -> Result<*const f32> { |
| 250 | let id = tensor.id(); |
| 251 | // Fast path: read lock for cache hit (no write contention) |
| 252 | if let Some(buf) = self.cache.read().unwrap().get(&id) { |
| 253 | return Ok(buf.as_ptr()); |
| 254 | } |
| 255 | // Slow path: write lock for cache miss |
| 256 | let data = Self::to_f32_vec(tensor)?; |
| 257 | let buf = self.gpu_upload(&data)?; |
| 258 | let ptr = buf.as_ptr(); |
| 259 | self.cache.write().unwrap().insert(id, buf); |
| 260 | Ok(ptr) |
| 261 | } |
| 262 | |
| 263 | #[inline] |
| 264 | fn rocblas_gemm(&self, a: *const f32, b: *const f32, m: usize, k: usize, n: usize) -> Result<GpuBuf> { |
no test coverage detected