MCPcopy Create free account
hub / github.com/evilsocket/cake / get_or_upload

Method get_or_upload

cake-core/src/backends/rocm/mod.rs:249–261  ·  view source on GitHub ↗
(&self, tensor: &Tensor)

Source from the content-addressed store, hash-verified

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> {

Callers 1

tensor_matmulMethod · 0.45

Calls 3

as_ptrMethod · 0.80
gpu_uploadMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected