Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tic
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wenyuanbo
tic
Commits
2607a836
Commit
2607a836
authored
Sep 18, 2017
by
Tianqi Chen
Committed by
GitHub
Sep 18, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[RUNTIME][PYTHON] More compatibility in ndarray (#463)
parent
0220abba
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
1 deletions
+13
-1
python/tvm/_ffi/ndarray.py
+12
-0
python/tvm/ndarray.py
+1
-1
No files found.
python/tvm/_ffi/ndarray.py
View file @
2607a836
...
...
@@ -165,6 +165,10 @@ class NDArrayBase(_NDArrayBase):
arr : NDArray
Reference to self.
"""
if
isinstance
(
source_array
,
NDArrayBase
):
source_array
.
copyto
(
self
)
return
self
if
not
isinstance
(
source_array
,
np
.
ndarray
):
try
:
source_array
=
np
.
array
(
source_array
,
dtype
=
self
.
dtype
)
...
...
@@ -187,6 +191,14 @@ class NDArrayBase(_NDArrayBase):
check_call
(
_LIB
.
TVMArrayCopyFromBytes
(
self
.
handle
,
data
,
nbytes
))
return
self
def
__repr__
(
self
):
res
=
"<tvm.NDArray shape={0}, {1}>
\n
"
.
format
(
self
.
shape
,
self
.
context
)
res
+=
self
.
asnumpy
()
.
__repr__
()
return
res
def
__str__
(
self
):
return
str
(
self
.
asnumpy
())
def
asnumpy
(
self
):
"""Convert this array to numpy array
...
...
python/tvm/ndarray.py
View file @
2607a836
...
...
@@ -140,7 +140,7 @@ def array(arr, ctx=cpu(0)):
ret : NDArray
The created array
"""
if
not
isinstance
(
arr
,
_np
.
ndarray
):
if
not
isinstance
(
arr
,
(
_np
.
ndarray
,
NDArray
)
):
arr
=
_np
.
array
(
arr
)
return
empty
(
arr
.
shape
,
arr
.
dtype
,
ctx
)
.
copyfrom
(
arr
)
...
...
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