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
b82153fe
Commit
b82153fe
authored
Apr 29, 2025
by
Catheriany
Browse files
issue/150: rope算子测例
parent
4e4d3415
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
32 deletions
+21
-32
src/infiniop-test/include/ops.hpp
src/infiniop-test/include/ops.hpp
+1
-1
test/infiniop-test/test_generate/testcases/rope.py
test/infiniop-test/test_generate/testcases/rope.py
+20
-31
No files found.
src/infiniop-test/include/ops.hpp
View file @
b82153fe
...
...
@@ -27,7 +27,7 @@ DECLARE_INFINIOP_TEST(rope)
REGISTER_INFINIOP_TEST(gemm) \
REGISTER_INFINIOP_TEST(random_sample) \
REGISTER_INFINIOP_TEST(mul) \
REGISTER_INFINIOP_TEST(rope) \
REGISTER_INFINIOP_TEST(rope) \
}
namespace
infiniop_test
{
...
...
test/infiniop-test/test_generate/testcases/rope.py
View file @
b82153fe
from
ast
import
List
import
numpy
as
np
import
gguf
from
enum
import
Enum
,
auto
from
typing
import
List
from
..
import
InfiniopTestWriter
,
InfiniopTestCase
,
np_dtype_to_ggml
,
gguf_strides
...
...
@@ -108,15 +109,6 @@ _TEST_CASES_ = [
_TENSOR_DTYPES_
=
[
np
.
float16
,
np
.
float32
]
class
Inplace
(
Enum
):
OUT_OF_PLACE
=
auto
()
INPLACE_X
=
auto
()
_INPLACE_
=
[
Inplace
.
OUT_OF_PLACE
,
Inplace
.
INPLACE_X
,
]
if
__name__
==
"__main__"
:
test_writer
=
InfiniopTestWriter
(
"rope.gguf"
)
...
...
@@ -124,26 +116,23 @@ if __name__ == "__main__":
for
dtype
in
_TENSOR_DTYPES_
:
for
shape
,
stride_x
,
stride_y
in
_TEST_CASES_
:
for
inplace
in
_INPLACE_
:
x
=
np
.
random
.
rand
(
*
shape
).
astype
(
dtype
)
if
inplace
==
Inplace
.
INPLACE_X
:
y
=
x
else
:
y
=
np
.
random
.
rand
(
*
shape
).
astype
(
dtype
)
pos_ids
=
np
.
arange
(
0
,
x
.
shape
[
0
],
dtype
=
np
.
int32
)
sin_table
,
cos_table
=
sin_cos_table
(
pos_ids
,
x
.
shape
[
2
],
theta
=
1e5
,
dtype
=
dtype
)
test_case
=
RoPETestCase
(
y
=
y
,
x
=
x
,
stride_y
=
stride_y
,
stride_x
=
stride_x
,
pos_ids
=
pos_ids
,
sin_table
=
sin_table
,
cos_table
=
cos_table
,
)
test_cases
.
append
(
test_case
)
x
=
np
.
random
.
rand
(
*
shape
).
astype
(
dtype
)
y
=
np
.
random
.
rand
(
*
shape
).
astype
(
dtype
)
pos_ids
=
np
.
arange
(
0
,
x
.
shape
[
0
],
dtype
=
np
.
int32
)
sin_table
,
cos_table
=
sin_cos_table
(
pos_ids
,
x
.
shape
[
2
],
theta
=
1e5
,
dtype
=
dtype
)
test_case
=
RoPETestCase
(
y
=
y
,
x
=
x
,
stride_y
=
stride_y
,
stride_x
=
stride_x
,
pos_ids
=
pos_ids
,
sin_table
=
sin_table
,
cos_table
=
cos_table
,
)
test_cases
.
append
(
test_case
)
test_writer
.
add_tests
(
test_cases
)
test_writer
.
save
()
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