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
FastMoE
Commits
c5d719cf
Commit
c5d719cf
authored
Dec 29, 2020
by
Jiezhong Qiu
Browse files
update
parent
79f16297
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
3 deletions
+3
-3
pytorch/cuda/moe.py
pytorch/cuda/moe.py
+3
-3
No files found.
pytorch/cuda/moe.py
View file @
c5d719cf
...
@@ -20,8 +20,8 @@ class MOEFunction(Function):
...
@@ -20,8 +20,8 @@ class MOEFunction(Function):
@
staticmethod
@
staticmethod
def
backward
(
ctx
,
grad_out
):
def
backward
(
ctx
,
grad_out
):
grad_input
,
grad_weight
=
moe_cuda
.
backward
(
grad_input
,
grad_weight
=
moe_cuda
.
backward
(
grad_out
.
contiguous
(),
*
ctx
.
saved_
variable
s
)
grad_out
.
contiguous
(),
*
ctx
.
saved_
tensor
s
)
return
grad_input
,
grad_weight
return
grad_input
,
None
,
grad_weight
class
MOELayer
(
nn
.
Module
):
class
MOELayer
(
nn
.
Module
):
...
@@ -46,7 +46,7 @@ out_feat = 512
...
@@ -46,7 +46,7 @@ out_feat = 512
moe
=
MOELayer
(
num_expert
,
in_feat
,
out_feat
).
cuda
()
moe
=
MOELayer
(
num_expert
,
in_feat
,
out_feat
).
cuda
()
input
=
torch
.
rand
(
batch_size
,
in_feat
).
cuda
()
input
=
torch
.
rand
(
batch_size
,
in_feat
).
cuda
()
gate
=
torch
.
randint
(
low
=
0
,
high
=
num_expert
,
size
=
(
batch_size
,
)).
int
().
cuda
()
gate
=
torch
.
randint
(
low
=
0
,
high
=
num_expert
,
size
=
(
batch_size
,
)
,
requires_grad
=
False
).
int
().
cuda
()
output
=
moe
(
input
,
gate
)
output
=
moe
(
input
,
gate
)
...
...
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