nielsr HF staff commited on
Commit
e0f8585
1 Parent(s): 20e5c44

Add print statements

Browse files
Files changed (1) hide show
  1. modeling_cogvlm.py +27 -25
modeling_cogvlm.py CHANGED
@@ -241,33 +241,35 @@ class VisionExpertAttention(nn.Module):
241
  key_states = self._transpose_for_scores(key_states) # B, H, L, HD
242
  value_states = self._transpose_for_scores(value_states) # B, H, L, HD
243
 
244
- torch.save(query_states, "query_states.pt")
245
- torch.save(key_states, "key_states.pt")
246
- torch.save(value_states, "value_states.pt")
247
 
248
- from huggingface_hub import HfApi
 
 
249
 
250
- api = HfApi()
251
- api.upload_file(
252
- path_or_fileobj="query_states.pt",
253
- path_in_repo="query_states.pt",
254
- repo_id="nielsr/test-cogvlm",
255
- repo_type="dataset",
256
- )
257
- api = HfApi()
258
- api.upload_file(
259
- path_or_fileobj="key_states.pt",
260
- path_in_repo="key_states.pt",
261
- repo_id="nielsr/test-cogvlm",
262
- repo_type="dataset",
263
- )
264
- api = HfApi()
265
- api.upload_file(
266
- path_or_fileobj="value_states.pt",
267
- path_in_repo="value_states.pt",
268
- repo_id="nielsr/test-cogvlm",
269
- repo_type="dataset",
270
- )
 
 
271
 
272
  kv_seq_len = key_states.shape[-2]
273
  if past_key_value is not None:
 
241
  key_states = self._transpose_for_scores(key_states) # B, H, L, HD
242
  value_states = self._transpose_for_scores(value_states) # B, H, L, HD
243
 
244
+ if print_values:
 
 
245
 
246
+ torch.save(query_states, "query_states.pt")
247
+ torch.save(key_states, "key_states.pt")
248
+ torch.save(value_states, "value_states.pt")
249
 
250
+ from huggingface_hub import HfApi
251
+
252
+ api = HfApi()
253
+ api.upload_file(
254
+ path_or_fileobj="query_states.pt",
255
+ path_in_repo="query_states.pt",
256
+ repo_id="nielsr/test-cogvlm",
257
+ repo_type="dataset",
258
+ )
259
+ api = HfApi()
260
+ api.upload_file(
261
+ path_or_fileobj="key_states.pt",
262
+ path_in_repo="key_states.pt",
263
+ repo_id="nielsr/test-cogvlm",
264
+ repo_type="dataset",
265
+ )
266
+ api = HfApi()
267
+ api.upload_file(
268
+ path_or_fileobj="value_states.pt",
269
+ path_in_repo="value_states.pt",
270
+ repo_id="nielsr/test-cogvlm",
271
+ repo_type="dataset",
272
+ )
273
 
274
  kv_seq_len = key_states.shape[-2]
275
  if past_key_value is not None: