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
jerrrrry
infinicore
Commits
27b836c9
Unverified
Commit
27b836c9
authored
Jun 27, 2025
by
PanZezhong1725
Committed by
GitHub
Jun 27, 2025
Browse files
Merge pull request #283 from InfiniTensor/issue/282
issue/282: Maca CausalSoftamx精度bug
parents
af8bdb43
31e54f93
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
2 deletions
+4
-2
src/infiniop/ops/causal_softmax/maca/causal_softmax_kernel.h
src/infiniop/ops/causal_softmax/maca/causal_softmax_kernel.h
+1
-1
test/infiniop/causal_softmax.py
test/infiniop/causal_softmax.py
+3
-1
No files found.
src/infiniop/ops/causal_softmax/maca/causal_softmax_kernel.h
View file @
27b836c9
...
...
@@ -18,7 +18,7 @@ INFINIOP_MACA_KERNEL causalSoftmax(
// [Reduce] Find max value in each row and store in shared memory
__shared__
Tdata
max_
;
Tdata
max_0
=
op
::
common_maca
::
reduce_op
::
max
<
BLOCK_SIZE
,
Tdata
>
(
x
,
width
);
Tdata
max_0
=
op
::
common_maca
::
reduce_op
::
max
<
BLOCK_SIZE
,
Tdata
>
(
x
,
width
-
height
+
1
+
blockIdx
.
x
);
if
(
threadIdx
.
x
==
0
)
{
max_
=
max_0
;
}
...
...
test/infiniop/causal_softmax.py
View file @
27b836c9
...
...
@@ -30,6 +30,7 @@ _TEST_CASES_ = [
((
32
,
5
,
5
),
None
,
None
),
((
32
,
20
,
512
),
None
,
None
),
((
32
,
20
,
512
),
(
20480
,
512
,
1
),
None
),
((
28
,
15
,
15
),
None
,
None
),
]
# Data types used for testing
...
...
@@ -93,7 +94,8 @@ def test(
)
x
=
torch
.
rand
(
shape
,
dtype
=
dtype
).
to
(
torch_device
)
mask
=
torch
.
tril
(
torch
.
ones_like
(
x
),
diagonal
=-
1
).
flip
(
dims
=
[
-
2
,
-
1
])
x
=
torch
.
where
(
mask
==
1
,
torch
.
full_like
(
x
,
torch
.
finfo
(
x
.
dtype
).
max
),
x
)
ans
=
causal_softmax
(
x
)
x
=
rearrange_if_needed
(
x
,
x_stride
)
...
...
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