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
2942278a
Unverified
Commit
2942278a
authored
Apr 07, 2020
by
Tianqi Chen
Committed by
GitHub
Apr 07, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[RUNTIME] Quick fix PackedFunc String passing (#5266)
parent
df8a6f3b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
2 deletions
+14
-2
include/tvm/runtime/packed_func.h
+8
-2
tests/cpp/packed_func_test.cc
+6
-0
No files found.
include/tvm/runtime/packed_func.h
View file @
2942278a
...
@@ -513,9 +513,12 @@ class TVMArgValue : public TVMPODValue_ {
...
@@ -513,9 +513,12 @@ class TVMArgValue : public TVMPODValue_ {
}
}
}
}
operator
tvm
::
runtime
::
String
()
const
{
operator
tvm
::
runtime
::
String
()
const
{
// directly use the std::string constructor for now.
if
(
IsObjectRef
<
tvm
::
runtime
::
String
>
())
{
return
AsObjectRef
<
tvm
::
runtime
::
String
>
();
}
else
{
return
tvm
::
runtime
::
String
(
operator
std
::
string
());
return
tvm
::
runtime
::
String
(
operator
std
::
string
());
}
}
}
operator
DLDataType
()
const
{
operator
DLDataType
()
const
{
if
(
type_code_
==
kTVMStr
)
{
if
(
type_code_
==
kTVMStr
)
{
return
String2DLDataType
(
operator
std
::
string
());
return
String2DLDataType
(
operator
std
::
string
());
...
@@ -605,9 +608,12 @@ class TVMRetValue : public TVMPODValue_ {
...
@@ -605,9 +608,12 @@ class TVMRetValue : public TVMPODValue_ {
return
*
ptr
<
std
::
string
>
();
return
*
ptr
<
std
::
string
>
();
}
}
operator
tvm
::
runtime
::
String
()
const
{
operator
tvm
::
runtime
::
String
()
const
{
// directly use the std::string constructor for now.
if
(
IsObjectRef
<
tvm
::
runtime
::
String
>
())
{
return
AsObjectRef
<
tvm
::
runtime
::
String
>
();
}
else
{
return
tvm
::
runtime
::
String
(
operator
std
::
string
());
return
tvm
::
runtime
::
String
(
operator
std
::
string
());
}
}
}
operator
DLDataType
()
const
{
operator
DLDataType
()
const
{
if
(
type_code_
==
kTVMStr
)
{
if
(
type_code_
==
kTVMStr
)
{
return
String2DLDataType
(
operator
std
::
string
());
return
String2DLDataType
(
operator
std
::
string
());
...
...
tests/cpp/packed_func_test.cc
View file @
2942278a
...
@@ -95,6 +95,12 @@ TEST(PackedFunc, str) {
...
@@ -95,6 +95,12 @@ TEST(PackedFunc, str) {
CHECK
(
y
==
"hello"
);
CHECK
(
y
==
"hello"
);
*
rv
=
x
;
*
rv
=
x
;
})(
"hello"
);
})(
"hello"
);
PackedFunc
([
&
](
TVMArgs
args
,
TVMRetValue
*
rv
)
{
CHECK
(
args
.
num_args
==
1
);
runtime
::
String
s
=
args
[
0
];
CHECK
(
s
==
"hello"
);
})(
runtime
::
String
(
"hello"
));
}
}
...
...
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