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
80edd992
Commit
80edd992
authored
Feb 25, 2025
by
PanZezhong
Browse files
issue/71 合并infiniStatus
parent
e77735ef
Changes
51
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
97 additions
and
97 deletions
+97
-97
src/infiniop/ops/matmul/blas.h
src/infiniop/ops/matmul/blas.h
+10
-10
src/infiniop/ops/matmul/cpu/matmul_cpu.cc
src/infiniop/ops/matmul/cpu/matmul_cpu.cc
+9
-9
src/infiniop/ops/matmul/cuda/matmul_cuda.cu
src/infiniop/ops/matmul/cuda/matmul_cuda.cu
+9
-9
src/infiniop/ops/matmul/matmul.h
src/infiniop/ops/matmul/matmul.h
+2
-2
src/infiniop/ops/matmul/operator.cc
src/infiniop/ops/matmul/operator.cc
+10
-10
src/infiniop/ops/random_sample/operator.cc
src/infiniop/ops/random_sample/operator.cc
+17
-17
src/infiniop/ops/rearrange/operator.cc
src/infiniop/ops/rearrange/operator.cc
+6
-6
src/infiniop/ops/rms_norm/operator.cc
src/infiniop/ops/rms_norm/operator.cc
+9
-9
src/infiniop/ops/rotary_embedding/operator.cc
src/infiniop/ops/rotary_embedding/operator.cc
+13
-13
src/infiniop/ops/swiglu/operator.cc
src/infiniop/ops/swiglu/operator.cc
+8
-8
src/infiniop/tensor_descriptor.cc
src/infiniop/tensor_descriptor.cc
+4
-4
No files found.
src/infiniop/ops/matmul/blas.h
View file @
80edd992
...
@@ -16,7 +16,7 @@ struct BlasMatrix {
...
@@ -16,7 +16,7 @@ struct BlasMatrix {
BlasMatrix
()
=
default
;
BlasMatrix
()
=
default
;
BlasMatrix
(
infiniopTensorDescriptor_t
layout
,
infini
op
Status_t
*
status
)
{
BlasMatrix
(
infiniopTensorDescriptor_t
layout
,
infiniStatus_t
*
status
)
{
if
(
layout
->
ndim
==
2
)
{
if
(
layout
->
ndim
==
2
)
{
ndim
=
2
;
ndim
=
2
;
batch
=
1
;
batch
=
1
;
...
@@ -34,16 +34,16 @@ struct BlasMatrix {
...
@@ -34,16 +34,16 @@ struct BlasMatrix {
row_stride
=
layout
->
strides
[
1
];
row_stride
=
layout
->
strides
[
1
];
col_stride
=
layout
->
strides
[
2
];
col_stride
=
layout
->
strides
[
2
];
}
else
{
}
else
{
*
status
=
INFINI
OP
_STATUS_BAD_TENSOR_SHAPE
;
*
status
=
INFINI_STATUS_BAD_TENSOR_SHAPE
;
return
;
return
;
}
}
if
(
row_stride
!=
1
&&
col_stride
!=
1
)
{
if
(
row_stride
!=
1
&&
col_stride
!=
1
)
{
*
status
=
INFINI
OP
_STATUS_BAD_TENSOR_STRIDES
;
*
status
=
INFINI_STATUS_BAD_TENSOR_STRIDES
;
return
;
return
;
}
}
*
status
=
INFINI
OP
_STATUS_SUCCESS
;
*
status
=
INFINI_STATUS_SUCCESS
;
}
}
bool
match_batch
(
size_t
_batch
)
const
{
bool
match_batch
(
size_t
_batch
)
const
{
...
@@ -77,29 +77,29 @@ struct MatmulInfo {
...
@@ -77,29 +77,29 @@ struct MatmulInfo {
MatmulInfo
(
infiniopTensorDescriptor_t
c_desc
,
MatmulInfo
(
infiniopTensorDescriptor_t
c_desc
,
infiniopTensorDescriptor_t
a_desc
,
infiniopTensorDescriptor_t
a_desc
,
infiniopTensorDescriptor_t
b_desc
,
infiniopTensorDescriptor_t
b_desc
,
infini
op
Status_t
*
status
,
infiniStatus_t
*
status
,
MatrixLayout
layout
)
{
MatrixLayout
layout
)
{
a_matrix
=
BlasMatrix
(
a_desc
,
status
);
a_matrix
=
BlasMatrix
(
a_desc
,
status
);
if
(
*
status
!=
INFINI
OP
_STATUS_SUCCESS
)
{
if
(
*
status
!=
INFINI_STATUS_SUCCESS
)
{
return
;
return
;
}
}
b_matrix
=
BlasMatrix
(
b_desc
,
status
);
b_matrix
=
BlasMatrix
(
b_desc
,
status
);
if
(
*
status
!=
INFINI
OP
_STATUS_SUCCESS
)
{
if
(
*
status
!=
INFINI_STATUS_SUCCESS
)
{
return
;
return
;
}
}
c_matrix
=
BlasMatrix
(
c_desc
,
status
);
c_matrix
=
BlasMatrix
(
c_desc
,
status
);
if
(
*
status
!=
INFINI
OP
_STATUS_SUCCESS
)
{
if
(
*
status
!=
INFINI_STATUS_SUCCESS
)
{
return
;
return
;
}
}
if
(
c_matrix
.
rows
!=
a_matrix
.
rows
||
c_matrix
.
cols
!=
b_matrix
.
cols
||
a_matrix
.
cols
!=
b_matrix
.
rows
)
{
if
(
c_matrix
.
rows
!=
a_matrix
.
rows
||
c_matrix
.
cols
!=
b_matrix
.
cols
||
a_matrix
.
cols
!=
b_matrix
.
rows
)
{
*
status
=
INFINI
OP
_STATUS_BAD_TENSOR_SHAPE
;
*
status
=
INFINI_STATUS_BAD_TENSOR_SHAPE
;
return
;
return
;
}
}
batch
=
c_matrix
.
batch
;
batch
=
c_matrix
.
batch
;
if
(
!
a_matrix
.
match_batch
(
batch
)
||
!
b_matrix
.
match_batch
(
batch
))
{
if
(
!
a_matrix
.
match_batch
(
batch
)
||
!
b_matrix
.
match_batch
(
batch
))
{
*
status
=
INFINI
OP
_STATUS_BAD_TENSOR_SHAPE
;
*
status
=
INFINI_STATUS_BAD_TENSOR_SHAPE
;
return
;
return
;
}
}
...
...
src/infiniop/ops/matmul/cpu/matmul_cpu.cc
View file @
80edd992
...
@@ -6,7 +6,7 @@ namespace matmul::cpu {
...
@@ -6,7 +6,7 @@ namespace matmul::cpu {
Descriptor
::~
Descriptor
()
=
default
;
Descriptor
::~
Descriptor
()
=
default
;
infini
op
Status_t
Descriptor
::
create
(
infiniStatus_t
Descriptor
::
create
(
infiniopHandle_t
handle_
,
infiniopHandle_t
handle_
,
Descriptor
**
desc_ptr
,
Descriptor
**
desc_ptr
,
infiniopTensorDescriptor_t
c_desc
,
infiniopTensorDescriptor_t
c_desc
,
...
@@ -16,12 +16,12 @@ infiniopStatus_t Descriptor::create(
...
@@ -16,12 +16,12 @@ infiniopStatus_t Descriptor::create(
auto
dtype
=
c_desc
->
dtype
;
auto
dtype
=
c_desc
->
dtype
;
if
(
dtype
!=
INFINI_DTYPE_F16
&&
dtype
!=
INFINI_DTYPE_F32
)
{
if
(
dtype
!=
INFINI_DTYPE_F16
&&
dtype
!=
INFINI_DTYPE_F32
)
{
return
INFINI
OP
_STATUS_BAD_TENSOR_DTYPE
;
return
INFINI_STATUS_BAD_TENSOR_DTYPE
;
}
}
infini
op
Status_t
status
;
infiniStatus_t
status
;
auto
info
=
MatmulInfo
(
c_desc
,
a_desc
,
b_desc
,
&
status
,
MatrixLayout
::
COL_MAJOR
);
auto
info
=
MatmulInfo
(
c_desc
,
a_desc
,
b_desc
,
&
status
,
MatrixLayout
::
COL_MAJOR
);
if
(
status
!=
INFINI
OP
_STATUS_SUCCESS
)
{
if
(
status
!=
INFINI_STATUS_SUCCESS
)
{
return
status
;
return
status
;
}
}
...
@@ -29,7 +29,7 @@ infiniopStatus_t Descriptor::create(
...
@@ -29,7 +29,7 @@ infiniopStatus_t Descriptor::create(
dtype
,
info
,
0
,
dtype
,
info
,
0
,
nullptr
,
nullptr
,
handle
->
device
,
handle
->
device_id
);
handle
->
device
,
handle
->
device_id
);
return
INFINI
OP
_STATUS_SUCCESS
;
return
INFINI_STATUS_SUCCESS
;
}
}
template
<
typename
Tdata
>
template
<
typename
Tdata
>
...
@@ -72,7 +72,7 @@ void calculate(
...
@@ -72,7 +72,7 @@ void calculate(
}
}
}
}
infini
op
Status_t
Descriptor
::
calculate
(
infiniStatus_t
Descriptor
::
calculate
(
void
*
workspace
,
void
*
workspace
,
size_t
workspace_size
,
size_t
workspace_size
,
void
*
c
,
void
*
c
,
...
@@ -85,14 +85,14 @@ infiniopStatus_t Descriptor::calculate(
...
@@ -85,14 +85,14 @@ infiniopStatus_t Descriptor::calculate(
switch
(
_dtype
)
{
switch
(
_dtype
)
{
case
INFINI_DTYPE_F16
:
case
INFINI_DTYPE_F16
:
cpu
::
calculate
<
uint16_t
>
(
_info
,
c
,
beta
,
a
,
b
,
alpha
);
cpu
::
calculate
<
uint16_t
>
(
_info
,
c
,
beta
,
a
,
b
,
alpha
);
return
INFINI
OP
_STATUS_SUCCESS
;
return
INFINI_STATUS_SUCCESS
;
case
INFINI_DTYPE_F32
:
case
INFINI_DTYPE_F32
:
cpu
::
calculate
<
float
>
(
_info
,
c
,
beta
,
a
,
b
,
alpha
);
cpu
::
calculate
<
float
>
(
_info
,
c
,
beta
,
a
,
b
,
alpha
);
return
INFINI
OP
_STATUS_SUCCESS
;
return
INFINI_STATUS_SUCCESS
;
default:
default:
return
INFINI
OP
_STATUS_BAD_TENSOR_DTYPE
;
return
INFINI_STATUS_BAD_TENSOR_DTYPE
;
}
}
}
}
...
...
src/infiniop/ops/matmul/cuda/matmul_cuda.cu
View file @
80edd992
...
@@ -12,7 +12,7 @@ Descriptor::~Descriptor() {
...
@@ -12,7 +12,7 @@ Descriptor::~Descriptor() {
delete
_opaque
;
delete
_opaque
;
}
}
infini
op
Status_t
Descriptor
::
create
(
infiniStatus_t
Descriptor
::
create
(
infiniopHandle_t
handle_
,
infiniopHandle_t
handle_
,
Descriptor
**
desc_ptr
,
Descriptor
**
desc_ptr
,
infiniopTensorDescriptor_t
c_desc
,
infiniopTensorDescriptor_t
c_desc
,
...
@@ -22,12 +22,12 @@ infiniopStatus_t Descriptor::create(
...
@@ -22,12 +22,12 @@ infiniopStatus_t Descriptor::create(
auto
dtype
=
c_desc
->
dtype
;
auto
dtype
=
c_desc
->
dtype
;
if
(
dtype
!=
INFINI_DTYPE_F16
&&
dtype
!=
INFINI_DTYPE_F32
)
{
if
(
dtype
!=
INFINI_DTYPE_F16
&&
dtype
!=
INFINI_DTYPE_F32
)
{
return
INFINI
OP
_STATUS_BAD_TENSOR_DTYPE
;
return
INFINI_STATUS_BAD_TENSOR_DTYPE
;
}
}
infini
op
Status_t
status
;
infiniStatus_t
status
;
auto
info
=
MatmulInfo
(
c_desc
,
a_desc
,
b_desc
,
&
status
,
MatrixLayout
::
COL_MAJOR
);
auto
info
=
MatmulInfo
(
c_desc
,
a_desc
,
b_desc
,
&
status
,
MatrixLayout
::
COL_MAJOR
);
if
(
status
!=
INFINI
OP
_STATUS_SUCCESS
)
{
if
(
status
!=
INFINI_STATUS_SUCCESS
)
{
return
status
;
return
status
;
}
}
...
@@ -35,7 +35,7 @@ infiniopStatus_t Descriptor::create(
...
@@ -35,7 +35,7 @@ infiniopStatus_t Descriptor::create(
dtype
,
info
,
0
,
dtype
,
info
,
0
,
new
Opaque
{
handle
->
cublas_handle_pool
},
new
Opaque
{
handle
->
cublas_handle_pool
},
handle
->
device
,
handle
->
device_id
);
handle
->
device
,
handle
->
device_id
);
return
INFINI
OP
_STATUS_SUCCESS
;
return
INFINI_STATUS_SUCCESS
;
}
}
template
<
typename
Tdata
>
template
<
typename
Tdata
>
...
@@ -100,7 +100,7 @@ void calculate(
...
@@ -100,7 +100,7 @@ void calculate(
});
});
}
}
infini
op
Status_t
Descriptor
::
calculate
(
infiniStatus_t
Descriptor
::
calculate
(
void
*
workspace
,
void
*
workspace
,
size_t
workspace_size
,
size_t
workspace_size
,
void
*
c
,
void
*
c
,
...
@@ -113,14 +113,14 @@ infiniopStatus_t Descriptor::calculate(
...
@@ -113,14 +113,14 @@ infiniopStatus_t Descriptor::calculate(
switch
(
_dtype
)
{
switch
(
_dtype
)
{
case
INFINI_DTYPE_F16
:
case
INFINI_DTYPE_F16
:
cuda
::
calculate
<
uint16_t
>
(
_info
,
_opaque
->
cublas_handle_pool
,
c
,
beta
,
a
,
b
,
alpha
,
(
cudaStream_t
)
stream
);
cuda
::
calculate
<
uint16_t
>
(
_info
,
_opaque
->
cublas_handle_pool
,
c
,
beta
,
a
,
b
,
alpha
,
(
cudaStream_t
)
stream
);
return
INFINI
OP
_STATUS_SUCCESS
;
return
INFINI_STATUS_SUCCESS
;
case
INFINI_DTYPE_F32
:
case
INFINI_DTYPE_F32
:
cuda
::
calculate
<
float
>
(
_info
,
_opaque
->
cublas_handle_pool
,
c
,
beta
,
a
,
b
,
alpha
,
(
cudaStream_t
)
stream
);
cuda
::
calculate
<
float
>
(
_info
,
_opaque
->
cublas_handle_pool
,
c
,
beta
,
a
,
b
,
alpha
,
(
cudaStream_t
)
stream
);
return
INFINI
OP
_STATUS_SUCCESS
;
return
INFINI_STATUS_SUCCESS
;
default:
default:
return
INFINI
OP
_STATUS_BAD_TENSOR_DTYPE
;
return
INFINI_STATUS_BAD_TENSOR_DTYPE
;
}
}
}
}
...
...
src/infiniop/ops/matmul/matmul.h
View file @
80edd992
...
@@ -71,14 +71,14 @@
...
@@ -71,14 +71,14 @@
\
\
~Descriptor(); \
~Descriptor(); \
\
\
static infini
op
Status_t create( \
static infiniStatus_t create(
\
infiniopHandle_t handle, \
infiniopHandle_t handle, \
Descriptor **desc_ptr, \
Descriptor **desc_ptr, \
infiniopTensorDescriptor_t c_desc, \
infiniopTensorDescriptor_t c_desc, \
infiniopTensorDescriptor_t a_desc, \
infiniopTensorDescriptor_t a_desc, \
infiniopTensorDescriptor_t b_desc); \
infiniopTensorDescriptor_t b_desc); \
\
\
infini
op
Status_t calculate( \
infiniStatus_t calculate(
\
void *workspace, \
void *workspace, \
size_t workspace_size, \
size_t workspace_size, \
void *c, \
void *c, \
...
...
src/infiniop/ops/matmul/operator.cc
View file @
80edd992
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
#include "ascend/matmul_ascend.h"
#include "ascend/matmul_ascend.h"
#endif
#endif
__C
infini
op
Status_t
infiniopCreateMatmulDescriptor
(
__C
infiniStatus_t
infiniopCreateMatmulDescriptor
(
infiniopHandle_t
handle
,
infiniopHandle_t
handle
,
infiniopMatmulDescriptor_t
*
desc_ptr
,
infiniopMatmulDescriptor_t
*
desc_ptr
,
infiniopTensorDescriptor_t
c_desc
,
infiniopTensorDescriptor_t
c_desc
,
...
@@ -45,13 +45,13 @@ __C infiniopStatus_t infiniopCreateMatmulDescriptor(
...
@@ -45,13 +45,13 @@ __C infiniopStatus_t infiniopCreateMatmulDescriptor(
#endif
#endif
default:
default:
return
INFINI
OP
_STATUS_DEVICE_TYPE_NOT_SUPPORTED
;
return
INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED
;
}
}
#undef CREATE
#undef CREATE
}
}
__C
infini
op
Status_t
__C
infiniStatus_t
infiniopGetMatmulWorkspaceSize
(
infiniopGetMatmulWorkspaceSize
(
infiniopMatmulDescriptor_t
desc
,
infiniopMatmulDescriptor_t
desc
,
size_t
*
size
)
{
size_t
*
size
)
{
...
@@ -59,7 +59,7 @@ infiniopGetMatmulWorkspaceSize(
...
@@ -59,7 +59,7 @@ infiniopGetMatmulWorkspaceSize(
#define GET(CASE, NAMESPACE) \
#define GET(CASE, NAMESPACE) \
case CASE: \
case CASE: \
*size = reinterpret_cast<const matmul::NAMESPACE::Descriptor *>(desc)->workspace_size; \
*size = reinterpret_cast<const matmul::NAMESPACE::Descriptor *>(desc)->workspace_size; \
return INFINI
OP
_STATUS_SUCCESS
return INFINI_STATUS_SUCCESS
switch
(
desc
->
device_type
)
{
switch
(
desc
->
device_type
)
{
...
@@ -77,13 +77,13 @@ infiniopGetMatmulWorkspaceSize(
...
@@ -77,13 +77,13 @@ infiniopGetMatmulWorkspaceSize(
#endif
#endif
default:
default:
return
INFINI
OP
_STATUS_DEVICE_TYPE_NOT_SUPPORTED
;
return
INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED
;
}
}
#undef GET
#undef GET
}
}
__C
infini
op
Status_t
infiniopMatmul
(
__C
infiniStatus_t
infiniopMatmul
(
infiniopMatmulDescriptor_t
desc
,
infiniopMatmulDescriptor_t
desc
,
void
*
workspace
,
size_t
workspace_size
,
void
*
workspace
,
size_t
workspace_size
,
void
*
c
,
void
*
c
,
...
@@ -117,19 +117,19 @@ __C infiniopStatus_t infiniopMatmul(
...
@@ -117,19 +117,19 @@ __C infiniopStatus_t infiniopMatmul(
#endif
#endif
default:
default:
return
INFINI
OP
_STATUS_DEVICE_TYPE_NOT_SUPPORTED
;
return
INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED
;
}
}
#undef CALCULATE
#undef CALCULATE
}
}
__C
infini
op
Status_t
__C
infiniStatus_t
infiniopDestroyMatmulDescriptor
(
infiniopMatmulDescriptor_t
desc
)
{
infiniopDestroyMatmulDescriptor
(
infiniopMatmulDescriptor_t
desc
)
{
#define DELETE(CASE, NAMESPACE) \
#define DELETE(CASE, NAMESPACE) \
case CASE: \
case CASE: \
delete reinterpret_cast<const matmul::NAMESPACE::Descriptor *>(desc); \
delete reinterpret_cast<const matmul::NAMESPACE::Descriptor *>(desc); \
return INFINI
OP
_STATUS_SUCCESS;
return INFINI_STATUS_SUCCESS;
switch
(
desc
->
device_type
)
{
switch
(
desc
->
device_type
)
{
...
@@ -147,7 +147,7 @@ infiniopDestroyMatmulDescriptor(infiniopMatmulDescriptor_t desc) {
...
@@ -147,7 +147,7 @@ infiniopDestroyMatmulDescriptor(infiniopMatmulDescriptor_t desc) {
#endif
#endif
default:
default:
return
INFINI
OP
_STATUS_DEVICE_TYPE_NOT_SUPPORTED
;
return
INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED
;
}
}
#undef DELETE
#undef DELETE
...
...
src/infiniop/ops/random_sample/operator.cc
View file @
80edd992
#include "infiniop/ops/random_sample.h"
#include "infiniop/ops/random_sample.h"
__C
infini
op
Status_t
infiniopCreateRandomSampleDescriptor
(
infiniopHandle_t
handle
,
infiniopRandomSampleDescriptor_t
*
desc_ptr
,
infiniopTensorDescriptor_t
result
,
infiniopTensorDescriptor_t
probs
)
{
__C
infiniStatus_t
infiniopCreateRandomSampleDescriptor
(
infiniopHandle_t
handle
,
infiniopRandomSampleDescriptor_t
*
desc_ptr
,
infiniopTensorDescriptor_t
result
,
infiniopTensorDescriptor_t
probs
)
{
switch
(
handle
->
device
)
{
switch
(
handle
->
device
)
{
#ifdef ENABLE_CPU
#ifdef ENABLE_CPU
case
DevCpu
:
case
DevCpu
:
...
@@ -35,10 +35,10 @@ __C infiniopStatus_t infiniopCreateRandomSampleDescriptor(infiniopHandle_t handl
...
@@ -35,10 +35,10 @@ __C infiniopStatus_t infiniopCreateRandomSampleDescriptor(infiniopHandle_t handl
return
musaCreateRandomSampleDescriptor
((
MusaHandle_t
)
handle
,
(
RandomSampleMusaDescriptor_t
*
)
desc_ptr
,
result
,
probs
);
return
musaCreateRandomSampleDescriptor
((
MusaHandle_t
)
handle
,
(
RandomSampleMusaDescriptor_t
*
)
desc_ptr
,
result
,
probs
);
#endif
#endif
}
}
return
INFINI
OP
_STATUS_DEVICE_TYPE_NOT_SUPPORTED
;
return
INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED
;
};
};
__C
infini
op
Status_t
infiniopGetRandomSampleWorkspaceSize
(
infiniopRandomSampleDescriptor_t
desc
,
size_t
*
size
)
{
__C
infiniStatus_t
infiniopGetRandomSampleWorkspaceSize
(
infiniopRandomSampleDescriptor_t
desc
,
size_t
*
size
)
{
switch
(
desc
->
device_type
)
{
switch
(
desc
->
device_type
)
{
#ifdef ENABLE_CPU
#ifdef ENABLE_CPU
case
DevCpu
:
case
DevCpu
:
...
@@ -72,19 +72,19 @@ __C infiniopStatus_t infiniopGetRandomSampleWorkspaceSize(infiniopRandomSampleDe
...
@@ -72,19 +72,19 @@ __C infiniopStatus_t infiniopGetRandomSampleWorkspaceSize(infiniopRandomSampleDe
}
}
#endif
#endif
}
}
return
INFINI
OP
_STATUS_DEVICE_TYPE_NOT_SUPPORTED
;
return
INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED
;
}
}
__C
infini
op
Status_t
infiniopRandomSample
(
infiniopRandomSampleDescriptor_t
desc
,
__C
infiniStatus_t
infiniopRandomSample
(
infiniopRandomSampleDescriptor_t
desc
,
void
*
workspace
,
void
*
workspace
,
size_t
workspace_size
,
size_t
workspace_size
,
void
*
result
,
void
*
result
,
const
void
*
probs
,
const
void
*
probs
,
float
random_val
,
float
random_val
,
float
topp
,
float
topp
,
int
topk
,
int
topk
,
float
temperature
,
float
temperature
,
void
*
stream
)
{
void
*
stream
)
{
switch
(
desc
->
device_type
)
{
switch
(
desc
->
device_type
)
{
#ifdef ENABLE_CPU
#ifdef ENABLE_CPU
case
DevCpu
:
case
DevCpu
:
...
@@ -114,10 +114,10 @@ __C infiniopStatus_t infiniopRandomSample(infiniopRandomSampleDescriptor_t desc,
...
@@ -114,10 +114,10 @@ __C infiniopStatus_t infiniopRandomSample(infiniopRandomSampleDescriptor_t desc,
return
musaRandomSample
((
RandomSampleMusaDescriptor_t
)
desc
,
workspace
,
workspace_size
,
result
,
probs
,
random_val
,
topp
,
topk
,
temperature
,
stream
);
return
musaRandomSample
((
RandomSampleMusaDescriptor_t
)
desc
,
workspace
,
workspace_size
,
result
,
probs
,
random_val
,
topp
,
topk
,
temperature
,
stream
);
#endif
#endif
}
}
return
INFINI
OP
_STATUS_DEVICE_TYPE_NOT_SUPPORTED
;
return
INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED
;
}
}
__C
infini
op
Status_t
infiniopDestroyRandomSampleDescriptor
(
infiniopRandomSampleDescriptor_t
desc
)
{
__C
infiniStatus_t
infiniopDestroyRandomSampleDescriptor
(
infiniopRandomSampleDescriptor_t
desc
)
{
switch
(
desc
->
device_type
)
{
switch
(
desc
->
device_type
)
{
#ifdef ENABLE_CPU
#ifdef ENABLE_CPU
case
DevCpu
:
case
DevCpu
:
...
@@ -147,5 +147,5 @@ __C infiniopStatus_t infiniopDestroyRandomSampleDescriptor(infiniopRandomSampleD
...
@@ -147,5 +147,5 @@ __C infiniopStatus_t infiniopDestroyRandomSampleDescriptor(infiniopRandomSampleD
return
musaDestroyRandomSampleDescriptor
((
RandomSampleMusaDescriptor_t
)
desc
);
return
musaDestroyRandomSampleDescriptor
((
RandomSampleMusaDescriptor_t
)
desc
);
#endif
#endif
}
}
return
INFINI
OP
_STATUS_DEVICE_TYPE_NOT_SUPPORTED
;
return
INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED
;
}
}
src/infiniop/ops/rearrange/operator.cc
View file @
80edd992
#include "infiniop/ops/rearrange.h"
#include "infiniop/ops/rearrange.h"
__C
infini
op
Status_t
infiniopCreateRearrangeDescriptor
(
__C
infiniStatus_t
infiniopCreateRearrangeDescriptor
(
infiniopHandle_t
handle
,
infiniopHandle_t
handle
,
infiniopRearrangeDescriptor_t
*
desc_ptr
,
infiniopRearrangeDescriptor_t
*
desc_ptr
,
infiniopTensorDescriptor_t
dst
,
infiniopTensorDescriptor_t
dst
,
...
@@ -40,10 +40,10 @@ __C infiniopStatus_t infiniopCreateRearrangeDescriptor(
...
@@ -40,10 +40,10 @@ __C infiniopStatus_t infiniopCreateRearrangeDescriptor(
}
}
#endif
#endif
}
}
return
INFINI
OP
_STATUS_DEVICE_TYPE_NOT_SUPPORTED
;
return
INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED
;
}
}
__C
infini
op
Status_t
infiniopRearrange
(
infiniopRearrangeDescriptor_t
desc
,
void
*
dst
,
const
void
*
src
,
void
*
stream
)
{
__C
infiniStatus_t
infiniopRearrange
(
infiniopRearrangeDescriptor_t
desc
,
void
*
dst
,
const
void
*
src
,
void
*
stream
)
{
switch
(
desc
->
device_type
)
{
switch
(
desc
->
device_type
)
{
#ifdef ENABLE_CPU
#ifdef ENABLE_CPU
case
DevCpu
:
case
DevCpu
:
...
@@ -79,10 +79,10 @@ __C infiniopStatus_t infiniopRearrange(infiniopRearrangeDescriptor_t desc, void
...
@@ -79,10 +79,10 @@ __C infiniopStatus_t infiniopRearrange(infiniopRearrangeDescriptor_t desc, void
}
}
#endif
#endif
}
}
return
INFINI
OP
_STATUS_DEVICE_TYPE_NOT_SUPPORTED
;
return
INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED
;
}
}
__C
infini
op
Status_t
infiniopDestroyRearrangeDescriptor
(
infiniopRearrangeDescriptor_t
desc
)
{
__C
infiniStatus_t
infiniopDestroyRearrangeDescriptor
(
infiniopRearrangeDescriptor_t
desc
)
{
switch
(
desc
->
device_type
)
{
switch
(
desc
->
device_type
)
{
#ifdef ENABLE_CPU
#ifdef ENABLE_CPU
case
DevCpu
:
case
DevCpu
:
...
@@ -115,5 +115,5 @@ __C infiniopStatus_t infiniopDestroyRearrangeDescriptor(infiniopRearrangeDescrip
...
@@ -115,5 +115,5 @@ __C infiniopStatus_t infiniopDestroyRearrangeDescriptor(infiniopRearrangeDescrip
}
}
#endif
#endif
}
}
return
INFINI
OP
_STATUS_DEVICE_TYPE_NOT_SUPPORTED
;
return
INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED
;
}
}
src/infiniop/ops/rms_norm/operator.cc
View file @
80edd992
#include "infiniop/ops/rms_norm.h"
#include "infiniop/ops/rms_norm.h"
__C
infini
op
Status_t
infiniopCreateRMSNormDescriptor
(
__C
infiniStatus_t
infiniopCreateRMSNormDescriptor
(
infiniopHandle_t
handle
,
infiniopHandle_t
handle
,
infiniopRMSNormDescriptor_t
*
desc_ptr
,
infiniopRMSNormDescriptor_t
*
desc_ptr
,
infiniopTensorDescriptor_t
y_desc
,
infiniopTensorDescriptor_t
y_desc
,
...
@@ -43,10 +43,10 @@ __C infiniopStatus_t infiniopCreateRMSNormDescriptor(
...
@@ -43,10 +43,10 @@ __C infiniopStatus_t infiniopCreateRMSNormDescriptor(
}
}
#endif
#endif
}
}
return
INFINI
OP
_STATUS_DEVICE_TYPE_NOT_SUPPORTED
;
return
INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED
;
}
}
__C
infini
op
Status_t
infiniopGetRMSNormWorkspaceSize
(
infiniopRMSNormDescriptor_t
desc
,
size_t
*
size
)
{
__C
infiniStatus_t
infiniopGetRMSNormWorkspaceSize
(
infiniopRMSNormDescriptor_t
desc
,
size_t
*
size
)
{
switch
(
desc
->
device_type
)
{
switch
(
desc
->
device_type
)
{
#ifdef ENABLE_CPU
#ifdef ENABLE_CPU
case
DevCpu
:
case
DevCpu
:
...
@@ -80,11 +80,11 @@ __C infiniopStatus_t infiniopGetRMSNormWorkspaceSize(infiniopRMSNormDescriptor_t
...
@@ -80,11 +80,11 @@ __C infiniopStatus_t infiniopGetRMSNormWorkspaceSize(infiniopRMSNormDescriptor_t
}
}
#endif
#endif
}
}
return
INFINI
OP
_STATUS_DEVICE_TYPE_NOT_SUPPORTED
;
return
INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED
;
}
}
__C
infini
op
Status_t
infiniopRMSNorm
(
infiniopRMSNormDescriptor_t
desc
,
void
*
workspace
,
size_t
workspace_size
,
__C
infiniStatus_t
infiniopRMSNorm
(
infiniopRMSNormDescriptor_t
desc
,
void
*
workspace
,
size_t
workspace_size
,
void
*
y
,
const
void
*
x
,
const
void
*
w
,
void
*
stream
)
{
void
*
y
,
const
void
*
x
,
const
void
*
w
,
void
*
stream
)
{
switch
(
desc
->
device_type
)
{
switch
(
desc
->
device_type
)
{
#ifdef ENABLE_CPU
#ifdef ENABLE_CPU
case
DevCpu
:
case
DevCpu
:
...
@@ -123,10 +123,10 @@ __C infiniopStatus_t infiniopRMSNorm(infiniopRMSNormDescriptor_t desc, void *wor
...
@@ -123,10 +123,10 @@ __C infiniopStatus_t infiniopRMSNorm(infiniopRMSNormDescriptor_t desc, void *wor
}
}
#endif
#endif
}
}
return
INFINI
OP
_STATUS_DEVICE_TYPE_NOT_SUPPORTED
;
return
INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED
;
}
}
__C
infini
op
Status_t
infiniopDestroyRMSNormDescriptor
(
infiniopRMSNormDescriptor_t
desc
)
{
__C
infiniStatus_t
infiniopDestroyRMSNormDescriptor
(
infiniopRMSNormDescriptor_t
desc
)
{
switch
(
desc
->
device_type
)
{
switch
(
desc
->
device_type
)
{
#ifdef ENABLE_CPU
#ifdef ENABLE_CPU
case
DevCpu
:
case
DevCpu
:
...
@@ -159,5 +159,5 @@ __C infiniopStatus_t infiniopDestroyRMSNormDescriptor(infiniopRMSNormDescriptor_
...
@@ -159,5 +159,5 @@ __C infiniopStatus_t infiniopDestroyRMSNormDescriptor(infiniopRMSNormDescriptor_
}
}
#endif
#endif
}
}
return
INFINI
OP
_STATUS_DEVICE_TYPE_NOT_SUPPORTED
;
return
INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED
;
}
}
src/infiniop/ops/rotary_embedding/operator.cc
View file @
80edd992
#include "infiniop/ops/rotary_embedding.h"
#include "infiniop/ops/rotary_embedding.h"
__C
infini
op
Status_t
infiniopCreateRoPEDescriptor
(
__C
infiniStatus_t
infiniopCreateRoPEDescriptor
(
infiniopHandle_t
handle
,
infiniopRoPEDescriptor_t
*
desc_ptr
,
infiniopHandle_t
handle
,
infiniopRoPEDescriptor_t
*
desc_ptr
,
infiniopTensorDescriptor_t
t
,
infiniopTensorDescriptor_t
pos_ids
,
infiniopTensorDescriptor_t
t
,
infiniopTensorDescriptor_t
pos_ids
,
infiniopTensorDescriptor_t
sin_table
,
infiniopTensorDescriptor_t
sin_table
,
...
@@ -49,11 +49,11 @@ __C infiniopStatus_t infiniopCreateRoPEDescriptor(
...
@@ -49,11 +49,11 @@ __C infiniopStatus_t infiniopCreateRoPEDescriptor(
}
}
#endif
#endif
}
}
return
INFINI
OP
_STATUS_DEVICE_TYPE_NOT_SUPPORTED
;
return
INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED
;
}
}
__C
infini
op
Status_t
infiniopGetRoPEWorkspaceSize
(
infiniopRoPEDescriptor_t
desc
,
__C
infiniStatus_t
infiniopGetRoPEWorkspaceSize
(
infiniopRoPEDescriptor_t
desc
,
size_t
*
size
)
{
size_t
*
size
)
{
switch
(
desc
->
device_type
)
{
switch
(
desc
->
device_type
)
{
#ifdef ENABLE_CPU
#ifdef ENABLE_CPU
case
DevCpu
:
case
DevCpu
:
...
@@ -86,14 +86,14 @@ __C infiniopStatus_t infiniopGetRoPEWorkspaceSize(infiniopRoPEDescriptor_t desc,
...
@@ -86,14 +86,14 @@ __C infiniopStatus_t infiniopGetRoPEWorkspaceSize(infiniopRoPEDescriptor_t desc,
}
}
#endif
#endif
}
}
return
INFINI
OP
_STATUS_DEVICE_TYPE_NOT_SUPPORTED
;
return
INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED
;
}
}
__C
infini
op
Status_t
infiniopRoPE
(
infiniopRoPEDescriptor_t
desc
,
__C
infiniStatus_t
infiniopRoPE
(
infiniopRoPEDescriptor_t
desc
,
void
*
workspace
,
size_t
workspace_size
,
void
*
workspace
,
size_t
workspace_size
,
void
*
t
,
const
void
*
pos_ids
,
void
*
t
,
const
void
*
pos_ids
,
const
void
*
sin_table
,
const
void
*
cos_table
,
const
void
*
sin_table
,
const
void
*
cos_table
,
void
*
stream
)
{
void
*
stream
)
{
switch
(
desc
->
device_type
)
{
switch
(
desc
->
device_type
)
{
#ifdef ENABLE_CPU
#ifdef ENABLE_CPU
case
DevCpu
:
case
DevCpu
:
...
@@ -133,10 +133,10 @@ __C infiniopStatus_t infiniopRoPE(infiniopRoPEDescriptor_t desc,
...
@@ -133,10 +133,10 @@ __C infiniopStatus_t infiniopRoPE(infiniopRoPEDescriptor_t desc,
}
}
#endif
#endif
}
}
return
INFINI
OP
_STATUS_DEVICE_TYPE_NOT_SUPPORTED
;
return
INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED
;
}
}
__C
infini
op
Status_t
__C
infiniStatus_t
infiniopDestroyRoPEDescriptor
(
infiniopRoPEDescriptor_t
desc
)
{
infiniopDestroyRoPEDescriptor
(
infiniopRoPEDescriptor_t
desc
)
{
switch
(
desc
->
device_type
)
{
switch
(
desc
->
device_type
)
{
#ifdef ENABLE_CPU
#ifdef ENABLE_CPU
...
@@ -170,5 +170,5 @@ infiniopDestroyRoPEDescriptor(infiniopRoPEDescriptor_t desc) {
...
@@ -170,5 +170,5 @@ infiniopDestroyRoPEDescriptor(infiniopRoPEDescriptor_t desc) {
}
}
#endif
#endif
}
}
return
INFINI
OP
_STATUS_DEVICE_TYPE_NOT_SUPPORTED
;
return
INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED
;
}
}
src/infiniop/ops/swiglu/operator.cc
View file @
80edd992
#include "infiniop/ops/swiglu.h"
#include "infiniop/ops/swiglu.h"
__C
infini
op
Status_t
infiniopCreateSwiGLUDescriptor
(
__C
infiniStatus_t
infiniopCreateSwiGLUDescriptor
(
infiniopHandle_t
handle
,
infiniopSwiGLUDescriptor_t
*
desc_ptr
,
infiniopHandle_t
handle
,
infiniopSwiGLUDescriptor_t
*
desc_ptr
,
infiniopTensorDescriptor_t
c_desc
,
infiniopTensorDescriptor_t
a_desc
,
infiniopTensorDescriptor_t
c_desc
,
infiniopTensorDescriptor_t
a_desc
,
infiniopTensorDescriptor_t
b_desc
)
{
infiniopTensorDescriptor_t
b_desc
)
{
...
@@ -42,12 +42,12 @@ __C infiniopStatus_t infiniopCreateSwiGLUDescriptor(
...
@@ -42,12 +42,12 @@ __C infiniopStatus_t infiniopCreateSwiGLUDescriptor(
handle
,
(
SwiGLUMusaDescriptor_t
*
)
desc_ptr
,
c_desc
,
a_desc
,
b_desc
);
handle
,
(
SwiGLUMusaDescriptor_t
*
)
desc_ptr
,
c_desc
,
a_desc
,
b_desc
);
#endif
#endif
}
}
return
INFINI
OP
_STATUS_DEVICE_TYPE_NOT_SUPPORTED
;
return
INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED
;
};
};
__C
infini
op
Status_t
infiniopSwiGLU
(
infiniopSwiGLUDescriptor_t
desc
,
void
*
c
,
__C
infiniStatus_t
infiniopSwiGLU
(
infiniopSwiGLUDescriptor_t
desc
,
void
*
c
,
const
void
*
a
,
const
void
*
b
,
const
void
*
a
,
const
void
*
b
,
void
*
stream
)
{
void
*
stream
)
{
switch
(
desc
->
device_type
)
{
switch
(
desc
->
device_type
)
{
#ifdef ENABLE_CPU
#ifdef ENABLE_CPU
case
DevCpu
:
case
DevCpu
:
...
@@ -75,10 +75,10 @@ __C infiniopStatus_t infiniopSwiGLU(infiniopSwiGLUDescriptor_t desc, void *c,
...
@@ -75,10 +75,10 @@ __C infiniopStatus_t infiniopSwiGLU(infiniopSwiGLUDescriptor_t desc, void *c,
return
musaSwiGLU
((
SwiGLUMusaDescriptor_t
)
desc
,
c
,
a
,
b
,
stream
);
return
musaSwiGLU
((
SwiGLUMusaDescriptor_t
)
desc
,
c
,
a
,
b
,
stream
);
#endif
#endif
}
}
return
INFINI
OP
_STATUS_DEVICE_TYPE_NOT_SUPPORTED
;
return
INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED
;
}
}
__C
infini
op
Status_t
__C
infiniStatus_t
infiniopDestroySwiGLUDescriptor
(
infiniopSwiGLUDescriptor_t
desc
)
{
infiniopDestroySwiGLUDescriptor
(
infiniopSwiGLUDescriptor_t
desc
)
{
switch
(
desc
->
device_type
)
{
switch
(
desc
->
device_type
)
{
#ifdef ENABLE_CPU
#ifdef ENABLE_CPU
...
@@ -107,5 +107,5 @@ infiniopDestroySwiGLUDescriptor(infiniopSwiGLUDescriptor_t desc) {
...
@@ -107,5 +107,5 @@ infiniopDestroySwiGLUDescriptor(infiniopSwiGLUDescriptor_t desc) {
return
musaDestroySwiGLUDescriptor
((
SwiGLUMusaDescriptor_t
)
desc
);
return
musaDestroySwiGLUDescriptor
((
SwiGLUMusaDescriptor_t
)
desc
);
#endif
#endif
}
}
return
INFINI
OP
_STATUS_DEVICE_TYPE_NOT_SUPPORTED
;
return
INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED
;
}
}
src/infiniop/tensor_descriptor.cc
View file @
80edd992
#include "infiniop/tensor_descriptor.h"
#include "infiniop/tensor_descriptor.h"
#include <cstring>
#include <cstring>
__C
__export
infini
op
Status_t
infiniopCreateTensorDescriptor
(
infiniopTensorDescriptor_t
*
desc_ptr
,
size_t
ndim
,
size_t
const
*
shape_
,
ptrdiff_t
const
*
strides_
,
infiniDtype_t
datatype
)
{
__C
__export
infiniStatus_t
infiniopCreateTensorDescriptor
(
infiniopTensorDescriptor_t
*
desc_ptr
,
size_t
ndim
,
size_t
const
*
shape_
,
ptrdiff_t
const
*
strides_
,
infiniDtype_t
datatype
)
{
size_t
*
shape
=
new
size_t
[
ndim
];
size_t
*
shape
=
new
size_t
[
ndim
];
ptrdiff_t
*
strides
=
new
ptrdiff_t
[
ndim
];
ptrdiff_t
*
strides
=
new
ptrdiff_t
[
ndim
];
std
::
memcpy
(
shape
,
shape_
,
ndim
*
sizeof
(
size_t
));
std
::
memcpy
(
shape
,
shape_
,
ndim
*
sizeof
(
size_t
));
...
@@ -15,12 +15,12 @@ __C __export infiniopStatus_t infiniopCreateTensorDescriptor(infiniopTensorDescr
...
@@ -15,12 +15,12 @@ __C __export infiniopStatus_t infiniopCreateTensorDescriptor(infiniopTensorDescr
}
}
}
}
*
desc_ptr
=
new
InfiniopTensorDescriptor
{
datatype
,
ndim
,
shape
,
strides
};
*
desc_ptr
=
new
InfiniopTensorDescriptor
{
datatype
,
ndim
,
shape
,
strides
};
return
INFINI
OP
_STATUS_SUCCESS
;
return
INFINI_STATUS_SUCCESS
;
}
}
__C
__export
infini
op
Status_t
infiniopDestroyTensorDescriptor
(
infiniopTensorDescriptor_t
desc
)
{
__C
__export
infiniStatus_t
infiniopDestroyTensorDescriptor
(
infiniopTensorDescriptor_t
desc
)
{
delete
[]
desc
->
shape
;
delete
[]
desc
->
shape
;
delete
[]
desc
->
strides
;
delete
[]
desc
->
strides
;
delete
desc
;
delete
desc
;
return
INFINI
OP
_STATUS_SUCCESS
;
return
INFINI_STATUS_SUCCESS
;
}
}
Prev
1
2
3
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