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
ollama
Commits
9d1de41b
Commit
9d1de41b
authored
Jul 24, 2025
by
Michael Yang
Browse files
clamp glu/linear
parent
9679520e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
4 deletions
+9
-4
model/models/gptoss/model.go
model/models/gptoss/model.go
+9
-4
No files found.
model/models/gptoss/model.go
View file @
9d1de41b
...
@@ -189,11 +189,16 @@ func (mlp *MLPBlock) Forward(ctx ml.Context, hiddenStates, one ml.Tensor, opts *
...
@@ -189,11 +189,16 @@ func (mlp *MLPBlock) Forward(ctx ml.Context, hiddenStates, one ml.Tensor, opts *
hiddenStates
=
hiddenStates
.
Reshape
(
ctx
,
2
,
hiddenStates
.
Dim
(
0
)
/
2
,
hiddenStates
.
Dim
(
1
),
hiddenStates
.
Dim
(
2
))
hiddenStates
=
hiddenStates
.
Reshape
(
ctx
,
2
,
hiddenStates
.
Dim
(
0
)
/
2
,
hiddenStates
.
Dim
(
1
),
hiddenStates
.
Dim
(
2
))
dimStride
:=
[]
int
{
hiddenStates
.
Dim
(
0
)
/
2
,
hiddenStates
.
Stride
(
1
),
hiddenStates
.
Dim
(
1
),
hiddenStates
.
Stride
(
2
),
hiddenStates
.
Dim
(
2
),
hiddenStates
.
Stride
(
3
),
hiddenStates
.
Dim
(
3
)}
dimStride
:=
[]
int
{
hiddenStates
.
Dim
(
0
)
/
2
,
hiddenStates
.
Stride
(
1
),
hiddenStates
.
Dim
(
1
),
hiddenStates
.
Stride
(
2
),
hiddenStates
.
Dim
(
2
),
hiddenStates
.
Stride
(
3
),
hiddenStates
.
Dim
(
3
)}
hiddenStates
=
hiddenStates
.
View
(
ctx
,
0
,
dimStride
...
)
.
Contiguous
(
ctx
)
.
QuickGELU
(
ctx
)
.
Mul
(
ctx
,
hiddenStates
.
View
(
ctx
,
hiddenStates
.
Stride
(
0
),
dimStride
...
)
.
Add
(
ctx
,
one
))
glu
:=
hiddenStates
.
View
(
ctx
,
0
,
dimStride
...
)
glu
=
glu
.
Contiguous
(
ctx
)
glu
=
glu
.
Clamp
(
ctx
,
float32
(
math
.
Inf
(
-
1
)),
7.0
)
glu
=
glu
.
QuickGELU
(
ctx
)
linear
:=
hiddenStates
.
View
(
ctx
,
hiddenStates
.
Stride
(
0
),
dimStride
...
)
linear
=
linear
.
Clamp
(
ctx
,
-
7.0
,
7.0
)
hiddenStates
=
glu
.
Mul
(
ctx
,
linear
.
Add
(
ctx
,
one
))
hiddenStates
=
hiddenStates
.
Reshape
(
ctx
,
hiddenStates
.
Dim
(
0
)
*
hiddenStates
.
Dim
(
1
),
hiddenStates
.
Dim
(
2
),
hiddenStates
.
Dim
(
3
))
hiddenStates
=
hiddenStates
.
Reshape
(
ctx
,
hiddenStates
.
Dim
(
0
)
*
hiddenStates
.
Dim
(
1
),
hiddenStates
.
Dim
(
2
),
hiddenStates
.
Dim
(
3
))
experts
:=
mlp
.
Down
.
Forward
(
ctx
,
hiddenStates
,
selectedExperts
)
experts
:=
mlp
.
Down
.
Forward
(
ctx
,
hiddenStates
,
selectedExperts
)
...
...
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