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
87d10975
Unverified
Commit
87d10975
authored
Feb 18, 2025
by
PanZezhong1725
Committed by
GitHub
Feb 18, 2025
Browse files
Merge pull request #61 from PanZezhong1725/issue/60
issue/60: to_tensor存储原torch张量,增加INFINI_ROOT默认路径
parents
89e49e31
26f8ae57
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
5 deletions
+6
-5
test/infiniop/libinfiniop/liboperators.py
test/infiniop/libinfiniop/liboperators.py
+5
-3
test/infiniop/libinfiniop/utils.py
test/infiniop/libinfiniop/utils.py
+1
-2
No files found.
test/infiniop/libinfiniop/liboperators.py
View file @
87d10975
...
...
@@ -5,11 +5,12 @@ import ctypes
from
ctypes
import
c_int
,
c_int64
,
c_uint64
,
Structure
,
POINTER
,
c_size_t
from
.datatypes
import
*
from
.devices
import
*
from
pathlib
import
Path
Device
=
c_int
Optype
=
c_int
INFINI_ROOT
=
os
.
environ
.
get
(
"INFINI_ROOT"
)
INFINI_ROOT
=
os
.
get
env
(
"INFINI_ROOT"
)
or
str
(
Path
.
home
()
/
".infini"
)
class
TensorDescriptor
(
Structure
):
...
...
@@ -30,9 +31,10 @@ infiniopTensorDescriptor_t = ctypes.POINTER(TensorDescriptor)
class
CTensor
:
def
__init__
(
self
,
desc
,
data
):
def
__init__
(
self
,
desc
,
torch_tensor
):
self
.
descriptor
=
desc
self
.
data
=
data
self
.
torch_tensor_
=
torch_tensor
self
.
data
=
torch_tensor
.
data_ptr
()
class
Handle
(
Structure
):
...
...
test/infiniop/libinfiniop/utils.py
View file @
87d10975
...
...
@@ -19,7 +19,6 @@ def to_tensor(tensor, lib):
ndim
=
tensor
.
ndimension
()
shape
=
(
ctypes
.
c_size_t
*
ndim
)(
*
tensor
.
shape
)
strides
=
(
ctypes
.
c_int64
*
ndim
)(
*
(
tensor
.
stride
()))
data_ptr
=
tensor
.
data_ptr
()
# fmt: off
dt
=
(
InfiniDtype
.
I8
if
tensor
.
dtype
==
torch
.
int8
else
...
...
@@ -46,7 +45,7 @@ def to_tensor(tensor, lib):
ctypes
.
byref
(
tensor_desc
),
ndim
,
shape
,
strides
,
dt
)
# Create Tensor
return
CTensor
(
tensor_desc
,
data_pt
r
)
return
CTensor
(
tensor_desc
,
tenso
r
)
def
create_workspace
(
size
,
torch_device
):
...
...
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