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
a55d1196
Commit
a55d1196
authored
Dec 27, 2019
by
Zhao Wu (Chinese Name: 吴钊)
Committed by
Tianqi Chen
Dec 27, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Runtime] add necessary const qualifier for NDArray container of parameters (#4590)
parent
c3deec19
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
9 deletions
+9
-9
include/tvm/runtime/c_runtime_api.h
+1
-1
include/tvm/runtime/ndarray.h
+7
-7
src/runtime/ndarray.cc
+1
-1
No files found.
include/tvm/runtime/c_runtime_api.h
View file @
a55d1196
...
...
@@ -136,7 +136,7 @@ typedef DLDataType TVMType;
typedef
DLContext
TVMContext
;
/*!
* \brief The tensor array stucture to TVM API.
* \brief The tensor array st
r
ucture to TVM API.
*/
typedef
DLTensor
TVMArray
;
...
...
include/tvm/runtime/ndarray.h
View file @
a55d1196
...
...
@@ -118,7 +118,7 @@ class NDArray {
* \note The copy may happen asynchrously if it involves a GPU context.
* TVMSynchronize is necessary.
*/
inline
void
CopyFrom
(
DLTensor
*
other
);
inline
void
CopyFrom
(
const
DLTensor
*
other
);
inline
void
CopyFrom
(
const
NDArray
&
other
);
/*!
* \brief Copy data content into another array.
...
...
@@ -188,7 +188,7 @@ class NDArray {
* \param stream The stream used in copy.
*/
TVM_DLL
static
void
CopyFromTo
(
DLTensor
*
from
,
DLTensor
*
to
,
TVMStreamHandle
stream
=
nullptr
);
const
DLTensor
*
from
,
DLTensor
*
to
,
TVMStreamHandle
stream
=
nullptr
);
TVM_DLL
std
::
vector
<
int64_t
>
Shape
()
const
;
...
...
@@ -228,7 +228,7 @@ struct array_type_info<NDArray> {
* \param strm The outpu stream
* \param tensor The tensor to be saved.
*/
inline
bool
SaveDLTensor
(
dmlc
::
Stream
*
strm
,
DLTensor
*
tensor
);
inline
bool
SaveDLTensor
(
dmlc
::
Stream
*
strm
,
const
DLTensor
*
tensor
);
/*!
* \brief Reference counted Container object used to back NDArray.
...
...
@@ -369,7 +369,7 @@ inline size_t GetDataSize(const DLTensor& arr) {
return
size
;
}
inline
void
NDArray
::
CopyFrom
(
DLTensor
*
other
)
{
inline
void
NDArray
::
CopyFrom
(
const
DLTensor
*
other
)
{
CHECK
(
data_
!=
nullptr
);
CopyFromTo
(
other
,
&
(
data_
->
dl_tensor
));
}
...
...
@@ -413,7 +413,7 @@ inline const DLTensor* NDArray::operator->() const {
constexpr
uint64_t
kTVMNDArrayMagic
=
0xDD5E40F096B4A13F
;
inline
bool
SaveDLTensor
(
dmlc
::
Stream
*
strm
,
DLTensor
*
tensor
)
{
const
DLTensor
*
tensor
)
{
uint64_t
header
=
kTVMNDArrayMagic
,
reserved
=
0
;
strm
->
Write
(
header
);
strm
->
Write
(
reserved
);
...
...
@@ -451,7 +451,7 @@ inline bool SaveDLTensor(dmlc::Stream* strm,
}
else
{
std
::
vector
<
uint8_t
>
bytes
(
data_byte_size
);
CHECK_EQ
(
TVMArrayCopyToBytes
(
tensor
,
dmlc
::
BeginPtr
(
bytes
),
data_byte_size
),
0
)
const_cast
<
DLTensor
*>
(
tensor
)
,
dmlc
::
BeginPtr
(
bytes
),
data_byte_size
),
0
)
<<
TVMGetLastError
();
if
(
!
DMLC_IO_NO_ENDIAN_SWAP
)
{
dmlc
::
ByteSwap
(
dmlc
::
BeginPtr
(
bytes
),
type_bytes
,
num_elems
);
...
...
@@ -462,7 +462,7 @@ inline bool SaveDLTensor(dmlc::Stream* strm,
}
inline
void
NDArray
::
Save
(
dmlc
::
Stream
*
strm
)
const
{
SaveDLTensor
(
strm
,
const_cast
<
DLTensor
*>
(
operator
->
()
));
SaveDLTensor
(
strm
,
operator
->
(
));
}
inline
bool
NDArray
::
Load
(
dmlc
::
Stream
*
strm
)
{
...
...
src/runtime/ndarray.cc
View file @
a55d1196
...
...
@@ -160,7 +160,7 @@ NDArray NDArray::FromDLPack(DLManagedTensor* tensor) {
return
NDArray
(
data
);
}
void
NDArray
::
CopyFromTo
(
DLTensor
*
from
,
void
NDArray
::
CopyFromTo
(
const
DLTensor
*
from
,
DLTensor
*
to
,
TVMStreamHandle
stream
)
{
size_t
from_size
=
GetDataSize
(
*
from
);
...
...
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