[example] make gpt example directory more clear (#2353)

This commit is contained in:
Jiarui Fang
2023-01-06 11:11:26 +08:00
committed by GitHub
parent 7027540d3d
commit 509a87f3ff
13 changed files with 26 additions and 584 deletions

View File

@@ -0,0 +1,12 @@
import torch
# Randomly Generated Data
def get_data(batch_size, seq_len, vocab_size):
input_ids = torch.randint(0, vocab_size, (batch_size, seq_len), device=torch.cuda.current_device())
attention_mask = torch.ones_like(input_ids)
return input_ids, attention_mask
def get_tflops(model_numel, batch_size, seq_len, step_time):
return model_numel * batch_size * seq_len * 8 / 1e12 / (step_time + 1e-12)