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
b205db35
Commit
b205db35
authored
Mar 31, 2018
by
eqy
Committed by
Tianqi Chen
Mar 31, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
preserve input option order (#1068)
parent
267f0294
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
33 deletions
+35
-33
include/tvm/build_module.h
+16
-16
src/codegen/build_module.cc
+16
-17
tests/cpp/build_module_test.cc
+3
-0
No files found.
include/tvm/build_module.h
View file @
b205db35
...
...
@@ -126,36 +126,36 @@ struct TargetContext {
/*! \brief This namespace provides functions to construct Target instances */
namespace
target
{
/*! \return A target for LLVM */
EXPORT
Target
llvm
(
const
std
::
unordered_set
<
std
::
string
>&
options
=
std
::
unordered_set
<
std
::
string
>
());
EXPORT
Target
llvm
(
const
std
::
vector
<
std
::
string
>&
options
=
std
::
vector
<
std
::
string
>
());
/*! \return A target for CUDA */
EXPORT
Target
cuda
(
const
std
::
unordered_set
<
std
::
string
>&
options
=
std
::
unordered_set
<
std
::
string
>
());
EXPORT
Target
cuda
(
const
std
::
vector
<
std
::
string
>&
options
=
std
::
vector
<
std
::
string
>
());
/*! \return A target for ROCm */
EXPORT
Target
rocm
(
const
std
::
unordered_set
<
std
::
string
>&
options
=
std
::
unordered_set
<
std
::
string
>
());
EXPORT
Target
rocm
(
const
std
::
vector
<
std
::
string
>&
options
=
std
::
vector
<
std
::
string
>
());
/*! \return A target for OpenCL */
EXPORT
Target
opencl
(
const
std
::
unordered_set
<
std
::
string
>&
options
=
std
::
unordered_set
<
std
::
string
>
());
EXPORT
Target
opencl
(
const
std
::
vector
<
std
::
string
>&
options
=
std
::
vector
<
std
::
string
>
());
/*! \return A target for Metal */
EXPORT
Target
metal
(
const
std
::
unordered_set
<
std
::
string
>&
options
=
std
::
unordered_set
<
std
::
string
>
());
EXPORT
Target
metal
(
const
std
::
vector
<
std
::
string
>&
options
=
std
::
vector
<
std
::
string
>
());
/*! \return A target for rasp */
EXPORT
Target
rasp
(
const
std
::
unordered_set
<
std
::
string
>&
options
=
std
::
unordered_set
<
std
::
string
>
());
EXPORT
Target
rasp
(
const
std
::
vector
<
std
::
string
>&
options
=
std
::
vector
<
std
::
string
>
());
/*! \return A target for Mali */
EXPORT
Target
mali
(
const
std
::
unordered_set
<
std
::
string
>&
options
=
std
::
unordered_set
<
std
::
string
>
());
EXPORT
Target
mali
(
const
std
::
vector
<
std
::
string
>&
options
=
std
::
vector
<
std
::
string
>
());
/*! \return A target for stackvm */
EXPORT
Target
stackvm
(
const
std
::
unordered_set
<
std
::
string
>&
options
=
std
::
unordered_set
<
std
::
string
>
());
EXPORT
Target
stackvm
(
const
std
::
vector
<
std
::
string
>&
options
=
std
::
vector
<
std
::
string
>
());
}
// namespace target
...
...
src/codegen/build_module.cc
View file @
b205db35
...
...
@@ -31,7 +31,7 @@ TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
* \return The constructed Target
*/
Target
CreateTarget
(
const
std
::
string
&
target_name
,
const
std
::
unordered_set
<
std
::
string
>&
options
)
{
const
std
::
vector
<
std
::
string
>&
options
)
{
auto
target
=
Target
(
std
::
make_shared
<
TargetNode
>
());
auto
t
=
static_cast
<
TargetNode
*>
(
target
.
node_
.
get
());
...
...
@@ -58,7 +58,6 @@ Target CreateTarget(const std::string& target_name,
if
(
device_name
.
length
()
>
0
)
{
t
->
keys_array
.
push_back
(
ir
::
StringImm
::
make
(
device_name
));
}
t
->
device_type
=
kDLCPU
;
t
->
thread_warp_size
=
1
;
if
(
target_name
==
"llvm"
)
{
...
...
@@ -95,10 +94,10 @@ Target CreateTarget(const std::string& target_name,
TVM_REGISTER_API
(
"_TargetCreate"
)
.
set_body
([](
TVMArgs
args
,
TVMRetValue
*
ret
)
{
std
::
string
target_name
=
args
[
0
];
std
::
unordered_set
<
std
::
string
>
options
;
std
::
vector
<
std
::
string
>
options
;
for
(
int
i
=
1
;
i
<
args
.
num_args
;
++
i
)
{
std
::
string
arg
=
args
[
i
];
options
.
insert
(
arg
);
options
.
push_back
(
arg
);
}
*
ret
=
CreateTarget
(
target_name
,
options
);
...
...
@@ -175,10 +174,10 @@ Target Target::create(const std::string& target_str) {
ss
>>
target_name
;
auto
device_name
=
GetDeviceName
(
target_str
);
std
::
unordered_set
<
std
::
string
>
options
;
std
::
vector
<
std
::
string
>
options
;
std
::
string
item
;
while
(
ss
>>
item
)
{
options
.
insert
(
item
);
options
.
push_back
(
item
);
}
if
(
device_name
==
"rasp"
)
{
...
...
@@ -224,33 +223,33 @@ tvm::Target Target::current_target(bool allow_not_defined) {
}
namespace
target
{
std
::
unordered_set
<
std
::
string
>
MergeOptions
(
std
::
unordered_set
<
std
::
string
>
opts
,
const
std
::
unordered_set
<
std
::
string
>&
new_opts
)
{
opts
.
insert
(
new_opts
.
begin
(),
new_opts
.
end
());
std
::
vector
<
std
::
string
>
MergeOptions
(
std
::
vector
<
std
::
string
>
opts
,
const
std
::
vector
<
std
::
string
>&
new_opts
)
{
opts
.
insert
(
opts
.
end
(),
new_opts
.
begin
(),
new_opts
.
end
());
return
opts
;
}
Target
llvm
(
const
std
::
unordered_set
<
std
::
string
>&
options
)
{
Target
llvm
(
const
std
::
vector
<
std
::
string
>&
options
)
{
return
CreateTarget
(
"llvm"
,
options
);
}
Target
cuda
(
const
std
::
unordered_set
<
std
::
string
>&
options
)
{
Target
cuda
(
const
std
::
vector
<
std
::
string
>&
options
)
{
return
CreateTarget
(
"cuda"
,
options
);
}
Target
rocm
(
const
std
::
unordered_set
<
std
::
string
>&
options
)
{
Target
rocm
(
const
std
::
vector
<
std
::
string
>&
options
)
{
return
CreateTarget
(
"rocm"
,
options
);
}
Target
opencl
(
const
std
::
unordered_set
<
std
::
string
>&
options
)
{
Target
opencl
(
const
std
::
vector
<
std
::
string
>&
options
)
{
return
CreateTarget
(
"opencl"
,
options
);
}
Target
metal
(
const
std
::
unordered_set
<
std
::
string
>&
options
)
{
Target
metal
(
const
std
::
vector
<
std
::
string
>&
options
)
{
return
CreateTarget
(
"metal"
,
options
);
}
Target
rasp
(
const
std
::
unordered_set
<
std
::
string
>&
options
)
{
Target
rasp
(
const
std
::
vector
<
std
::
string
>&
options
)
{
return
CreateTarget
(
"llvm"
,
MergeOptions
(
options
,
{
"-device=rasp"
,
"-mtriple=armv7l-none-linux-gnueabihf"
,
...
...
@@ -259,14 +258,14 @@ Target rasp(const std::unordered_set<std::string>& options) {
}));
}
Target
mali
(
const
std
::
unordered_set
<
std
::
string
>&
options
)
{
Target
mali
(
const
std
::
vector
<
std
::
string
>&
options
)
{
return
CreateTarget
(
"opencl"
,
MergeOptions
(
options
,
{
"-device=mali"
}));
}
Target
stackvm
(
const
std
::
unordered_set
<
std
::
string
>&
options
)
{
Target
stackvm
(
const
std
::
vector
<
std
::
string
>&
options
)
{
return
CreateTarget
(
"stackvm"
,
options
);
}
}
// namespace target
...
...
tests/cpp/build_module_test.cc
View file @
b205db35
...
...
@@ -32,6 +32,9 @@ TEST(BuildModule, Basic) {
auto
lowered
=
lower
(
s
,
args
,
"func"
,
binds
,
config
);
auto
module
=
build
(
lowered
,
target
,
Target
(),
config
);
auto
mali_target
=
Target
::
create
(
"opencl -model=Mali-T860MP4@800Mhz -device=mali"
);
CHECK_EQ
(
mali_target
->
str
(),
"opencl -model=Mali-T860MP4@800Mhz -device=mali"
);
}
...
...
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