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
d4c0cdf9
Commit
d4c0cdf9
authored
Apr 24, 2025
by
Graylatzhou
Browse files
issue/183 根据反馈修改
parent
975559ee
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
52 additions
and
46 deletions
+52
-46
include/infiniop/ops/mul.h
include/infiniop/ops/mul.h
+3
-3
src/infiniop-test/src/ops/mul.cpp
src/infiniop-test/src/ops/mul.cpp
+2
-3
src/infiniop/ops/mul/cpu/mul_cpu.h
src/infiniop/ops/mul/cpu/mul_cpu.h
+1
-1
src/infiniop/ops/mul/cuda/mul_cuda.cu
src/infiniop/ops/mul/cuda/mul_cuda.cu
+1
-1
src/infiniop/ops/mul/cuda/mul_cuda.cuh
src/infiniop/ops/mul/cuda/mul_cuda.cuh
+1
-1
src/infiniop/ops/mul/cuda/mul_cuda_internal.cuh
src/infiniop/ops/mul/cuda/mul_cuda_internal.cuh
+2
-2
src/infiniop/ops/mul/operator.cc
src/infiniop/ops/mul/operator.cc
+1
-1
test/infiniop-test/test_generate/testcases/mul.py
test/infiniop-test/test_generate/testcases/mul.py
+41
-34
No files found.
include/infiniop/ops/mul.h
View file @
d4c0cdf9
...
@@ -17,10 +17,10 @@ __C __export infiniStatus_t infiniopMul(infiniopMulDescriptor_t desc,
...
@@ -17,10 +17,10 @@ __C __export infiniStatus_t infiniopMul(infiniopMulDescriptor_t desc,
void
*
workspace
,
void
*
workspace
,
size_t
workspace_size
,
size_t
workspace_size
,
void
*
c
,
void
*
c
,
void
const
*
a
,
const
void
*
a
,
void
const
*
b
,
const
void
*
b
,
void
*
stream
);
void
*
stream
);
__C
__export
infiniStatus_t
infiniopDestroyMulDescriptor
(
infiniopMulDescriptor_t
desc
);
__C
__export
infiniStatus_t
infiniopDestroyMulDescriptor
(
infiniopMulDescriptor_t
desc
);
#endif
#endif
\ No newline at end of file
src/infiniop-test/src/ops/mul.cpp
View file @
d4c0cdf9
...
@@ -80,13 +80,12 @@ std::shared_ptr<infiniop_test::Result> Test::run(
...
@@ -80,13 +80,12 @@ std::shared_ptr<infiniop_test::Result> Test::run(
b
->
data
(),
b
->
data
(),
nullptr
);
nullptr
);
},
},
(
warm_ups
+
1
)
/
2
,
(
iterations
+
1
)
/
2
);
warm_ups
,
iterations
);
return
TEST_PASSED
(
elapsed_time
);
return
TEST_PASSED
(
elapsed_time
);
}
}
std
::
vector
<
std
::
string
>
Test
::
attribute_names
()
{
std
::
vector
<
std
::
string
>
Test
::
attribute_names
()
{
// MUL 操作不需要特殊属性(与 GEMM 不同,GEMM 需要 alpha 和 beta)
return
{};
return
{};
}
}
...
@@ -109,4 +108,4 @@ Test::~Test() {
...
@@ -109,4 +108,4 @@ Test::~Test() {
delete
_attributes
;
delete
_attributes
;
}
}
}
// namespace infiniop_test::mul
}
// namespace infiniop_test::mul
\ No newline at end of file
src/infiniop/ops/mul/cpu/mul_cpu.h
View file @
d4c0cdf9
...
@@ -16,4 +16,4 @@ public:
...
@@ -16,4 +16,4 @@ public:
}
MulOp
;
}
MulOp
;
}
// namespace op::mul::cpu
}
// namespace op::mul::cpu
#endif // __MUL_CPU_H__
#endif // __MUL_CPU_H__
\ No newline at end of file
src/infiniop/ops/mul/cuda/mul_cuda.cu
View file @
d4c0cdf9
...
@@ -54,4 +54,4 @@ infiniStatus_t Descriptor::calculate(
...
@@ -54,4 +54,4 @@ infiniStatus_t Descriptor::calculate(
return
INFINI_STATUS_SUCCESS
;
return
INFINI_STATUS_SUCCESS
;
}
}
}
// namespace op::add::cuda
}
// namespace op::mul::cuda
\ No newline at end of file
src/infiniop/ops/mul/cuda/mul_cuda.cuh
View file @
d4c0cdf9
...
@@ -5,4 +5,4 @@
...
@@ -5,4 +5,4 @@
ELEMENTWISE_DESCRIPTOR
(
mul
,
cuda
)
ELEMENTWISE_DESCRIPTOR
(
mul
,
cuda
)
#endif // __MUL_CUDA_API_H__
#endif // __MUL_CUDA_API_H__
\ No newline at end of file
src/infiniop/ops/mul/cuda/mul_cuda_internal.cuh
View file @
d4c0cdf9
...
@@ -21,6 +21,6 @@ typedef struct MulOp {
...
@@ -21,6 +21,6 @@ typedef struct MulOp {
}
}
}
MulOp
;
}
MulOp
;
}
// namespace op::
add
::cuda
}
// namespace op::
mul
::cuda
#endif // __MUL_CUDA_H__
#endif // __MUL_CUDA_H__
\ No newline at end of file
src/infiniop/ops/mul/operator.cc
View file @
d4c0cdf9
...
@@ -117,4 +117,4 @@ infiniopDestroyMulDescriptor(infiniopMulDescriptor_t desc) {
...
@@ -117,4 +117,4 @@ infiniopDestroyMulDescriptor(infiniopMulDescriptor_t desc) {
}
}
#undef DELETE
#undef DELETE
}
}
\ No newline at end of file
test/infiniop-test/test_generate/testcases/mul.py
View file @
d4c0cdf9
from
ast
import
List
import
numpy
as
np
import
numpy
as
np
import
gguf
import
gguf
from
typing
import
List
from
typing
import
List
...
@@ -54,101 +53,109 @@ class MulTestCase(InfiniopTestCase):
...
@@ -54,101 +53,109 @@ class MulTestCase(InfiniopTestCase):
test_writer
.
add_tensor
(
test_writer
.
add_tensor
(
test_writer
.
gguf_key
(
"c"
),
self
.
c
,
raw_dtype
=
np_dtype_to_ggml
(
self
.
c
.
dtype
)
test_writer
.
gguf_key
(
"c"
),
self
.
c
,
raw_dtype
=
np_dtype_to_ggml
(
self
.
c
.
dtype
)
)
)
a_fp64
=
self
.
a
.
astype
(
np
.
float64
)
b_fp64
=
self
.
b
.
astype
(
np
.
float64
)
ans_fp64
=
np
.
multiply
(
a_fp64
,
b_fp64
)
ans
=
mul
(
self
.
a
,
self
.
b
,
self
.
c
)
ans
=
mul
(
self
.
a
,
self
.
b
,
self
.
c
)
test_writer
.
add_tensor
(
test_writer
.
add_tensor
(
test_writer
.
gguf_key
(
"ans"
),
ans
,
raw_dtype
=
np_dtype_to_ggml
(
ans
.
dtype
)
test_writer
.
gguf_key
(
"ans"
),
ans
,
raw_dtype
=
np_dtype_to_ggml
(
ans
.
dtype
)
)
)
test_writer
.
add_tensor
(
test_writer
.
gguf_key
(
"ans_fp64"
),
ans_fp64
,
raw_dtype
=
np_dtype_to_ggml
(
ans_fp64
.
dtype
),
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
test_writer
=
InfiniopTestWriter
(
"mul.gguf"
)
test_writer
=
InfiniopTestWriter
(
"mul.gguf"
)
test_cases
=
[
test_cases
=
[
MulTestCase
(
MulTestCase
(
random_tensor
((
2
,
3
),
np
.
float32
),
random_tensor
((
2
,
3
),
np
.
float32
),
gguf_strides
(
3
,
1
),
gguf_strides
(
3
,
1
),
random_tensor
((
2
,
3
),
np
.
float32
),
random_tensor
((
2
,
3
),
np
.
float32
),
gguf_strides
(
3
,
1
),
(
1
,
2
),
random_tensor
((
2
,
3
),
np
.
float32
),
random_tensor
((
2
,
3
),
np
.
float32
),
gguf_strides
(
3
,
1
),
gguf_strides
(
3
,
1
),
),
),
MulTestCase
(
MulTestCase
(
random_tensor
((
2
,
3
),
np
.
float16
),
random_tensor
((
2
,
3
),
np
.
float16
),
gguf_strides
(
3
,
1
),
(
1
,
2
),
random_tensor
((
2
,
3
),
np
.
float16
),
random_tensor
((
2
,
3
),
np
.
float16
),
gguf_strides
(
3
,
1
),
gguf_strides
(
3
,
1
),
random_tensor
((
2
,
3
),
np
.
float16
),
random_tensor
((
2
,
3
),
np
.
float16
),
gguf_strides
(
3
,
1
),
(
1
,
2
),
),
),
MulTestCase
(
MulTestCase
(
random_tensor
((
2
,
3
),
np
.
float64
),
random_tensor
((
2
,
3
),
np
.
float64
),
gguf_strides
(
3
,
1
),
gguf_strides
(
3
,
1
),
random_tensor
((
2
,
3
),
np
.
float64
),
random_tensor
((
2
,
3
),
np
.
float64
),
gguf_strides
(
3
,
1
),
gguf_strides
(
3
,
1
),
random_tensor
((
2
,
3
),
np
.
float64
),
random_tensor
((
2
,
3
),
np
.
float64
),
gguf_strides
(
3
,
1
),
(
1
,
2
),
),
),
MulTestCase
(
MulTestCase
(
random_tensor
((
4
,
6
),
np
.
float16
),
random_tensor
((
4
,
6
),
np
.
float16
),
gguf_strides
(
1
,
4
),
gguf_strides
(
1
,
4
),
random_tensor
((
4
,
6
),
np
.
float16
),
random_tensor
((
4
,
6
),
np
.
float16
),
gguf_strides
(
1
,
5
),
gguf_strides
(
1
,
5
),
random_tensor
((
4
,
6
),
np
.
float16
),
random_tensor
((
4
,
6
),
np
.
float16
),
gguf_strides
(
1
,
4
),
gguf_strides
(
6
,
1
),
),
),
MulTestCase
(
MulTestCase
(
random_tensor
((
1
,
2048
),
np
.
float16
),
random_tensor
((
1
,
2048
),
np
.
float16
),
gguf_strides
(
1
,
2048
),
(
1
,
1
),
random_tensor
((
1
,
2048
),
np
.
float16
),
random_tensor
((
1
,
2048
),
np
.
float16
),
gguf_strides
(
1
,
2048
)
,
gguf_strides
(
2048
,
1
),
random_tensor
((
1
,
2048
),
np
.
float16
),
random_tensor
((
1
,
2048
),
np
.
float16
),
gguf_strides
(
1
,
2048
),
(
1
,
1
),
),
),
MulTestCase
(
MulTestCase
(
random_tensor
((
2048
,
2048
),
np
.
float32
),
random_tensor
((
2048
,
2048
),
np
.
float32
),
None
,
None
,
random_tensor
((
2048
,
2048
),
np
.
float32
),
random_tensor
((
2048
,
2048
),
np
.
float32
),
None
,
(
1
,
2048
),
random_tensor
((
2048
,
2048
),
np
.
float32
),
random_tensor
((
2048
,
2048
),
np
.
float32
),
None
,
None
,
),
),
MulTestCase
(
MulTestCase
(
random_tensor
((
2
,
4
,
2048
),
np
.
float16
),
random_tensor
((
2
,
4
,
2048
),
np
.
float16
),
None
,
(
4
*
2048
,
2048
,
1
),
random_tensor
((
2
,
4
,
2048
),
np
.
float16
),
random_tensor
((
2
,
4
,
2048
),
np
.
float16
),
None
,
(
1
,
2
,
2
*
4
),
random_tensor
((
2
,
4
,
2048
),
np
.
float16
),
random_tensor
((
2
,
4
,
2048
),
np
.
float16
),
None
,
(
4
*
2048
,
2048
,
1
),
),
),
MulTestCase
(
MulTestCase
(
random_tensor
((
2
,
4
,
2048
),
np
.
float32
),
random_tensor
((
2
,
4
,
2048
),
np
.
float32
),
None
,
(
1
,
2
,
2
*
4
),
random_tensor
((
2
,
4
,
2048
),
np
.
float32
),
random_tensor
((
2
,
4
,
2048
),
np
.
float32
),
None
,
None
,
random_tensor
((
2
,
4
,
2048
),
np
.
float32
),
random_tensor
((
2
,
4
,
2048
),
np
.
float32
),
None
,
(
1
,
2
,
2
*
4
),
),
),
MulTestCase
(
MulTestCase
(
random_tensor
((
2048
,
2560
),
np
.
float32
),
random_tensor
((
2048
,
2560
),
np
.
float32
),
gguf_strides
(
1
,
2560
)
,
gguf_strides
(
2560
,
1
),
random_tensor
((
2048
,
2560
),
np
.
float32
),
random_tensor
((
2048
,
2560
),
np
.
float32
),
gguf_strides
(
1
,
2560
),
(
1
,
2048
),
random_tensor
((
2048
,
2560
),
np
.
float32
),
random_tensor
((
2048
,
2560
),
np
.
float32
),
gguf_strides
(
1
,
2560
)
,
gguf_strides
(
2560
,
1
),
),
),
MulTestCase
(
MulTestCase
(
random_tensor
((
4
,
48
,
64
),
np
.
float16
),
random_tensor
((
4
,
48
,
64
),
np
.
float16
),
None
,
(
64
*
48
,
64
,
1
),
random_tensor
((
4
,
48
,
64
),
np
.
float16
),
random_tensor
((
4
,
48
,
64
),
np
.
float16
),
None
,
(
1
,
4
,
4
*
48
),
random_tensor
((
4
,
48
,
64
),
np
.
float16
),
random_tensor
((
4
,
48
,
64
),
np
.
float16
),
None
None
),
),
MulTestCase
(
MulTestCase
(
random_tensor
((
4
,
48
,
64
),
np
.
float32
),
random_tensor
((
4
,
48
,
64
),
np
.
float32
),
None
,
None
,
random_tensor
((
4
,
48
,
64
),
np
.
float32
),
random_tensor
((
4
,
48
,
64
),
np
.
float32
),
None
,
(
1
,
4
,
4
*
48
),
random_tensor
((
4
,
48
,
64
),
np
.
float32
),
random_tensor
((
4
,
48
,
64
),
np
.
float32
),
None
(
48
*
64
,
64
,
1
),
),
),
]
]
...
...
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