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
8f67b530
Commit
8f67b530
authored
Feb 23, 2021
by
Rick Ho
Browse files
use nn.modulelist to wrap up customized experts
parent
704092b1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
2 deletions
+6
-2
fmoe/layers.py
fmoe/layers.py
+6
-2
No files found.
fmoe/layers.py
View file @
8f67b530
...
@@ -143,10 +143,14 @@ class FMoE(nn.Module):
...
@@ -143,10 +143,14 @@ class FMoE(nn.Module):
self
.
top_k
=
top_k
self
.
top_k
=
top_k
self
.
gate
=
gate
(
d_model
,
num_expert
,
world_size
,
top_k
)
self
.
gate
=
gate
(
d_model
,
num_expert
,
world_size
,
top_k
)
if
expert
is
not
None
:
if
expert
is
not
None
:
self
.
experts
=
[
expert
(
d_model
)
for
_
in
range
(
num_expert
)]
self
.
experts
=
nn
.
ModuleList
([
expert
(
d_model
)
for
_
in
range
(
num_expert
)])
self
.
experts_fused
=
False
else
:
self
.
experts_fused
=
True
def
expert_fn
(
self
,
inp
,
fwd_expert_count
):
def
expert_fn
(
self
,
inp
,
fwd_expert_count
):
if
isinstance
(
self
.
experts
,
nn
.
Module
)
:
if
self
.
experts
_fused
:
return
self
.
experts
(
inp
,
fwd_expert_count
)
return
self
.
experts
(
inp
,
fwd_expert_count
)
outputs
=
[]
outputs
=
[]
base_idx
=
0
base_idx
=
0
...
...
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