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
450549a4
Commit
450549a4
authored
Apr 26, 2021
by
Rick Ho
Browse files
fix zero gate and constant gate
parent
956d3aef
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
5 deletions
+2
-5
fmoe/gates/zero_gate.py
fmoe/gates/zero_gate.py
+1
-4
tests/test_zero.py
tests/test_zero.py
+1
-1
No files found.
fmoe/gates/zero_gate.py
View file @
450549a4
...
...
@@ -27,7 +27,4 @@ class ZeroGate(BaseGate):
gate_score
=
(
torch
.
ones
(
inp
.
shape
[
0
]
*
self
.
top_k
,
device
=
inp
.
device
)
/
self
.
top_k
)
gate_score_all
=
torch
.
zeros
(
inp
.
shape
[
0
],
self
.
num_expert
,
device
=
inp
.
device
)
gate_score_all
[:,
0
]
=
1
return
idx
,
gate_score
.
reshape
(
-
1
,
1
,
self
.
top_k
),
gate_score_all
return
idx
,
gate_score
.
reshape
(
-
1
,
1
,
self
.
top_k
)
tests/test_zero.py
View file @
450549a4
...
...
@@ -12,7 +12,7 @@ class ConstantGate(torch.nn.Module):
idx
=
torch
.
zeros
((
inp
.
shape
[
0
]
*
self
.
top_k
,),
dtype
=
torch
.
int64
,
device
=
inp
.
device
)
score
=
torch
.
ones
((
inp
.
shape
[
0
],
1
,
self
.
top_k
),
device
=
inp
.
device
)
/
2
return
idx
,
score
,
None
return
idx
,
score
def
test_zero_fwd
(
num_expert
=
2
,
batch_size
=
4
,
d_hidden
=
8
,
world_size
=
1
):
...
...
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