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
452049e2
Unverified
Commit
452049e2
authored
Mar 21, 2025
by
PanZezhong1725
Committed by
GitHub
Mar 21, 2025
Browse files
Merge pull request #116 from PanZezhong1725/issue/115
issue/115 将matmul改名为gemm
parents
2ede6b81
054763bc
Changes
33
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
98 additions
and
89 deletions
+98
-89
.github/workflows/build.yml
.github/workflows/build.yml
+1
-1
include/infiniop.h
include/infiniop.h
+1
-1
include/infiniop/ops/attention.h
include/infiniop/ops/attention.h
+1
-1
include/infiniop/ops/gemm.h
include/infiniop/ops/gemm.h
+10
-13
include/infiniop/ops/matmul.h
include/infiniop/ops/matmul.h
+0
-28
include/infiniop/ops/mlp.h
include/infiniop/ops/mlp.h
+1
-1
src/infiniop-test/include/ops.hpp
src/infiniop-test/include/ops.hpp
+4
-4
src/infiniop-test/src/ops/gemm.cpp
src/infiniop-test/src/ops/gemm.cpp
+17
-17
src/infiniop/ops/gemm/ascend/gemm_ascend.cc
src/infiniop/ops/gemm/ascend/gemm_ascend.cc
+3
-3
src/infiniop/ops/gemm/ascend/gemm_ascend.h
src/infiniop/ops/gemm/ascend/gemm_ascend.h
+8
-0
src/infiniop/ops/gemm/bang/gemm_bang.cc
src/infiniop/ops/gemm/bang/gemm_bang.cc
+3
-3
src/infiniop/ops/gemm/bang/gemm_bang.h
src/infiniop/ops/gemm/bang/gemm_bang.h
+8
-0
src/infiniop/ops/gemm/blas.h
src/infiniop/ops/gemm/blas.h
+2
-2
src/infiniop/ops/gemm/cpu/gemm_cpu.cc
src/infiniop/ops/gemm/cpu/gemm_cpu.cc
+3
-3
src/infiniop/ops/gemm/cpu/gemm_cpu.h
src/infiniop/ops/gemm/cpu/gemm_cpu.h
+8
-0
src/infiniop/ops/gemm/cuda/gemm_cuda.cu
src/infiniop/ops/gemm/cuda/gemm_cuda.cu
+3
-3
src/infiniop/ops/gemm/cuda/gemm_cuda.cuh
src/infiniop/ops/gemm/cuda/gemm_cuda.cuh
+8
-0
src/infiniop/ops/gemm/gemm.h
src/infiniop/ops/gemm/gemm.h
+4
-4
src/infiniop/ops/gemm/kunlun/gemm_kunlun.cc
src/infiniop/ops/gemm/kunlun/gemm_kunlun.cc
+5
-5
src/infiniop/ops/gemm/kunlun/gemm_kunlun.h
src/infiniop/ops/gemm/kunlun/gemm_kunlun.h
+8
-0
No files found.
.github/workflows/build.yml
View file @
452049e2
...
...
@@ -49,6 +49,6 @@ jobs:
if
:
matrix.os != 'windows-latest'
run
:
|
pip install torch
LD_LIBRARY_PATH=$HOME/.infini/lib python test/infiniop/
matmul
.py --cpu
LD_LIBRARY_PATH=$HOME/.infini/lib python test/infiniop/
gemm
.py --cpu
LD_LIBRARY_PATH=$HOME/.infini/lib python test/infiniop/rms_norm.py --cpu
LD_LIBRARY_PATH=$HOME/.infini/lib python test/infiniop/random_sample.py --cpu
include/infiniop.h
View file @
452049e2
...
...
@@ -10,7 +10,7 @@
#include "infiniop/ops/expand.h"
#include "infiniop/ops/gemm.h"
#include "infiniop/ops/global_avg_pool.h"
#include "infiniop/ops/
matmul
.h"
#include "infiniop/ops/
gemm
.h"
#include "infiniop/ops/max_pool.h"
#include "infiniop/ops/mlp.h"
#include "infiniop/ops/random_sample.h"
...
...
include/infiniop/ops/attention.h
View file @
452049e2
...
...
@@ -2,7 +2,7 @@
#define __INFINIOP_ATTENTION_API_H__
#include "../operator_descriptor.h"
#include "
matmul
.h"
#include "
gemm
.h"
#include "swiglu.h"
typedef
InfiniopDescriptor
*
infiniopAttentionDescriptor_t
;
...
...
include/infiniop/ops/gemm.h
View file @
452049e2
...
...
@@ -3,29 +3,26 @@
#include "../operator_descriptor.h"
typedef
InfiniopDescriptor
*
infiniopG
EMM
Descriptor_t
;
typedef
InfiniopDescriptor
*
infiniopG
emm
Descriptor_t
;
__C
__export
infiniStatus_t
infiniopCreateGEMMDescriptor
(
infiniopHandle_t
handle
,
infiniopGEMMDescriptor_t
*
desc_ptr
,
infiniopTensorDescriptor_t
y_desc
,
infiniopTensorDescriptor_t
a_desc
,
infiniopTensorDescriptor_t
b_desc
,
__C
__export
infiniStatus_t
infiniopCreateGemmDescriptor
(
infiniopHandle_t
handle
,
infiniopGemmDescriptor_t
*
desc_ptr
,
infiniopTensorDescriptor_t
c_desc
,
char
transA
,
char
transB
);
infiniopTensorDescriptor_t
a_desc
,
infiniopTensorDescriptor_t
b_desc
);
__C
__export
infiniStatus_t
infiniopGetG
EMM
WorkspaceSize
(
infiniopG
EMM
Descriptor_t
desc
,
size_t
*
size
);
__C
__export
infiniStatus_t
infiniopGetG
emm
WorkspaceSize
(
infiniopG
emm
Descriptor_t
desc
,
size_t
*
size
);
__C
__export
infiniStatus_t
infiniopG
EMM
(
infiniopG
EMM
Descriptor_t
desc
,
__C
__export
infiniStatus_t
infiniopG
emm
(
infiniopG
emm
Descriptor_t
desc
,
void
*
workspace
,
size_t
workspace_size
,
void
*
y
,
void
*
c
,
void
const
*
a
,
void
const
*
b
,
void
const
*
c
,
float
alpha
,
float
beta
,
void
*
stream
);
__C
__export
infiniStatus_t
infiniopDestroyGEMMDescriptor
(
infiniopGEMMDescriptor_t
desc
);
__C
__export
infiniStatus_t
infiniopDestroyGemmDescriptor
(
infiniopGemmDescriptor_t
desc
);
#endif
include/infiniop/ops/matmul.h
deleted
100644 → 0
View file @
2ede6b81
#ifndef __INFINIOP_MATMUL_API_H__
#define __INFINIOP_MATMUL_API_H__
#include "../operator_descriptor.h"
typedef
InfiniopDescriptor
*
infiniopMatmulDescriptor_t
;
__C
__export
infiniStatus_t
infiniopCreateMatmulDescriptor
(
infiniopHandle_t
handle
,
infiniopMatmulDescriptor_t
*
desc_ptr
,
infiniopTensorDescriptor_t
c_desc
,
infiniopTensorDescriptor_t
a_desc
,
infiniopTensorDescriptor_t
b_desc
);
__C
__export
infiniStatus_t
infiniopGetMatmulWorkspaceSize
(
infiniopMatmulDescriptor_t
desc
,
size_t
*
size
);
__C
__export
infiniStatus_t
infiniopMatmul
(
infiniopMatmulDescriptor_t
desc
,
void
*
workspace
,
size_t
workspace_size
,
void
*
c
,
void
const
*
a
,
void
const
*
b
,
float
alpha
,
float
beta
,
void
*
stream
);
__C
__export
infiniStatus_t
infiniopDestroyMatmulDescriptor
(
infiniopMatmulDescriptor_t
desc
);
#endif
include/infiniop/ops/mlp.h
View file @
452049e2
...
...
@@ -2,7 +2,7 @@
#define __INFINIOP_MLP_API_H__
#include "../operator_descriptor.h"
#include "
matmul
.h"
#include "
gemm
.h"
#include "swiglu.h"
typedef
InfiniopDescriptor
*
infiniopMLPDescriptor_t
;
...
...
src/infiniop-test/include/ops.hpp
View file @
452049e2
...
...
@@ -5,7 +5,7 @@
/*
* Declare all the tests here
*/
DECLARE_INFINIOP_TEST
(
matmul
)
DECLARE_INFINIOP_TEST
(
gemm
)
#define REGISTER_INFINIOP_TEST(name) \
{ \
...
...
@@ -18,9 +18,9 @@ DECLARE_INFINIOP_TEST(matmul)
/*
* Register all the tests here
*/
#define TEST_BUILDER_MAPPINGS
\
{
\
REGISTER_INFINIOP_TEST(
matmul
), \
#define TEST_BUILDER_MAPPINGS \
{ \
REGISTER_INFINIOP_TEST(
gemm
), \
}
namespace
infiniop_test
{
...
...
src/infiniop-test/src/ops/
matmul
.cpp
→
src/infiniop-test/src/ops/
gemm
.cpp
View file @
452049e2
...
...
@@ -4,7 +4,7 @@
#include <iomanip>
#include <iostream>
namespace
infiniop_test
::
matmul
{
namespace
infiniop_test
::
gemm
{
struct
Test
::
Attributes
{
float
alpha
;
float
beta
;
...
...
@@ -43,30 +43,30 @@ std::shared_ptr<Test> Test::build(
std
::
shared_ptr
<
infiniop_test
::
Result
>
Test
::
run
(
infiniopHandle_t
handle
,
infiniDevice_t
device
,
int
device_id
,
size_t
warm_ups
,
size_t
iterations
)
{
infiniop
Matmul
Descriptor_t
op_desc
;
infiniop
Gemm
Descriptor_t
op_desc
;
auto
alpha
=
_attributes
->
alpha
;
auto
beta
=
_attributes
->
beta
;
auto
a
=
_attributes
->
a
->
to
(
device
,
device_id
);
auto
b
=
_attributes
->
b
->
to
(
device
,
device_id
);
auto
c
=
_attributes
->
c
->
to
(
device
,
device_id
);
CHECK_OR
(
infiniopCreate
Matmul
Descriptor
(
handle
,
&
op_desc
,
c
->
desc
(),
a
->
desc
(),
b
->
desc
()),
CHECK_OR
(
infiniopCreate
Gemm
Descriptor
(
handle
,
&
op_desc
,
c
->
desc
(),
a
->
desc
(),
b
->
desc
()),
return
TEST_FAILED
(
OP_CREATION_FAILED
,
"Failed to create op descriptor."
));
size_t
workspace_size
;
CHECK_OR
(
infiniopGet
Matmul
WorkspaceSize
(
op_desc
,
&
workspace_size
),
CHECK_OR
(
infiniopGet
Gemm
WorkspaceSize
(
op_desc
,
&
workspace_size
),
return
TEST_FAILED
(
OP_CREATION_FAILED
,
"Failed to get workspace size."
));
void
*
workspace
;
CHECK_OR
(
infinirtMalloc
(
&
workspace
,
workspace_size
),
return
TEST_FAILED
(
OP_CREATION_FAILED
,
"Failed to allocate workspace."
));
CHECK_OR
(
infiniop
Matmul
(
op_desc
,
workspace
,
workspace_size
,
c
->
data
(),
a
->
data
(),
b
->
data
(),
alpha
,
beta
,
nullptr
),
CHECK_OR
(
infiniop
Gemm
(
op_desc
,
workspace
,
workspace_size
,
c
->
data
(),
a
->
data
(),
b
->
data
(),
alpha
,
beta
,
nullptr
),
return
TEST_FAILED
(
OP_EXECUTION_FAILED
,
"Failed during execution."
));
try
{
...
...
@@ -83,7 +83,7 @@ std::shared_ptr<infiniop_test::Result> Test::run(
elapsed_time
=
benchmark
(
[
=
]()
{
infiniop
Matmul
(
infiniop
Gemm
(
op_desc
,
workspace
,
workspace_size
,
c
->
data
(),
a
->
data
(),
...
...
@@ -91,7 +91,7 @@ std::shared_ptr<infiniop_test::Result> Test::run(
alpha
,
beta
,
nullptr
);
infiniop
Matmul
(
infiniop
Gemm
(
op_desc
,
workspace
,
workspace_size
,
c
->
data
(),
a
->
data
(),
...
...
@@ -129,4 +129,4 @@ Test::~Test() {
delete
_attributes
;
}
}
// namespace infiniop_test::
matmul
}
// namespace infiniop_test::
gemm
src/infiniop/ops/
matmul
/ascend/
matmul
_ascend.cc
→
src/infiniop/ops/
gemm
/ascend/
gemm
_ascend.cc
View file @
452049e2
#include "
matmul
_ascend.h"
#include "
gemm
_ascend.h"
#include "../../../devices/ascend/common_ascend.h"
#include <aclnnop/aclnn_matmul.h>
#include <aclnnop/level2/aclnn_gemm.h>
namespace
op
::
matmul
::
ascend
{
namespace
op
::
gemm
::
ascend
{
struct
Descriptor
::
Opaque
{
mutable
aclOpExecutor
*
executor
;
...
...
@@ -116,4 +116,4 @@ infiniStatus_t Descriptor::calculate(
return
INFINI_STATUS_SUCCESS
;
}
}
// namespace op::
matmul
::ascend
}
// namespace op::
gemm
::ascend
src/infiniop/ops/gemm/ascend/gemm_ascend.h
0 → 100644
View file @
452049e2
#ifndef __GEMM_ASCEND_H__
#define __GEMM_ASCEND_H__
#include "../gemm.h"
DESCRIPTOR
(
ascend
)
#endif // __GEMM_ASCEND_H__
src/infiniop/ops/
matmul/bang/matmul
_bang.cc
→
src/infiniop/ops/
gemm/bang/gemm
_bang.cc
View file @
452049e2
#
include
"
matmul
_bang.h"
#
include
"
gemm
_bang.h"
#include "../../../devices/bang/common_bang.h"
#include <cnnl_extra.h>
namespace
op
::
matmul
::
bang
{
namespace
op
::
gemm
::
bang
{
struct
Descriptor
::
Opaque
{
cnnlMatMulDescriptor_t
op
;
...
...
@@ -157,4 +157,4 @@ infiniStatus_t Descriptor::calculate(
return
INFINI_STATUS_SUCCESS
;
}
}
// namespace op::
matmul
::bang
}
// namespace op::
gemm
::bang
src/infiniop/ops/gemm/bang/gemm_bang.h
0 → 100644
View file @
452049e2
#ifndef __GEMM_BANG_H__
#define __GEMM_BANG_H__
#include "../gemm.h"
DESCRIPTOR
(
bang
)
#endif // __GEMM_BANG_H__
src/infiniop/ops/
matmul
/blas.h
→
src/infiniop/ops/
gemm
/blas.h
View file @
452049e2
...
...
@@ -5,7 +5,7 @@
#include "../../tensor.h"
#include <algorithm>
namespace
op
::
matmul
{
namespace
op
::
gemm
{
struct
BlasMatrix
{
size_t
ndim
;
...
...
@@ -120,6 +120,6 @@ struct MatmulInfo {
}
};
}
// namespace op::
matmul
}
// namespace op::
gemm
#endif // __BLAS_H__
src/infiniop/ops/
matmul/cpu/matmul
_cpu.cc
→
src/infiniop/ops/
gemm/cpu/gemm
_cpu.cc
View file @
452049e2
#include "
matmul
_cpu.h"
#include "
gemm
_cpu.h"
#include "../../../devices/cpu/common_cpu.h"
namespace
op
::
matmul
::
cpu
{
namespace
op
::
gemm
::
cpu
{
Descriptor
::~
Descriptor
()
=
default
;
...
...
@@ -95,4 +95,4 @@ infiniStatus_t Descriptor::calculate(
}
}
}
// namespace op::
matmul
::cpu
}
// namespace op::
gemm
::cpu
src/infiniop/ops/gemm/cpu/gemm_cpu.h
0 → 100644
View file @
452049e2
#ifndef __GEMM_CPU_H__
#define __GEMM_CPU_H__
#include "../gemm.h"
DESCRIPTOR
(
cpu
)
#endif // __GEMM_CPU_H__
src/infiniop/ops/
matmul/cuda/matmul
_cuda.cu
→
src/infiniop/ops/
gemm/cuda/gemm
_cuda.cu
View file @
452049e2
#include "../../../devices/cuda/cuda_handle.cuh"
#include "
matmul
_cuda.cuh"
#include "
gemm
_cuda.cuh"
namespace
op
::
matmul
::
cuda
{
namespace
op
::
gemm
::
cuda
{
struct
Descriptor
::
Opaque
{
std
::
shared_ptr
<
device
::
cuda
::
Handle
::
Internal
>
internal
;
...
...
@@ -109,4 +109,4 @@ infiniStatus_t Descriptor::calculate(
return
INFINI_STATUS_SUCCESS
;
}
}
// namespace op::
matmul
::cuda
}
// namespace op::
gemm
::cuda
src/infiniop/ops/gemm/cuda/gemm_cuda.cuh
0 → 100644
View file @
452049e2
#ifndef __GEMM_CUDA_CUH__
#define __GEMM_CUDA_CUH__
#include "../gemm.h"
DESCRIPTOR
(
cuda
)
#endif // __GEMM_CUDA_CUH__
src/infiniop/ops/
matmul/matmul
.h
→
src/infiniop/ops/
gemm/gemm
.h
View file @
452049e2
#ifndef __
MATMUL
_H__
#define __
MATMUL
_H__
#ifndef __
GEMM
_H__
#define __
GEMM
_H__
#include "../../operator.h"
#include "blas.h"
...
...
@@ -46,7 +46,7 @@
#define DESCRIPTOR(NAMESPACE) \
\
namespace op::
matmul
::NAMESPACE { \
namespace op::
gemm
::NAMESPACE {
\
class Descriptor final : public InfiniopDescriptor { \
struct Opaque; \
Opaque *_opaque; \
...
...
@@ -90,4 +90,4 @@
}; \
}
#endif // __
MATMUL
_H__
#endif // __
GEMM
_H__
src/infiniop/ops/
matmul
/kunlun/
matmul
_kunlun.cc
→
src/infiniop/ops/
gemm
/kunlun/
gemm
_kunlun.cc
View file @
452049e2
#include "
matmul
_kunlun.h"
#include "
gemm
_kunlun.h"
#include "../../../../utils.h"
#include "../../../devices/kunlun/kunlun_handle.h"
namespace
op
::
matmul
::
kunlun
{
namespace
op
::
gemm
::
kunlun
{
typedef
device
::
kunlun
::
Handle
::
Internal
HandleInternal
;
...
...
@@ -103,12 +103,12 @@ infiniStatus_t Descriptor::calculate(
void
*
stream
)
const
{
switch
(
_dtype
)
{
case
INFINI_DTYPE_F16
:
return
op
::
matmul
::
kunlun
::
calculate
<
float16
>
(
_info
,
_opaque
->
internal
,
_dtype
,
c
,
beta
,
a
,
b
,
alpha
,
(
kunlunStream_t
)
stream
);
return
op
::
gemm
::
kunlun
::
calculate
<
float16
>
(
_info
,
_opaque
->
internal
,
_dtype
,
c
,
beta
,
a
,
b
,
alpha
,
(
kunlunStream_t
)
stream
);
case
INFINI_DTYPE_F32
:
return
op
::
matmul
::
kunlun
::
calculate
<
float
>
(
_info
,
_opaque
->
internal
,
_dtype
,
c
,
beta
,
a
,
b
,
alpha
,
(
kunlunStream_t
)
stream
);
return
op
::
gemm
::
kunlun
::
calculate
<
float
>
(
_info
,
_opaque
->
internal
,
_dtype
,
c
,
beta
,
a
,
b
,
alpha
,
(
kunlunStream_t
)
stream
);
default:
return
INFINI_STATUS_BAD_TENSOR_DTYPE
;
}
}
}
// namespace op::
matmul
::kunlun
}
// namespace op::
gemm
::kunlun
src/infiniop/ops/gemm/kunlun/gemm_kunlun.h
0 → 100644
View file @
452049e2
#ifndef __GEMM_KUNLUN_H__
#define __GEMM_KUNLUN_H__
#include "../gemm.h"
DESCRIPTOR
(
kunlun
)
#endif // __GEMM_KUNLUN_H__
Prev
1
2
Next
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