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
2538df1b
Unverified
Commit
2538df1b
authored
Mar 05, 2025
by
PanZezhong1725
Committed by
GitHub
Mar 05, 2025
Browse files
Merge pull request #88 from PanZezhong1725/issue/87/cpu
issue/87/cpu 重构cpu handle
parents
93e0b45f
878db6cc
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
16 deletions
+26
-16
src/infiniop/devices/cpu/cpu_handle.cc
src/infiniop/devices/cpu/cpu_handle.cc
+6
-6
src/infiniop/devices/cpu/cpu_handle.h
src/infiniop/devices/cpu/cpu_handle.h
+8
-5
src/infiniop/devices/handle.cc
src/infiniop/devices/handle.cc
+11
-4
src/infiniop/ops/matmul/cpu/matmul_cpu.cc
src/infiniop/ops/matmul/cpu/matmul_cpu.cc
+1
-1
No files found.
src/infiniop/devices/cpu/cpu_handle.cc
View file @
2538df1b
#include "cpu_handle.h"
infiniStatus_t
createCpuHandle
(
infiniopCpuHandle_t
*
handle_ptr
)
{
*
handle_ptr
=
new
InfiniopHandle
{
INFINI_DEVICE_CPU
,
0
};
return
INFINI_STATUS_SUCCESS
;
}
namespace
infiniop
::
cpu
{
Handle
::
Handle
()
:
InfiniopHandle
{
INFINI_DEVICE_CPU
,
0
}
{}
infiniStatus_t
destroyCpuHandle
(
i
nfiniop
Cpu
Handle
_t
handle
)
{
delete
h
andle
;
infiniStatus_t
Handle
::
create
(
I
nfiniopHandle
**
handle
_ptr
)
{
*
handle_ptr
=
new
H
andle
{}
;
return
INFINI_STATUS_SUCCESS
;
}
}
// namespace infiniop::cpu
src/infiniop/devices/cpu/cpu_handle.h
View file @
2538df1b
...
...
@@ -3,10 +3,13 @@
#include "../../handle.h"
typedef
infiniopHandle_t
infiniopCpuHandle_t
;
infiniStatus_t
createCpuHandle
(
infiniopCpuHandle_t
*
handle_ptr
);
infiniStatus_t
destroyCpuHandle
(
infiniopCpuHandle_t
handle
);
namespace
infiniop
::
cpu
{
class
Handle
:
public
InfiniopHandle
{
Handle
();
public:
static
infiniStatus_t
create
(
InfiniopHandle
**
handle_ptr
);
};
}
// namespace infiniop::cpu
#endif
src/infiniop/devices/handle.cc
View file @
2538df1b
...
...
@@ -24,7 +24,7 @@ __C infiniStatus_t infiniopCreateHandle(infiniopHandle_t *handle_ptr,
switch
(
device
)
{
#ifdef ENABLE_CPU_API
case
INFINI_DEVICE_CPU
:
return
createCpuHandle
((
infiniopCpuHandle_t
*
)
handle_ptr
);
return
infiniop
::
cpu
::
Handle
::
create
(
handle_ptr
);
#endif
#ifdef ENABLE_CUDA_API
case
INFINI_DEVICE_NVIDIA
:
{
...
...
@@ -51,10 +51,15 @@ __C infiniStatus_t infiniopCreateHandle(infiniopHandle_t *handle_ptr,
}
__C
infiniStatus_t
infiniopDestroyHandle
(
infiniopHandle_t
handle
)
{
#define DELETE(CASE, NAMESPACE) \
case CASE: \
delete reinterpret_cast<infiniop::NAMESPACE::Handle *>(handle); \
return INFINI_STATUS_SUCCESS;
switch
(
handle
->
device
)
{
#ifdef ENABLE_CPU_API
case
INFINI_DEVICE_CPU
:
return
destroyCpuHandle
((
infiniopCpuHandle_t
)
handle
);
DELETE
(
INFINI_DEVICE_CPU
,
cpu
)
#endif
#ifdef ENABLE_CUDA_API
case
INFINI_DEVICE_NVIDIA
:
{
...
...
@@ -76,6 +81,8 @@ __C infiniStatus_t infiniopDestroyHandle(infiniopHandle_t handle) {
return
destroyKunlunHandle
((
infiniopKunlunHandle_t
)
handle
);
}
#endif
default:
return
INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED
;
}
return
INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED
;
#undef DELETE
}
src/infiniop/ops/matmul/cpu/matmul_cpu.cc
View file @
2538df1b
...
...
@@ -12,7 +12,7 @@ infiniStatus_t Descriptor::create(
infiniopTensorDescriptor_t
c_desc
,
infiniopTensorDescriptor_t
a_desc
,
infiniopTensorDescriptor_t
b_desc
)
{
auto
handle
=
reinterpret_cast
<
infiniop
Cpu
Handle
_t
>
(
handle_
);
auto
handle
=
reinterpret_cast
<
infiniop
::
cpu
::
Handle
*
>
(
handle_
);
auto
dtype
=
c_desc
->
dtype
();
if
(
dtype
!=
INFINI_DTYPE_F16
&&
dtype
!=
INFINI_DTYPE_F32
)
{
...
...
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