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
20 changed files
with
103 additions
and
122 deletions
+103
-122
include/infiniop/status.h
include/infiniop/status.h
+0
-18
include/infiniop/tensor_descriptor.h
include/infiniop/tensor_descriptor.h
+2
-3
src/infiniop/devices/ascend/ascend_handle.cc
src/infiniop/devices/ascend/ascend_handle.cc
+5
-5
src/infiniop/devices/ascend/ascend_handle.h
src/infiniop/devices/ascend/ascend_handle.h
+2
-2
src/infiniop/devices/ascend/common_ascend.cc
src/infiniop/devices/ascend/common_ascend.cc
+6
-6
src/infiniop/devices/ascend/common_ascend.h
src/infiniop/devices/ascend/common_ascend.h
+6
-6
src/infiniop/devices/ascend/tensor_aclnn.cc
src/infiniop/devices/ascend/tensor_aclnn.cc
+13
-13
src/infiniop/devices/ascend/tensor_aclnn.h
src/infiniop/devices/ascend/tensor_aclnn.h
+5
-5
src/infiniop/devices/bang/bang_handle.cc
src/infiniop/devices/bang/bang_handle.cc
+5
-5
src/infiniop/devices/bang/bang_handle.h
src/infiniop/devices/bang/bang_handle.h
+2
-2
src/infiniop/devices/cpu/cpu_handle.cc
src/infiniop/devices/cpu/cpu_handle.cc
+4
-4
src/infiniop/devices/cpu/cpu_handle.h
src/infiniop/devices/cpu/cpu_handle.h
+2
-2
src/infiniop/devices/cuda/common_cuda.cuh
src/infiniop/devices/cuda/common_cuda.cuh
+2
-2
src/infiniop/devices/cuda/cuda_handle.cu
src/infiniop/devices/cuda/cuda_handle.cu
+5
-5
src/infiniop/devices/cuda/cuda_handle.h
src/infiniop/devices/cuda/cuda_handle.h
+2
-2
src/infiniop/devices/handle.cc
src/infiniop/devices/handle.cc
+6
-6
src/infiniop/operator.cc
src/infiniop/operator.cc
+4
-4
src/infiniop/ops/causal_softmax/operator.cc
src/infiniop/ops/causal_softmax/operator.cc
+8
-8
src/infiniop/ops/matmul/ascend/matmul_ascend.cc
src/infiniop/ops/matmul/ascend/matmul_ascend.cc
+17
-17
src/infiniop/ops/matmul/bang/matmul_bang.cc
src/infiniop/ops/matmul/bang/matmul_bang.cc
+7
-7
No files found.
include/infiniop/status.h
deleted
100644 → 0
View file @
e77735ef
#ifndef __INFINIOP_STATUS__
#define __INFINIOP_STATUS__
typedef
enum
{
INFINIOP_STATUS_SUCCESS
=
0
,
INFINIOP_STATUS_INTERNAL_ERROR
=
1
,
INFINIOP_STATUS_BAD_PARAM
=
2
,
INFINIOP_STATUS_BAD_TENSOR_DTYPE
=
3
,
INFINIOP_STATUS_BAD_TENSOR_SHAPE
=
4
,
INFINIOP_STATUS_BAD_TENSOR_STRIDES
=
5
,
INFINIOP_STATUS_NULL_POINTER
=
6
,
INFINIOP_STATUS_INSUFFICIENT_WORKSPACE
=
7
,
INFINIOP_STATUS_DEVICE_TYPE_NOT_SUPPORTED
=
8
,
INFINIOP_STATUS_BAD_DEVICE
=
9
,
INFINIOP_STATUS_UNDEFINED_BEHAVIOR
=
10
,
}
infiniopStatus_t
;
#endif
include/infiniop/tensor_descriptor.h
View file @
80edd992
...
...
@@ -2,7 +2,6 @@
#define __INFINIOP_TENSOR_DESCRIPTOR__
#include "../infinicore.h"
#include "status.h"
struct
InfiniopTensorDescriptor
{
// Datatype
...
...
@@ -17,8 +16,8 @@ struct InfiniopTensorDescriptor {
typedef
struct
InfiniopTensorDescriptor
*
infiniopTensorDescriptor_t
;
__C
__export
infini
op
Status_t
infiniopCreateTensorDescriptor
(
infiniopTensorDescriptor_t
*
desc_ptr
,
size_t
ndim
,
const
size_t
*
shape
,
const
ptrdiff_t
*
strides
,
infiniDtype_t
dtype
);
__C
__export
infiniStatus_t
infiniopCreateTensorDescriptor
(
infiniopTensorDescriptor_t
*
desc_ptr
,
size_t
ndim
,
const
size_t
*
shape
,
const
ptrdiff_t
*
strides
,
infiniDtype_t
dtype
);
__C
__export
infini
op
Status_t
infiniopDestroyTensorDescriptor
(
infiniopTensorDescriptor_t
desc
);
__C
__export
infiniStatus_t
infiniopDestroyTensorDescriptor
(
infiniopTensorDescriptor_t
desc
);
#endif // __INFINIOP_TENSOR_DESCRIPTOR__
src/infiniop/devices/ascend/ascend_handle.cc
View file @
80edd992
#include "common_ascend.h"
infini
op
Status_t
createAscendHandle
(
infiniopAscendHandle_t
*
handle_ptr
)
{
infiniStatus_t
createAscendHandle
(
infiniopAscendHandle_t
*
handle_ptr
)
{
int
device_id
=
0
;
auto
ret
=
aclrtGetDevice
(
&
device_id
);
CHECK_RET
(
ret
==
ACL_SUCCESS
,
LOG_ERROR
(
"aclrtGetDevice failed. ERROR: %d
\n
"
,
ret
)
);
return
INFINI_STATUS_DEVICE_NOT_INITIALIZED
);
*
handle_ptr
=
new
InfiniopAscendHandle
{
INFINI_DEVICE_ASCEND
,
device_id
};
return
INFINI
OP
_STATUS_SUCCESS
;
return
INFINI_STATUS_SUCCESS
;
}
infini
op
Status_t
destroyAscendHandle
(
infiniopAscendHandle_t
handle_ptr
)
{
infiniStatus_t
destroyAscendHandle
(
infiniopAscendHandle_t
handle_ptr
)
{
delete
handle_ptr
;
return
INFINI
OP
_STATUS_SUCCESS
;
return
INFINI_STATUS_SUCCESS
;
}
src/infiniop/devices/ascend/ascend_handle.h
View file @
80edd992
...
...
@@ -7,8 +7,8 @@
struct
InfiniopAscendHandle
;
typedef
struct
InfiniopAscendHandle
*
infiniopAscendHandle_t
;
infini
op
Status_t
createAscendHandle
(
infiniopAscendHandle_t
*
handle_ptr
);
infiniStatus_t
createAscendHandle
(
infiniopAscendHandle_t
*
handle_ptr
);
infini
op
Status_t
destroyAscendHandle
(
infiniopAscendHandle_t
handle_ptr
);
infiniStatus_t
destroyAscendHandle
(
infiniopAscendHandle_t
handle_ptr
);
#endif
src/infiniop/devices/ascend/common_ascend.cc
View file @
80edd992
...
...
@@ -8,26 +8,26 @@ int64_t numElements(const int64_t *shape, int64_t num) {
return
numEle
;
}
infini
op
Status_t
mallocWorkspace
(
void
**
workspaceAddr
,
size_t
workspaceSize
)
{
infiniStatus_t
mallocWorkspace
(
void
**
workspaceAddr
,
size_t
workspaceSize
)
{
*
workspaceAddr
=
nullptr
;
if
(
workspaceSize
>
0
)
{
auto
ret
=
aclrtMalloc
(
workspaceAddr
,
workspaceSize
,
ACL_MEM_MALLOC_HUGE_FIRST
);
CHECK_RET
(
ret
==
ACL_SUCCESS
,
LOG_PRINT
(
"aclrtMalloc failed. ERROR: %d
\n
"
,
ret
);
return
INFINI
OP
_STATUS_INTERNAL_ERROR
);
return
INFINI_STATUS_INTERNAL_ERROR
);
}
return
INFINI
OP
_STATUS_SUCCESS
;
return
INFINI_STATUS_SUCCESS
;
}
infini
op
Status_t
freeWorkspace
(
void
*
workspaceAddr
)
{
infiniStatus_t
freeWorkspace
(
void
*
workspaceAddr
)
{
if
(
workspaceAddr
!=
nullptr
)
{
auto
ret
=
aclrtFree
(
workspaceAddr
);
CHECK_RET
(
ret
==
ACL_SUCCESS
,
LOG_PRINT
(
"aclrtFree failed, ERROR: %d
\n
"
,
ret
);
return
INFINI
OP
_STATUS_INTERNAL_ERROR
);
return
INFINI_STATUS_INTERNAL_ERROR
);
}
return
INFINI
OP
_STATUS_SUCCESS
;
return
INFINI_STATUS_SUCCESS
;
}
aclDataType
toAclDataType
(
infiniDtype_t
dt
)
{
...
...
src/infiniop/devices/ascend/common_ascend.h
View file @
80edd992
...
...
@@ -28,10 +28,10 @@ extern "C" {
printf(message, ##__VA_ARGS__); \
} while (0)
#define LOG_ERROR(message, ...)
\
do {
\
printf(message, ##__VA_ARGS__);
\
return INFINI
OP
_STATUS_INTERNAL_ERROR; \
#define LOG_ERROR(message, ...) \
do { \
printf(message, ##__VA_ARGS__); \
return INFINI_STATUS_INTERNAL_ERROR; \
} while (0)
#ifdef __cplusplus
...
...
@@ -46,8 +46,8 @@ struct InfiniopAscendHandle {
int64_t
numElements
(
const
int64_t
*
shape
,
int64_t
num
);
const
char
*
dataTypeToString
(
aclDataType
dtype
);
const
char
*
formatToString
(
aclFormat
format
);
infini
op
Status_t
mallocWorkspace
(
void
**
workspaceAddr
,
size_t
workspaceSize
);
infini
op
Status_t
freeWorkspace
(
void
*
workspaceAddr
);
infiniStatus_t
mallocWorkspace
(
void
**
workspaceAddr
,
size_t
workspaceSize
);
infiniStatus_t
freeWorkspace
(
void
*
workspaceAddr
);
aclDataType
toAclDataType
(
infiniDtype_t
dt
);
#endif
src/infiniop/devices/ascend/tensor_aclnn.cc
View file @
80edd992
...
...
@@ -2,9 +2,9 @@
#include "../../ops/utils.h"
#include <algorithm>
infini
op
Status_t
aclnnTensorDescriptor
::
setDescriptor
(
aclDataType
dtype
,
const
std
::
vector
<
int64_t
>
&
shape
,
const
std
::
vector
<
int64_t
>
&
strides
)
{
infiniStatus_t
aclnnTensorDescriptor
::
setDescriptor
(
aclDataType
dtype
,
const
std
::
vector
<
int64_t
>
&
shape
,
const
std
::
vector
<
int64_t
>
&
strides
)
{
if
(
shape
.
size
()
!=
strides
.
size
())
{
return
INFINI
OP
_STATUS_BAD_TENSOR_STRIDES
;
return
INFINI_STATUS_BAD_TENSOR_STRIDES
;
}
this
->
ndim
=
shape
.
size
();
this
->
shape
=
std
::
vector
<
int64_t
>
(
shape
);
...
...
@@ -16,26 +16,26 @@ infiniopStatus_t aclnnTensorDescriptor::setDescriptor(aclDataType dtype, const s
aclFormat
format
=
aclFormat
::
ACL_FORMAT_ND
;
this
->
format
=
format
;
CHECK_STATUS
(
this
->
inferStorageShape
(),
INFINI
OP
_STATUS_SUCCESS
);
CHECK_STATUS
(
this
->
inferStorageShape
(),
INFINI_STATUS_SUCCESS
);
return
INFINI
OP
_STATUS_SUCCESS
;
return
INFINI_STATUS_SUCCESS
;
}
/// @brief Infer storage shape. For now this ruturns a 1D shape of the total tensor storage size.
/// We don't see why higher dimensional storage shape is ever needed. To change if necesary.
infini
op
Status_t
aclnnTensorDescriptor
::
inferStorageShape
()
{
infiniStatus_t
aclnnTensorDescriptor
::
inferStorageShape
()
{
auto
index
=
std
::
max_element
(
this
->
strides
.
begin
(),
this
->
strides
.
end
());
uint64_t
max_stride_index
=
std
::
distance
(
this
->
strides
.
begin
(),
index
);
this
->
storageNdim
=
1
;
this
->
storageShape
=
std
::
vector
<
int64_t
>
({
this
->
shape
[
max_stride_index
]
*
this
->
strides
[
max_stride_index
]});
return
INFINI
OP
_STATUS_SUCCESS
;
return
INFINI_STATUS_SUCCESS
;
}
/// @brief Set aclnnTensorDescriptor from infiniopTensorDescriptor
/// @param y infiniopTensorDescriptor
/// @return infiniopStatus_t
infini
op
Status_t
aclnnTensorDescriptor
::
fromInfiniOpTensorDescriptor
(
infiniopTensorDescriptor_t
y
)
{
infiniStatus_t
aclnnTensorDescriptor
::
fromInfiniOpTensorDescriptor
(
infiniopTensorDescriptor_t
y
)
{
uint64_t
ndim
=
y
->
ndim
;
// Cast shape type
auto
shape
=
std
::
vector
<
int64_t
>
(
ndim
);
...
...
@@ -53,9 +53,9 @@ infiniopStatus_t aclnnTensorDescriptor::fromInfiniOpTensorDescriptor(infiniopTen
/// @param data Data ptr on device global mem.
/// @param tensor Pointer of pointer of aclTensor.
/// @return
infini
op
Status_t
aclnnTensorDescriptor
::
createTensor
(
void
*
data
)
{
infiniStatus_t
aclnnTensorDescriptor
::
createTensor
(
void
*
data
)
{
if
(
this
->
t
)
{
return
INFINI
OP
_STATUS_SUCCESS
;
return
INFINI_STATUS_SUCCESS
;
}
this
->
t
=
aclCreateTensor
(
this
->
shape
.
data
(),
this
->
ndim
,
...
...
@@ -66,17 +66,17 @@ infiniopStatus_t aclnnTensorDescriptor::createTensor(void *data) {
this
->
storageShape
.
data
(),
this
->
storageNdim
,
data
);
return
INFINI
OP
_STATUS_SUCCESS
;
return
INFINI_STATUS_SUCCESS
;
}
infini
op
Status_t
aclnnTensorDescriptor
::
destroyTensor
()
{
infiniStatus_t
aclnnTensorDescriptor
::
destroyTensor
()
{
auto
ret
=
aclDestroyTensor
(
this
->
t
);
CHECK_RET
(
ret
==
ACL_SUCCESS
,
LOG_PRINT
(
"aclDesctroyTensor failed, ERROR: %d
\n
"
,
ret
);
return
INFINI
OP
_STATUS_INTERNAL_ERROR
);
return
INFINI_STATUS_INTERNAL_ERROR
);
t
=
nullptr
;
return
INFINI
OP
_STATUS_SUCCESS
;
return
INFINI_STATUS_SUCCESS
;
}
aclnnTensorDescriptor
::~
aclnnTensorDescriptor
()
{
...
...
src/infiniop/devices/ascend/tensor_aclnn.h
View file @
80edd992
...
...
@@ -23,12 +23,12 @@ struct aclnnTensorDescriptor {
aclTensor
*
t
;
// Transfer from infiniOp DT to aclDataType
infini
op
Status_t
setDescriptor
(
aclDataType
dtype
,
const
std
::
vector
<
int64_t
>
&
shape
,
const
std
::
vector
<
int64_t
>
&
strides
);
infini
op
Status_t
inferStorageShape
();
infiniStatus_t
setDescriptor
(
aclDataType
dtype
,
const
std
::
vector
<
int64_t
>
&
shape
,
const
std
::
vector
<
int64_t
>
&
strides
);
infiniStatus_t
inferStorageShape
();
// Convert form InfiniOpTensorDescriptor
infini
op
Status_t
fromInfiniOpTensorDescriptor
(
infiniopTensorDescriptor_t
y_desc
);
infini
op
Status_t
createTensor
(
void
*
data
=
nullptr
);
infini
op
Status_t
destroyTensor
();
infiniStatus_t
fromInfiniOpTensorDescriptor
(
infiniopTensorDescriptor_t
y_desc
);
infiniStatus_t
createTensor
(
void
*
data
=
nullptr
);
infiniStatus_t
destroyTensor
();
~
aclnnTensorDescriptor
();
char
*
toString
();
...
...
src/infiniop/devices/bang/bang_handle.cc
View file @
80edd992
...
...
@@ -2,10 +2,10 @@
#include "common_bang.h"
#include <memory>
infini
op
Status_t
createBangHandle
(
infiniopBangHandle_t
*
handle_ptr
)
{
infiniStatus_t
createBangHandle
(
infiniopBangHandle_t
*
handle_ptr
)
{
int
device_id
=
0
;
if
(
cnrtGetDevice
(
&
device_id
)
!=
cnrtSuccess
)
{
return
INFINI
OP
_STATUS_
BAD_
DEVICE
;
return
INFINI_STATUS_DEVICE
_NOT_INITIALIZED
;
}
auto
pool
=
std
::
make_shared
<
Pool
<
cnnlHandle_t
>>
();
...
...
@@ -16,10 +16,10 @@ infiniopStatus_t createBangHandle(infiniopBangHandle_t *handle_ptr) {
*
handle_ptr
=
new
InfiniopBangHandle
{
INFINI_DEVICE_CAMBRICON
,
device_id
,
std
::
move
(
pool
)};
return
INFINI
OP
_STATUS_SUCCESS
;
return
INFINI_STATUS_SUCCESS
;
}
infini
op
Status_t
destroyBangHandle
(
infiniopBangHandle_t
handle
)
{
infiniStatus_t
destroyBangHandle
(
infiniopBangHandle_t
handle
)
{
delete
handle
;
return
INFINI
OP
_STATUS_SUCCESS
;
return
INFINI_STATUS_SUCCESS
;
}
src/infiniop/devices/bang/bang_handle.h
View file @
80edd992
...
...
@@ -6,7 +6,7 @@
struct
InfiniopBangHandle
;
typedef
struct
InfiniopBangHandle
*
infiniopBangHandle_t
;
infini
op
Status_t
createBangHandle
(
infiniopBangHandle_t
*
handle_ptr
);
infini
op
Status_t
destroyBangHandle
(
infiniopBangHandle_t
handle
);
infiniStatus_t
createBangHandle
(
infiniopBangHandle_t
*
handle_ptr
);
infiniStatus_t
destroyBangHandle
(
infiniopBangHandle_t
handle
);
#endif
src/infiniop/devices/cpu/cpu_handle.cc
View file @
80edd992
#include "cpu_handle.h"
infini
op
Status_t
createCpuHandle
(
infiniopCpuHandle_t
*
handle_ptr
)
{
infiniStatus_t
createCpuHandle
(
infiniopCpuHandle_t
*
handle_ptr
)
{
*
handle_ptr
=
new
InfiniopHandle
{
INFINI_DEVICE_CPU
,
0
};
return
INFINI
OP
_STATUS_SUCCESS
;
return
INFINI_STATUS_SUCCESS
;
}
infini
op
Status_t
destroyCpuHandle
(
infiniopCpuHandle_t
handle
)
{
infiniStatus_t
destroyCpuHandle
(
infiniopCpuHandle_t
handle
)
{
delete
handle
;
return
INFINI
OP
_STATUS_SUCCESS
;
return
INFINI_STATUS_SUCCESS
;
}
src/infiniop/devices/cpu/cpu_handle.h
View file @
80edd992
...
...
@@ -5,8 +5,8 @@
typedef
infiniopHandle_t
infiniopCpuHandle_t
;
infini
op
Status_t
createCpuHandle
(
infiniopCpuHandle_t
*
handle_ptr
);
infiniStatus_t
createCpuHandle
(
infiniopCpuHandle_t
*
handle_ptr
);
infini
op
Status_t
destroyCpuHandle
(
infiniopCpuHandle_t
handle
);
infiniStatus_t
destroyCpuHandle
(
infiniopCpuHandle_t
handle
);
#endif
src/infiniop/devices/cuda/common_cuda.cuh
View file @
80edd992
...
...
@@ -17,7 +17,7 @@
} \
} while (0)
#define CHECK_CUDA(call) CHECK_CUDA_OR_RETURN(call, INFINI
OP
_STATUS_INTERNAL_ERROR)
#define CHECK_CUDA(call) CHECK_CUDA_OR_RETURN(call, INFINI_STATUS_INTERNAL_ERROR)
#define CHECK_CUDNN(call) \
do { \
...
...
@@ -25,7 +25,7 @@
std::cerr << "CUDNN error: " << cudnnGetErrorString(status) \
<< " in file " << __FILE__ << ", function " << __func__ \
<< ", line " << __LINE__ << std::endl; \
return INFINI
OP
_STATUS_INTERNAL_ERROR; \
return INFINI_STATUS_INTERNAL_ERROR;
\
} \
} while (0)
...
...
src/infiniop/devices/cuda/cuda_handle.cu
View file @
80edd992
#include "common_cuda.cuh"
infini
op
Status_t
createCudaHandle
(
infiniopCudaHandle_t
*
handle_ptr
,
infiniDevice_t
cuda_device_type
)
{
infiniStatus_t
createCudaHandle
(
infiniopCudaHandle_t
*
handle_ptr
,
infiniDevice_t
cuda_device_type
)
{
// Create a new cublas handle pool
int
device_id
=
0
;
CHECK_CUDA
(
cudaGetDevice
(
&
device_id
));
CHECK_CUDA
_OR_RETURN
(
cudaGetDevice
(
&
device_id
)
,
INFINI_STATUS_DEVICE_NOT_INITIALIZED
);
auto
pool
=
std
::
make_shared
<
Pool
<
cublasHandle_t
>>
();
cublasHandle_t
handle
;
cublasCreate
(
&
handle
);
...
...
@@ -35,13 +35,13 @@ infiniopStatus_t createCudaHandle(infiniopCudaHandle_t *handle_ptr, infiniDevice
capability_minor
,
};
return
INFINI
OP
_STATUS_SUCCESS
;
return
INFINI_STATUS_SUCCESS
;
}
infini
op
Status_t
destroyCudaHandle
(
infiniopCudaHandle_t
handle_ptr
)
{
infiniStatus_t
destroyCudaHandle
(
infiniopCudaHandle_t
handle_ptr
)
{
handle_ptr
->
cublas_handle_pool
=
nullptr
;
handle_ptr
->
cudnn_handle_pool
=
nullptr
;
delete
handle_ptr
;
return
INFINI
OP
_STATUS_SUCCESS
;
return
INFINI_STATUS_SUCCESS
;
}
src/infiniop/devices/cuda/cuda_handle.h
View file @
80edd992
...
...
@@ -6,8 +6,8 @@
struct
InfiniopCudaHandle
;
typedef
struct
InfiniopCudaHandle
*
infiniopCudaHandle_t
;
infini
op
Status_t
createCudaHandle
(
infiniopCudaHandle_t
*
handle_ptr
,
infiniDevice_t
cuda_device_type
);
infiniStatus_t
createCudaHandle
(
infiniopCudaHandle_t
*
handle_ptr
,
infiniDevice_t
cuda_device_type
);
infini
op
Status_t
destroyCudaHandle
(
infiniopCudaHandle_t
handle_ptr
);
infiniStatus_t
destroyCudaHandle
(
infiniopCudaHandle_t
handle_ptr
);
#endif
src/infiniop/devices/handle.cc
View file @
80edd992
...
...
@@ -12,10 +12,10 @@
#include "ascend/ascend_handle.h"
#endif
__C
infini
op
Status_t
infiniopCreateHandle
(
infiniopHandle_t
*
handle_ptr
,
infiniDevice_t
device
)
{
__C
infiniStatus_t
infiniopCreateHandle
(
infiniopHandle_t
*
handle_ptr
,
infiniDevice_t
device
)
{
if
(
handle_ptr
==
nullptr
)
{
return
INFINI
OP
_STATUS_NULL_POINTER
;
return
INFINI_STATUS_NULL_POINTER
;
}
switch
(
device
)
{
...
...
@@ -39,10 +39,10 @@ __C infiniopStatus_t infiniopCreateHandle(infiniopHandle_t *handle_ptr,
}
#endif
}
return
INFINI
OP
_STATUS_DEVICE_TYPE_NOT_SUPPORTED
;
return
INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED
;
}
__C
infini
op
Status_t
infiniopDestroyHandle
(
infiniopHandle_t
handle
)
{
__C
infiniStatus_t
infiniopDestroyHandle
(
infiniopHandle_t
handle
)
{
switch
(
handle
->
device
)
{
#ifdef ENABLE_CPU_API
case
INFINI_DEVICE_CPU
:
...
...
@@ -64,5 +64,5 @@ __C infiniopStatus_t infiniopDestroyHandle(infiniopHandle_t handle) {
}
#endif
}
return
INFINI
OP
_STATUS_DEVICE_TYPE_NOT_SUPPORTED
;
return
INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED
;
}
src/infiniop/operator.cc
View file @
80edd992
#include "infiniop/operator.h"
infini
op
Status_t
infiniopGetDescriptorDeviceType
(
infiniStatus_t
infiniopGetDescriptorDeviceType
(
const
InfiniopDescriptor
*
desc_ptr
,
infiniDevice_t
*
device_type
)
{
*
device_type
=
desc_ptr
->
device_type
;
return
INFINI
OP
_STATUS_SUCCESS
;
return
INFINI_STATUS_SUCCESS
;
}
infini
op
Status_t
infiniopGetDescriptorDeviceId
(
infiniStatus_t
infiniopGetDescriptorDeviceId
(
const
InfiniopDescriptor
*
desc_ptr
,
int
*
device_id
)
{
*
device_id
=
desc_ptr
->
device_id
;
return
INFINI
OP
_STATUS_SUCCESS
;
return
INFINI_STATUS_SUCCESS
;
}
src/infiniop/ops/causal_softmax/operator.cc
View file @
80edd992
#include "infiniop/ops/causal_softmax.h"
__C
infini
op
Status_t
infiniopCreateCausalSoftmaxDescriptor
(
__C
infiniStatus_t
infiniopCreateCausalSoftmaxDescriptor
(
infiniopHandle_t
handle
,
infiniopCausalSoftmaxDescriptor_t
*
desc_ptr
,
infiniopTensorDescriptor_t
y_desc
)
{
...
...
@@ -37,10 +37,10 @@ __C infiniopStatus_t infiniopCreateCausalSoftmaxDescriptor(
}
#endif
}
return
INFINI
OP
_STATUS_DEVICE_TYPE_NOT_SUPPORTED
;
return
INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED
;
}
__C
infini
op
Status_t
infiniopGetCausalSoftmaxWorkspaceSize
(
infiniopCausalSoftmaxDescriptor_t
desc
,
size_t
*
size
)
{
__C
infiniStatus_t
infiniopGetCausalSoftmaxWorkspaceSize
(
infiniopCausalSoftmaxDescriptor_t
desc
,
size_t
*
size
)
{
switch
(
desc
->
device_type
)
{
#ifdef ENABLE_CPU
case
DevCpu
:
...
...
@@ -75,10 +75,10 @@ __C infiniopStatus_t infiniopGetCausalSoftmaxWorkspaceSize(infiniopCausalSoftmax
}
#endif
}
return
INFINI
OP
_STATUS_DEVICE_TYPE_NOT_SUPPORTED
;
return
INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED
;
}
__C
infini
op
Status_t
infiniopCausalSoftmax
(
infiniopCausalSoftmaxDescriptor_t
desc
,
void
*
workspace
,
size_t
workspace_size
,
void
*
data
,
void
*
stream
)
{
__C
infiniStatus_t
infiniopCausalSoftmax
(
infiniopCausalSoftmaxDescriptor_t
desc
,
void
*
workspace
,
size_t
workspace_size
,
void
*
data
,
void
*
stream
)
{
switch
(
desc
->
device_type
)
{
#ifdef ENABLE_CPU
case
DevCpu
:
...
...
@@ -112,10 +112,10 @@ __C infiniopStatus_t infiniopCausalSoftmax(infiniopCausalSoftmaxDescriptor_t des
}
#endif
}
return
INFINI
OP
_STATUS_DEVICE_TYPE_NOT_SUPPORTED
;
return
INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED
;
}
__C
infini
op
Status_t
infiniopDestroyCausalSoftmaxDescriptor
(
infiniopCausalSoftmaxDescriptor_t
desc
)
{
__C
infiniStatus_t
infiniopDestroyCausalSoftmaxDescriptor
(
infiniopCausalSoftmaxDescriptor_t
desc
)
{
switch
(
desc
->
device_type
)
{
#ifdef ENABLE_CPU
case
DevCpu
:
...
...
@@ -148,5 +148,5 @@ __C infiniopStatus_t infiniopDestroyCausalSoftmaxDescriptor(infiniopCausalSoftma
return
musaDestroyCausalSoftmaxDescriptor
((
CausalSoftmaxMusaDescriptor_t
)
desc
);
#endif
}
return
INFINI
OP
_STATUS_DEVICE_TYPE_NOT_SUPPORTED
;
return
INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED
;
}
src/infiniop/ops/matmul/ascend/matmul_ascend.cc
View file @
80edd992
...
...
@@ -29,7 +29,7 @@ Descriptor::~Descriptor() {
delete
_opaque
;
}
infini
op
Status_t
Descriptor
::
create
(
infiniStatus_t
Descriptor
::
create
(
infiniopHandle_t
handle_
,
Descriptor
**
desc_ptr
,
infiniopTensorDescriptor_t
c_desc
,
...
...
@@ -39,12 +39,12 @@ infiniopStatus_t Descriptor::create(
auto
dtype
=
c_desc
->
dtype
;
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
::
ROW_MAJOR
);
if
(
status
!=
INFINI
OP
_STATUS_SUCCESS
)
{
if
(
status
!=
INFINI_STATUS_SUCCESS
)
{
return
status
;
}
...
...
@@ -59,23 +59,23 @@ infiniopStatus_t Descriptor::create(
{
static_cast
<
int64_t
>
(
info
.
c_matrix
.
rows
),
static_cast
<
int64_t
>
(
info
.
c_matrix
.
cols
)},
{
info
.
c_matrix
.
row_stride
,
info
.
c_matrix
.
col_stride
}),
INFINI
OP
_STATUS_SUCCESS
);
INFINI_STATUS_SUCCESS
);
CHECK_STATUS
(
a
->
setDescriptor
(
toAclDataType
(
a_desc
->
dtype
),
{
static_cast
<
int64_t
>
(
info
.
a_matrix
.
rows
),
static_cast
<
int64_t
>
(
info
.
a_matrix
.
cols
)},
{
info
.
a_matrix
.
row_stride
,
info
.
a_matrix
.
col_stride
}),
INFINI
OP
_STATUS_SUCCESS
);
INFINI_STATUS_SUCCESS
);
CHECK_STATUS
(
b
->
setDescriptor
(
toAclDataType
(
b_desc
->
dtype
),
{
static_cast
<
int64_t
>
(
info
.
b_matrix
.
rows
),
static_cast
<
int64_t
>
(
info
.
b_matrix
.
cols
)},
{
info
.
b_matrix
.
row_stride
,
info
.
b_matrix
.
col_stride
}),
INFINI
OP
_STATUS_SUCCESS
);
INFINI_STATUS_SUCCESS
);
CHECK_STATUS
(
c
->
createTensor
(),
INFINI
OP
_STATUS_SUCCESS
);
CHECK_STATUS
(
a
->
createTensor
(),
INFINI
OP
_STATUS_SUCCESS
);
CHECK_STATUS
(
b
->
createTensor
(),
INFINI
OP
_STATUS_SUCCESS
);
CHECK_STATUS
(
c
->
createTensor
(),
INFINI_STATUS_SUCCESS
);
CHECK_STATUS
(
a
->
createTensor
(),
INFINI_STATUS_SUCCESS
);
CHECK_STATUS
(
b
->
createTensor
(),
INFINI_STATUS_SUCCESS
);
auto
tc
=
c
->
t
,
ta
=
a
->
t
,
...
...
@@ -91,7 +91,7 @@ infiniopStatus_t Descriptor::create(
auto
ret
=
aclnnGemmGetWorkspaceSize
(
ta
,
tb
,
tc
,
.5
,
.5
,
0
,
0
,
tc
,
mt
,
&
workspace_size
,
&
executor
);
CHECK_RET
(
ret
==
ACL_SUCCESS
,
LOG_PRINT
(
"aclnnGemmGetWorkspaceSize failed. ERROR: %d
\n
"
,
ret
);
return
INFINI
OP
_STATUS_INTERNAL_ERROR
);
return
INFINI_STATUS_INTERNAL_ERROR
);
aclSetAclOpExecutorRepeatable
(
executor
);
*
desc_ptr
=
new
Descriptor
(
...
...
@@ -104,10 +104,10 @@ infiniopStatus_t Descriptor::create(
mt
,
},
handle
->
device
,
handle
->
device_id
);
return
INFINI
OP
_STATUS_SUCCESS
;
return
INFINI_STATUS_SUCCESS
;
}
infini
op
Status_t
Descriptor
::
calculate
(
infiniStatus_t
Descriptor
::
calculate
(
void
*
workspace
,
size_t
workspaceSize_
,
void
*
c
,
...
...
@@ -127,9 +127,9 @@ infiniopStatus_t Descriptor::calculate(
&
workspace_size
,
&
(
_opaque
->
executor
));
CHECK_RET
(
ret
==
ACL_SUCCESS
,
LOG_PRINT
(
"aclnnGemmGetWorkspaceSize failed. ERROR: %d
\n
"
,
ret
);
return
INFINI
OP
_STATUS_INTERNAL_ERROR
);
return
INFINI_STATUS_INTERNAL_ERROR
);
if
(
workspaceSize_
<
workspace_size
)
{
return
INFINI
OP
_STATUS_INSUFFICIENT_WORKSPACE
;
return
INFINI_STATUS_INSUFFICIENT_WORKSPACE
;
}
aclSetAclOpExecutorRepeatable
(
_opaque
->
executor
);
...
...
@@ -142,10 +142,10 @@ infiniopStatus_t Descriptor::calculate(
ret
=
aclnnGemm
(
workspace
,
workspace_size
,
_opaque
->
executor
,
stream
);
CHECK_RET
(
ret
==
ACL_SUCCESS
,
LOG_PRINT
(
"aclnnGemm failed. ERROR: %d
\n
"
,
ret
);
return
INFINI
OP
_STATUS_INTERNAL_ERROR
);
return
INFINI_STATUS_INTERNAL_ERROR
);
}
return
INFINI
OP
_STATUS_SUCCESS
;
return
INFINI_STATUS_SUCCESS
;
}
}
// namespace matmul::ascend
src/infiniop/ops/matmul/bang/matmul_bang.cc
View file @
80edd992
...
...
@@ -59,7 +59,7 @@ Descriptor::~Descriptor() {
delete
_opaque
;
}
infini
op
Status_t
Descriptor
::
create
(
infiniStatus_t
Descriptor
::
create
(
infiniopHandle_t
handle_
,
Descriptor
**
desc_ptr
,
infiniopTensorDescriptor_t
c_desc
,
...
...
@@ -69,12 +69,12 @@ infiniopStatus_t Descriptor::create(
auto
dtype
=
c_desc
->
dtype
;
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
::
ROW_MAJOR
);
if
(
status
!=
INFINI
OP
_STATUS_SUCCESS
)
{
if
(
status
!=
INFINI_STATUS_SUCCESS
)
{
return
status
;
}
...
...
@@ -122,10 +122,10 @@ infiniopStatus_t Descriptor::create(
c
,
handle
->
cnnl_handle_pool
},
handle
->
device
,
handle
->
device_id
);
return
INFINI
OP
_STATUS_SUCCESS
;
return
INFINI_STATUS_SUCCESS
;
}
infini
op
Status_t
Descriptor
::
calculate
(
infiniStatus_t
Descriptor
::
calculate
(
void
*
workspace
,
size_t
workspace_size
,
void
*
c
,
...
...
@@ -155,7 +155,7 @@ infiniopStatus_t Descriptor::calculate(
});
cnrtQueueSync
((
cnrtQueue_t
)
stream
);
return
INFINI
OP
_STATUS_SUCCESS
;
return
INFINI_STATUS_SUCCESS
;
}
}
// namespace matmul::bang
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