MCPcopy
hub / github.com/FoundationVision/LlamaGen / update

Method update

autoregressive/models/gpt.py:177–185  ·  view source on GitHub ↗
(self, input_pos, k_val, v_val)

Source from the content-addressed store, hash-verified

175 self.register_buffer('v_cache', torch.zeros(cache_shape, dtype=dtype))
176
177 def update(self, input_pos, k_val, v_val):
178 # input_pos: [S], k_val: [B, H, S, D]
179 assert input_pos.shape[0] == k_val.shape[2]
180 k_out = self.k_cache
181 v_out = self.v_cache
182 k_out[:, :, input_pos] = k_val
183 v_out[:, :, input_pos] = v_val
184
185 return k_out, v_out
186
187
188class Attention(nn.Module):

Callers 14

create_deepspeed_configFunction · 0.80
mainFunction · 0.80
downloadFunction · 0.80
_run_engineMethod · 0.80
_prepare_sampleMethod · 0.80
prepare_input_tensorsMethod · 0.80
execute_modelMethod · 0.80
_sample_with_torchFunction · 0.80
_get_logprobsFunction · 0.80
_init_tokenizerMethod · 0.80
forwardMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected