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
206f267e
"src/vscode:/vscode.git/clone" did not exist on "43346adc1ffa9051fc71be9af33fd982ee14c383"
Commit
206f267e
authored
Oct 26, 2021
by
Rick Ho
Browse files
fix swipe eval
parent
57bdfe88
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
fmoe/gates/swipe_gate.py
fmoe/gates/swipe_gate.py
+4
-4
No files found.
fmoe/gates/swipe_gate.py
View file @
206f267e
...
...
@@ -26,15 +26,15 @@ class SwipeGate(NaiveGate):
def
forward
(
self
,
inp
):
score
=
self
.
gate
(
inp
)
_
,
orig_idx
=
torch
.
topk
(
score
,
k
=
self
.
top_k
,
dim
=-
1
)
orig_score
,
orig_idx
=
torch
.
topk
(
score
,
k
=
self
.
top_k
,
dim
=-
1
)
if
not
self
.
training
:
topk_val
=
F
.
softmax
(
topk_val
,
dim
=-
1
)
return
topk
_idx
,
topk_val
topk_val
=
F
.
softmax
(
orig_score
,
dim
=-
1
)
return
orig
_idx
,
topk_val
capacity
=
torch
.
scalar_tensor
(
inp
.
shape
[
0
]
*
self
.
top_k
,
dtype
=
torch
.
long
)
topk_idxs
=
[]
topk_vals
=
[]
idx_x
=
torch
.
arange
(
inp
.
shape
[
0
],
device
=
inp
.
device
)
...
...
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