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
Megatron-LM
Commits
323e75c4
"src/diffusers/models/modeling_utils.py" did not exist on "78744b6a8f3c9dd4800e1b279cc37930dfd77048"
Commit
323e75c4
authored
Mar 17, 2020
by
Raul Puri
Browse files
Update generate_samples.py
parent
29d10a36
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
7 deletions
+8
-7
generate_samples.py
generate_samples.py
+8
-7
No files found.
generate_samples.py
View file @
323e75c4
...
@@ -366,12 +366,13 @@ def switch(val1, val2, boolean):
...
@@ -366,12 +366,13 @@ def switch(val1, val2, boolean):
return
(
1
-
boolean
)
*
val1
+
boolean
*
val2
return
(
1
-
boolean
)
*
val1
+
boolean
*
val2
def
sample_sequence_batch
(
model
,
context_tokens
,
context_lengths
,
attention_mask
,
position_ids
,
tokenizer
,
args
,
maxlen
=
None
,
type_ids
=
None
):
def
sample_sequence_batch
(
model
,
context_tokens
,
context_lengths
,
attention_mask
,
position_ids
,
tokenizer
,
args
,
maxlen
=
None
,
type_ids
=
None
):
if
isinstance
(
model
,
DDP
):
actual_model
=
model
model
=
model
.
module
if
isinstance
(
actual_model
,
DDP
):
if
isinstance
(
model
,
FP16_Module
):
actual_model
=
actual_model
.
module
model
=
model
.
module
if
isinstance
(
actual_model
,
FP16_Module
):
original_output_parallel
=
model
.
parallel_output
actual_model
=
actual_model
.
module
model
.
parallel_output
=
False
original_output_parallel
=
actual_model
.
parallel_output
actual_model
.
parallel_output
=
False
model
.
eval
()
model
.
eval
()
with
torch
.
no_grad
():
with
torch
.
no_grad
():
context_length
=
context_lengths
.
min
().
item
()
context_length
=
context_lengths
.
min
().
item
()
...
@@ -438,7 +439,7 @@ def sample_sequence_batch(model, context_tokens, context_lengths, attention_mask
...
@@ -438,7 +439,7 @@ def sample_sequence_batch(model, context_tokens, context_lengths, attention_mask
yield
tokens
,
lengths
yield
tokens
,
lengths
if
done
:
if
done
:
break
break
model
.
parallel_output
=
original_output_parallel
actual_
model
.
parallel_output
=
original_output_parallel
def
prepare_tokenizer
(
args
):
def
prepare_tokenizer
(
args
):
...
...
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