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

Method cache_activation

cake-core/src/backends/vulkan/mod.rs:552–563  ·  view source on GitHub ↗

Cache a dispatch output buffer by the returned Tensor's TensorId. If the next dispatch consumes this tensor, `get_or_upload` will find the buffer here and skip the re-upload.

(&self, tensor_id: TensorId, buf: MappedBuffer)

Source from the content-addressed store, hash-verified

550 /// If the next dispatch consumes this tensor, `get_or_upload` will find
551 /// the buffer here and skip the re-upload.
552 fn cache_activation(&self, tensor_id: TensorId, buf: MappedBuffer) {
553 let buf = Arc::new(buf);
554 let mut act_cache = self.activation_cache.lock().unwrap();
555 if act_cache.len() >= 16 {
556 // Evict oldest entry, release its buffer back to pool
557 let (_, old_buf) = act_cache.remove(0);
558 if let Ok(old) = Arc::try_unwrap(old_buf) {
559 self.release_output(old);
560 }
561 }
562 act_cache.push((tensor_id, buf));
563 }
564
565 /// Compute a stable cache key from tensor's storage pointer + layout.
566 /// Survives `.t()` calls which create new TensorIds but share storage.

Callers 5

dispatch_binary_vec4Method · 0.80
dispatch_ternary_vec4Method · 0.80
dispatch_unary_vec4Method · 0.80
dispatch_softmaxMethod · 0.80
tensor_matmulMethod · 0.80

Calls 2

release_outputMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected