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
a22b422a
Commit
a22b422a
authored
Nov 02, 2018
by
Paul
Browse files
Add test for operand alias
parent
d0575532
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
2 deletions
+18
-2
src/include/migraph/instruction.hpp
src/include/migraph/instruction.hpp
+2
-0
src/instruction.cpp
src/instruction.cpp
+14
-2
test/include/basic_ops.hpp
test/include/basic_ops.hpp
+2
-0
No files found.
src/include/migraph/instruction.hpp
View file @
a22b422a
...
...
@@ -69,6 +69,8 @@ struct instruction
static
void
replace
(
instruction_ref
ins
,
operation
o
,
const
shape
&
r
,
std
::
vector
<
instruction_ref
>
args
);
static
instruction_ref
get_output_alias
(
instruction_ref
ins
);
private:
// internal
void
replace
(
operation
o
,
const
shape
&
r
,
std
::
vector
<
instruction_ref
>
args
);
...
...
src/instruction.cpp
View file @
a22b422a
...
...
@@ -161,12 +161,24 @@ void instruction::replace_argument(instruction_ref old, instruction_ref new_ins)
old
->
remove_output
(
*
this
);
}
shape
compute_shape
(
const
operation
&
op
,
const
std
::
vector
<
instruction_ref
>&
args
)
std
::
vector
<
shape
>
compute_shape
s
(
const
std
::
vector
<
instruction_ref
>&
args
)
{
std
::
vector
<
shape
>
shapes
(
args
.
size
());
std
::
transform
(
args
.
begin
(),
args
.
end
(),
shapes
.
begin
(),
[](
instruction_ref
i
)
{
return
i
->
get_shape
();
});
return
op
.
compute_shape
(
shapes
);
return
shapes
;
}
instruction_ref
instruction
::
get_output_alias
(
instruction_ref
ins
)
{
auto
i
=
ins
->
get_operator
().
output_alias
(
compute_shapes
(
ins
->
inputs
()));
if
(
i
<
0
)
return
ins
;
return
get_output_alias
(
ins
->
inputs
().
at
(
i
));
}
shape
compute_shape
(
const
operation
&
op
,
const
std
::
vector
<
instruction_ref
>&
args
)
{
return
op
.
compute_shape
(
compute_shapes
(
args
));
}
}
// namespace migraph
test/include/basic_ops.hpp
View file @
a22b422a
...
...
@@ -79,6 +79,7 @@ struct pass_op
return
{};
return
inputs
.
front
();
}
int
output_alias
(
const
std
::
vector
<
migraph
::
shape
>&
)
const
{
return
0
;
}
};
struct
pass_standard_op
...
...
@@ -103,6 +104,7 @@ struct pass_standard_op
return
{};
return
inputs
.
front
();
}
int
output_alias
(
const
std
::
vector
<
migraph
::
shape
>&
)
const
{
return
0
;
}
};
struct
nop
...
...
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