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
05188f30
Commit
05188f30
authored
Mar 04, 2025
by
PanZezhong
Browse files
issue/78 错误信息改用通用代码
parent
e1caa4f5
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
15 additions
and
67 deletions
+15
-67
src/infiniop/devices/ascend/ascend_handle.cc
src/infiniop/devices/ascend/ascend_handle.cc
+1
-3
src/infiniop/devices/ascend/common_ascend.cc
src/infiniop/devices/ascend/common_ascend.cc
+3
-9
src/infiniop/devices/ascend/common_ascend.h
src/infiniop/devices/ascend/common_ascend.h
+2
-19
src/infiniop/devices/ascend/tensor_aclnn.cc
src/infiniop/devices/ascend/tensor_aclnn.cc
+1
-4
src/infiniop/devices/cuda/common_cuda.cuh
src/infiniop/devices/cuda/common_cuda.cuh
+4
-19
src/infiniop/ops/matmul/ascend/matmul_ascend.cc
src/infiniop/ops/matmul/ascend/matmul_ascend.cc
+4
-13
No files found.
src/infiniop/devices/ascend/ascend_handle.cc
View file @
05188f30
...
@@ -2,9 +2,7 @@
...
@@ -2,9 +2,7 @@
infiniStatus_t
createAscendHandle
(
infiniopAscendHandle_t
*
handle_ptr
)
{
infiniStatus_t
createAscendHandle
(
infiniopAscendHandle_t
*
handle_ptr
)
{
int
device_id
=
0
;
int
device_id
=
0
;
auto
ret
=
aclrtGetDevice
(
&
device_id
);
CHECK_ACL
(
aclrtGetDevice
(
&
device_id
));
CHECK_RET
(
ret
==
ACL_SUCCESS
,
return
INFINI_STATUS_DEVICE_NOT_INITIALIZED
);
*
handle_ptr
=
new
InfiniopAscendHandle
{
INFINI_DEVICE_ASCEND
,
device_id
};
*
handle_ptr
=
new
InfiniopAscendHandle
{
INFINI_DEVICE_ASCEND
,
device_id
};
...
...
src/infiniop/devices/ascend/common_ascend.cc
View file @
05188f30
...
@@ -11,21 +11,15 @@ int64_t numElements(const int64_t *shape, int64_t num) {
...
@@ -11,21 +11,15 @@ int64_t numElements(const int64_t *shape, int64_t num) {
infiniStatus_t
mallocWorkspace
(
void
**
workspaceAddr
,
size_t
workspaceSize
)
{
infiniStatus_t
mallocWorkspace
(
void
**
workspaceAddr
,
size_t
workspaceSize
)
{
*
workspaceAddr
=
nullptr
;
*
workspaceAddr
=
nullptr
;
if
(
workspaceSize
>
0
)
{
if
(
workspaceSize
>
0
)
{
auto
ret
=
aclrtMalloc
(
workspaceAddr
,
workspaceSize
,
CHECK_ACL
(
aclrtMalloc
(
workspaceAddr
,
workspaceSize
,
ACL_MEM_MALLOC_HUGE_FIRST
);
ACL_MEM_MALLOC_HUGE_FIRST
));
CHECK_RET
(
ret
==
ACL_SUCCESS
,
LOG_PRINT
(
"aclrtMalloc failed. ERROR: %d
\n
"
,
ret
);
return
INFINI_STATUS_INTERNAL_ERROR
);
}
}
return
INFINI_STATUS_SUCCESS
;
return
INFINI_STATUS_SUCCESS
;
}
}
infiniStatus_t
freeWorkspace
(
void
*
workspaceAddr
)
{
infiniStatus_t
freeWorkspace
(
void
*
workspaceAddr
)
{
if
(
workspaceAddr
!=
nullptr
)
{
if
(
workspaceAddr
!=
nullptr
)
{
auto
ret
=
aclrtFree
(
workspaceAddr
);
CHECK_ACL
(
aclrtFree
(
workspaceAddr
));
CHECK_RET
(
ret
==
ACL_SUCCESS
,
LOG_PRINT
(
"aclrtFree failed, ERROR: %d
\n
"
,
ret
);
return
INFINI_STATUS_INTERNAL_ERROR
);
}
}
return
INFINI_STATUS_SUCCESS
;
return
INFINI_STATUS_SUCCESS
;
}
}
...
...
src/infiniop/devices/ascend/common_ascend.h
View file @
05188f30
#ifndef __INFINIOP_COMMON_ASCEND_H__
#ifndef __INFINIOP_COMMON_ASCEND_H__
#define __INFINIOP_COMMON_ASCEND_H__
#define __INFINIOP_COMMON_ASCEND_H__
#include "../../utils.h"
#include "ascend_handle.h"
#include "ascend_handle.h"
#include <acl/acl.h>
#include <acl/acl.h>
#include <acl/acl_base.h>
#include <acl/acl_base.h>
...
@@ -15,25 +16,7 @@
...
@@ -15,25 +16,7 @@
#ifdef __cplusplus
#ifdef __cplusplus
extern
"C"
{
extern
"C"
{
#endif
#endif
#define CHECK_ACL(API) CHECK_INTERNAL(API, ACL_SUCCESS)
#define CHECK_RET(cond, return_expr) \
do { \
if (!(cond)) { \
return_expr; \
} \
} while (0)
#define LOG_PRINT(message, ...) \
do { \
printf(message, ##__VA_ARGS__); \
} while (0)
#define LOG_ERROR(message, ...) \
do { \
printf(message, ##__VA_ARGS__); \
return INFINI_STATUS_INTERNAL_ERROR; \
} while (0)
#ifdef __cplusplus
#ifdef __cplusplus
};
};
#endif
#endif
...
...
src/infiniop/devices/ascend/tensor_aclnn.cc
View file @
05188f30
...
@@ -70,10 +70,7 @@ infiniStatus_t aclnnTensorDescriptor::createTensor(void *data) {
...
@@ -70,10 +70,7 @@ infiniStatus_t aclnnTensorDescriptor::createTensor(void *data) {
}
}
infiniStatus_t
aclnnTensorDescriptor
::
destroyTensor
()
{
infiniStatus_t
aclnnTensorDescriptor
::
destroyTensor
()
{
auto
ret
=
aclDestroyTensor
(
this
->
t
);
CHECK_ACL
(
aclDestroyTensor
(
this
->
t
));
CHECK_RET
(
ret
==
ACL_SUCCESS
,
LOG_PRINT
(
"aclDesctroyTensor failed, ERROR: %d
\n
"
,
ret
);
return
INFINI_STATUS_INTERNAL_ERROR
);
t
=
nullptr
;
t
=
nullptr
;
return
INFINI_STATUS_SUCCESS
;
return
INFINI_STATUS_SUCCESS
;
...
...
src/infiniop/devices/cuda/common_cuda.cuh
View file @
05188f30
...
@@ -5,29 +5,14 @@
...
@@ -5,29 +5,14 @@
#define MAX_WARP_PER_BLOCK 32
#define MAX_WARP_PER_BLOCK 32
#define WARP_SIZE 32
#define WARP_SIZE 32
#include "../../utils.h"
#include <iostream>
#include <iostream>
#define CHECK_CUDA_OR_RETURN(call, errorCode) \
#define CHECK_CUDA_OR_RETURN(API, ERROR) CHECK_API_OR(API, cudaSuccess, return ERROR)
do { \
if (auto status = call; status != cudaSuccess) { \
std::cerr << "CUDA error: " << cudaGetErrorString(status) \
<< " in file " << __FILE__ << ", function " << __func__ \
<< ", line " << __LINE__ << std::endl; \
return errorCode; \
} \
} while (0)
#define CHECK_CUDA(
call
) CHECK_
CUDA_OR_RETURN(call, INFINI_STATUS_INTERNAL_ERROR
)
#define CHECK_CUDA(
API
) CHECK_
INTERNAL(API, cudaSuccess
)
#define CHECK_CUDNN(call) \
#define CHECK_CUDNN(API) CHECK_INTERNAL(API, CUDNN_STATUS_SUCCESS)
do { \
if (auto status = call; status != CUDNN_STATUS_SUCCESS) { \
std::cerr << "CUDNN error: " << cudnnGetErrorString(status) \
<< " in file " << __FILE__ << ", function " << __func__ \
<< ", line " << __LINE__ << std::endl; \
return INFINI_STATUS_INTERNAL_ERROR; \
} \
} while (0)
#include "../pool.h"
#include "../pool.h"
#include "cuda_handle.h"
#include "cuda_handle.h"
...
...
src/infiniop/ops/matmul/ascend/matmul_ascend.cc
View file @
05188f30
...
@@ -88,10 +88,7 @@ infiniStatus_t Descriptor::create(
...
@@ -88,10 +88,7 @@ infiniStatus_t Descriptor::create(
// use alpha = 0.5, beta = 0.5 temporarily
// use alpha = 0.5, beta = 0.5 temporarily
int8_t
mt
=
1
;
int8_t
mt
=
1
;
auto
ret
=
aclnnGemmGetWorkspaceSize
(
ta
,
tb
,
tc
,
.5
,
.5
,
0
,
0
,
tc
,
mt
,
&
workspace_size
,
&
executor
);
CHECK_ACL
(
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_STATUS_INTERNAL_ERROR
);
aclSetAclOpExecutorRepeatable
(
executor
);
aclSetAclOpExecutorRepeatable
(
executor
);
*
desc_ptr
=
new
Descriptor
(
*
desc_ptr
=
new
Descriptor
(
...
@@ -122,12 +119,9 @@ infiniStatus_t Descriptor::calculate(
...
@@ -122,12 +119,9 @@ infiniStatus_t Descriptor::calculate(
tb
=
_opaque
->
b
->
t
;
tb
=
_opaque
->
b
->
t
;
size_t
workspace_size
;
size_t
workspace_size
;
auto
ret
=
aclnnGemmGetWorkspaceSize
(
CHECK_ACL
(
aclnnGemmGetWorkspaceSize
(
ta
,
tb
,
tc
,
alpha
,
beta
,
0
,
0
,
tc
,
_opaque
->
mt
,
ta
,
tb
,
tc
,
alpha
,
beta
,
0
,
0
,
tc
,
_opaque
->
mt
,
&
workspace_size
,
&
(
_opaque
->
executor
));
&
workspace_size
,
&
(
_opaque
->
executor
)));
CHECK_RET
(
ret
==
ACL_SUCCESS
,
LOG_PRINT
(
"aclnnGemmGetWorkspaceSize failed. ERROR: %d
\n
"
,
ret
);
return
INFINI_STATUS_INTERNAL_ERROR
);
if
(
workspaceSize_
<
workspace_size
)
{
if
(
workspaceSize_
<
workspace_size
)
{
return
INFINI_STATUS_INSUFFICIENT_WORKSPACE
;
return
INFINI_STATUS_INSUFFICIENT_WORKSPACE
;
}
}
...
@@ -139,10 +133,7 @@ infiniStatus_t Descriptor::calculate(
...
@@ -139,10 +133,7 @@ infiniStatus_t Descriptor::calculate(
AclSetTensorAddr
(
_opaque
->
executor
,
1
,
tb
,
((
char
*
)
b
)
+
i
*
_info
.
b_matrix
.
stride
*
unit
);
AclSetTensorAddr
(
_opaque
->
executor
,
1
,
tb
,
((
char
*
)
b
)
+
i
*
_info
.
b_matrix
.
stride
*
unit
);
AclSetTensorAddr
(
_opaque
->
executor
,
2
,
tc
,
((
char
*
)
c
)
+
i
*
_info
.
c_matrix
.
stride
*
unit
);
AclSetTensorAddr
(
_opaque
->
executor
,
2
,
tc
,
((
char
*
)
c
)
+
i
*
_info
.
c_matrix
.
stride
*
unit
);
AclSetTensorAddr
(
_opaque
->
executor
,
3
,
tc
,
((
char
*
)
c
)
+
i
*
_info
.
c_matrix
.
stride
*
unit
);
AclSetTensorAddr
(
_opaque
->
executor
,
3
,
tc
,
((
char
*
)
c
)
+
i
*
_info
.
c_matrix
.
stride
*
unit
);
ret
=
aclnnGemm
(
workspace
,
workspace_size
,
_opaque
->
executor
,
stream
);
CHECK_ACL
(
aclnnGemm
(
workspace
,
workspace_size
,
_opaque
->
executor
,
stream
));
CHECK_RET
(
ret
==
ACL_SUCCESS
,
LOG_PRINT
(
"aclnnGemm failed. ERROR: %d
\n
"
,
ret
);
return
INFINI_STATUS_INTERNAL_ERROR
);
}
}
return
INFINI_STATUS_SUCCESS
;
return
INFINI_STATUS_SUCCESS
;
...
...
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