Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tvm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cld
ml
tvm
Commits
b205db35
Commit
b205db35
authored
7 years ago
by
eqy
Committed by
Tianqi Chen
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
preserve input option order (#1068)
parent
267f0294
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
include/tvm/build_module.h
+16
-16
16 additions, 16 deletions
include/tvm/build_module.h
src/codegen/build_module.cc
+16
-17
16 additions, 17 deletions
src/codegen/build_module.cc
tests/cpp/build_module_test.cc
+3
-0
3 additions, 0 deletions
tests/cpp/build_module_test.cc
with
35 additions
and
33 deletions
include/tvm/build_module.h
+
16
−
16
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
...
...
This diff is collapsed.
Click to expand it.
src/codegen/build_module.cc
+
16
−
17
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
...
...
This diff is collapsed.
Click to expand it.
tests/cpp/build_module_test.cc
+
3
−
0
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"
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment