Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
MIGraphX
Commits
b40c020a
"testing/vscode:/vscode.git/clone" did not exist on "d110d0871c364577427e946954ece65880fa034f"
Commit
b40c020a
authored
Jul 19, 2023
by
umangyadav
Browse files
Use target_id instead of string
parent
93bcb779
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
19 deletions
+19
-19
src/include/migraphx/target_assignments.hpp
src/include/migraphx/target_assignments.hpp
+4
-4
src/program.cpp
src/program.cpp
+14
-14
test/fpga/get_target_assignments.cpp
test/fpga/get_target_assignments.cpp
+1
-1
No files found.
src/include/migraphx/target_assignments.hpp
View file @
b40c020a
...
@@ -34,13 +34,13 @@ inline namespace MIGRAPHX_INLINE_NS {
...
@@ -34,13 +34,13 @@ inline namespace MIGRAPHX_INLINE_NS {
struct
target_assignments
struct
target_assignments
{
{
using
iterator
=
std
::
unordered_map
<
instruction_ref
,
std
::
s
tring
>::
const_iterator
;
using
iterator
=
std
::
unordered_map
<
instruction_ref
,
std
::
s
ize_t
>::
const_iterator
;
using
value_type
=
std
::
pair
<
instruction_ref
,
std
::
s
tring
>
;
using
value_type
=
std
::
pair
<
instruction_ref
,
std
::
s
ize_t
>
;
auto
size
()
const
{
return
assignments
.
size
();
}
auto
size
()
const
{
return
assignments
.
size
();
}
auto
&
at
(
instruction_ref
ins
)
const
{
return
assignments
.
at
(
ins
);
}
auto
&
at
(
instruction_ref
ins
)
const
{
return
assignments
.
at
(
ins
);
}
auto
insert
(
iterator
it
,
const
std
::
pair
<
instruction_ref
,
std
::
s
tring
>&
assignment
)
auto
insert
(
iterator
it
,
const
std
::
pair
<
instruction_ref
,
std
::
s
ize_t
>&
assignment
)
{
{
return
assignments
.
insert
(
it
,
assignment
);
return
assignments
.
insert
(
it
,
assignment
);
}
}
...
@@ -50,7 +50,7 @@ struct target_assignments
...
@@ -50,7 +50,7 @@ struct target_assignments
auto
end
()
const
{
return
assignments
.
end
();
}
auto
end
()
const
{
return
assignments
.
end
();
}
private:
private:
std
::
unordered_map
<
instruction_ref
,
std
::
s
tring
>
assignments
;
std
::
unordered_map
<
instruction_ref
,
std
::
s
ize_t
>
assignments
;
};
};
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace MIGRAPHX_INLINE_NS
...
...
src/program.cpp
View file @
b40c020a
...
@@ -178,6 +178,7 @@ It does it by first finding subgraphs supported on a given target based on assig
...
@@ -178,6 +178,7 @@ It does it by first finding subgraphs supported on a given target based on assig
It is possible that instructions have multiple target assignments and part of multiple subgraphs.
It is possible that instructions have multiple target assignments and part of multiple subgraphs.
Current logic is simple and assigns entire subgraph containing supported instruction to a particular
Current logic is simple and assigns entire subgraph containing supported instruction to a particular
target on first seen basis and doesn't find the "best" target assignment.
target on first seen basis and doesn't find the "best" target assignment.
Assumes that all instructions will have target_assignment after this.
*/
*/
target_assignments
program
::
get_target_assignments
(
const
std
::
vector
<
target
>&
targets
,
target_assignments
program
::
get_target_assignments
(
const
std
::
vector
<
target
>&
targets
,
assignment_options
options
)
assignment_options
options
)
...
@@ -187,13 +188,12 @@ target_assignments program::get_target_assignments(const std::vector<target>& ta
...
@@ -187,13 +188,12 @@ target_assignments program::get_target_assignments(const std::vector<target>& ta
target_assignments
p
;
target_assignments
p
;
const
auto
*
mod
=
get_main_module
();
const
auto
*
mod
=
get_main_module
();
std
::
vector
<
std
::
pair
<
targe
t
,
supported_segments
>>
target_subgraphs
;
std
::
vector
<
std
::
pair
<
std
::
size_
t
,
supported_segments
>>
target_subgraphs
;
target_subgraphs
.
reserve
(
targets
.
size
());
target_subgraphs
.
reserve
(
targets
.
size
());
std
::
transform
(
targets
.
begin
(),
for
(
auto
tid
:
range
(
targets
.
size
()))
targets
.
end
(),
{
std
::
back_inserter
(
target_subgraphs
),
target_subgraphs
.
push_back
(
std
::
make_pair
(
tid
,
targets
[
tid
].
find_supported
(
mod
,
m
)));
[
&
](
const
auto
&
t
)
{
return
std
::
make_pair
(
t
,
t
.
find_supported
(
mod
,
m
));
});
}
for
(
const
auto
ins
:
iterator_for
(
*
mod
))
for
(
const
auto
ins
:
iterator_for
(
*
mod
))
{
{
if
(
contains
(
p
,
ins
))
if
(
contains
(
p
,
ins
))
...
@@ -201,24 +201,24 @@ target_assignments program::get_target_assignments(const std::vector<target>& ta
...
@@ -201,24 +201,24 @@ target_assignments program::get_target_assignments(const std::vector<target>& ta
continue
;
continue
;
}
}
for
(
const
auto
&
[
t
arget
,
subgraph
]
:
target_subgraphs
)
for
(
const
auto
&
[
t
id
,
subgraph
]
:
target_subgraphs
)
{
{
// can't pass a structured binding into lambda in C++17 so create a variable for it
// can't pass a structured binding into lambda in C++17 so create a variable for it
const
auto
&
t
=
t
arget
;
const
auto
&
t
=
t
id
;
for
(
const
auto
&
segment
:
subgraph
)
for
(
const
auto
&
segment
:
subgraph
)
{
{
const
auto
&
instructions
=
segment
.
instructions
;
const
auto
&
instructions
=
segment
.
instructions
;
if
(
not
contains
(
instructions
,
ins
))
if
(
contains
(
instructions
,
ins
))
{
{
continue
;
std
::
transform
(
instructions
.
begin
(),
instructions
.
end
(),
std
::
inserter
(
p
,
p
.
end
()),
[
&
](
auto
instr
)
{
return
std
::
make_pair
(
instr
,
t
);
});
}
}
std
::
transform
(
instructions
.
begin
(),
instructions
.
end
(),
std
::
inserter
(
p
,
p
.
end
()),
[
&
](
auto
instr
)
{
return
std
::
make_pair
(
instr
,
t
.
name
());
});
}
}
}
}
}
}
return
p
;
return
p
;
}
}
...
...
test/fpga/get_target_assignments.cpp
View file @
b40c020a
...
@@ -56,7 +56,7 @@ TEST_CASE(is_supported)
...
@@ -56,7 +56,7 @@ TEST_CASE(is_supported)
for
(
const
auto
ins
:
iterator_for
(
*
mod
))
for
(
const
auto
ins
:
iterator_for
(
*
mod
))
{
{
const
auto
&
target
=
assignments
.
at
(
ins
);
const
auto
&
target
=
assignments
.
at
(
ins
);
EXPECT
(
target
==
"fpga"
);
EXPECT
(
target
==
0
);
}
}
}
}
...
...
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