Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
ColossalAI
Commits
de56b563
Unverified
Commit
de56b563
authored
Nov 14, 2022
by
Frank Lee
Committed by
GitHub
Nov 14, 2022
Browse files
[tutorial] added missing dummy dataloader (#1944)
parent
c6ea6501
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
1 deletion
+40
-1
examples/tutorial/.gitignore
examples/tutorial/.gitignore
+1
-1
examples/tutorial/sequence_parallel/data/dummy_dataloader.py
examples/tutorial/sequence_parallel/data/dummy_dataloader.py
+39
-0
No files found.
examples/tutorial/.gitignore
View file @
de56b563
data/
./
data/
examples/tutorial/sequence_parallel/data/dummy_dataloader.py
0 → 100644
View file @
de56b563
import
torch
class
DummyDataloader
():
def
__init__
(
self
,
batch_size
,
vocab_size
,
seq_length
):
self
.
batch_size
=
batch_size
self
.
vocab_size
=
vocab_size
self
.
seq_length
=
seq_length
self
.
step
=
0
def
generate
(
self
):
tokens
=
torch
.
randint
(
low
=
0
,
high
=
self
.
vocab_size
,
size
=
(
self
.
batch_size
,
self
.
seq_length
,
))
types
=
torch
.
randint
(
low
=
0
,
high
=
3
,
size
=
(
self
.
batch_size
,
self
.
seq_length
,
))
sentence_order
=
torch
.
randint
(
low
=
0
,
high
=
2
,
size
=
(
self
.
batch_size
,))
loss_mask
=
torch
.
randint
(
low
=
0
,
high
=
2
,
size
=
(
self
.
batch_size
,
self
.
seq_length
,
))
lm_labels
=
torch
.
randint
(
low
=
0
,
high
=
self
.
vocab_size
,
size
=
(
self
.
batch_size
,
self
.
seq_length
))
padding_mask
=
torch
.
randint
(
low
=
0
,
high
=
2
,
size
=
(
self
.
batch_size
,
self
.
seq_length
))
return
dict
(
text
=
tokens
,
types
=
types
,
is_random
=
sentence_order
,
loss_mask
=
loss_mask
,
labels
=
lm_labels
,
padding_mask
=
padding_mask
)
def
__iter__
(
self
):
return
self
def
__next__
(
self
):
return
self
.
generate
()
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment