Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
N
ngraph
Project
Project
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ngraph
Commits
04212bcb
Commit
04212bcb
authored
Dec 05, 2019
by
baojun
Committed by
Scott Cyphers
Dec 05, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Added reproducer for specialize_function (#3931)" (#3996)
This reverts commit
4a1e308a
.
parent
8adf78fe
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
41 deletions
+17
-41
get_output_element_elimination.cpp
src/ngraph/pass/get_output_element_elimination.cpp
+15
-10
get_output_element_elimination.hpp
src/ngraph/pass/get_output_element_elimination.hpp
+2
-2
specialize_function.cpp
src/ngraph/specialize_function.cpp
+0
-4
specialize_function.cpp
test/specialize_function.cpp
+0
-25
No files found.
src/ngraph/pass/get_output_element_elimination.cpp
View file @
04212bcb
...
...
@@ -18,25 +18,30 @@
#include "get_output_element_elimination.hpp"
#include "ngraph/graph_util.hpp"
#include "ngraph/log.hpp"
#include "ngraph/op/avg_pool.hpp"
#include "ngraph/op/broadcast.hpp"
#include "ngraph/op/constant.hpp"
#include "ngraph/op/convolution.hpp"
#include "ngraph/op/get_output_element.hpp"
#include "ngraph/op/max_pool.hpp"
#include "ngraph/op/pad.hpp"
#include "ngraph/op/product.hpp"
#include "ngraph/op/sum.hpp"
using
namespace
ngraph
;
using
namespace
std
;
bool
pass
::
GetOutputElementElimination
::
run_on_
function
(
shared_ptr
<
Function
>
f
)
bool
pass
::
GetOutputElementElimination
::
run_on_
node
(
shared_ptr
<
Node
>
n
)
{
bool
optimized
=
false
;
for
(
auto
&
n
:
f
->
get_op
s
())
for
(
auto
&
input
:
n
->
input
s
())
{
for
(
auto
&
input
:
n
->
inputs
(
))
if
(
auto
goe
=
dynamic_cast
<
op
::
GetOutputElement
*>
(
input
.
get_source_output
().
get_node
()
))
{
if
(
auto
goe
=
as_type
<
op
::
GetOutputElement
>
(
input
.
get_source_output
().
get_node
()))
{
input
.
replace_source_output
(
goe
->
input
(
0
).
get_source_output
());
// we don't need to fix anything w.r.t GetOutputElement as it will become
// unreachable
optimized
=
true
;
}
input
.
replace_source_output
(
goe
->
input
(
0
).
get_source_output
());
// we don't need to fix anything w.r.t GetOutputElement as it will become unreachable
optimized
=
true
;
}
}
return
optimized
;
...
...
src/ngraph/pass/get_output_element_elimination.hpp
View file @
04212bcb
...
...
@@ -26,8 +26,8 @@ namespace ngraph
}
}
class
NGRAPH_API
ngraph
::
pass
::
GetOutputElementElimination
:
public
Function
Pass
class
NGRAPH_API
ngraph
::
pass
::
GetOutputElementElimination
:
public
Node
Pass
{
public
:
bool
run_on_
function
(
std
::
shared_ptr
<
ngraph
::
Function
>
f
)
override
;
bool
run_on_
node
(
std
::
shared_ptr
<
Node
>
node
)
override
;
};
src/ngraph/specialize_function.cpp
View file @
04212bcb
...
...
@@ -16,7 +16,6 @@
#include "ngraph/specialize_function.hpp"
#include <pass/constant_folding.hpp>
#include <pass/get_output_element_elimination.hpp>
#include "ngraph/op/constant.hpp"
using
namespace
ngraph
;
...
...
@@ -121,8 +120,5 @@ std::shared_ptr<Function>
{
ngraph
::
pass
::
ConstantFolding
().
run_on_function
(
function
);
}
ngraph
::
pass
::
GetOutputElementElimination
().
run_on_function
(
function
);
return
function
;
}
test/specialize_function.cpp
View file @
04212bcb
...
...
@@ -362,28 +362,3 @@ TEST(specialize_function, share_constants_with_cf)
ASSERT_EQ
(
add_const_1
->
output
(
0
).
get_target_inputs
().
size
(),
1
);
ASSERT_EQ
(
add_const_2
->
output
(
0
).
get_target_inputs
().
size
(),
1
);
}
TEST
(
specialize_function
,
copy_network_with_split
)
{
auto
p0
=
std
::
make_shared
<
op
::
Parameter
>
(
element
::
f32
,
PartialShape
{
1
,
3
,
64
,
64
});
auto
split
=
std
::
make_shared
<
op
::
Split
>
(
p0
,
1
,
3
);
auto
res1
=
std
::
make_shared
<
op
::
Result
>
(
split
->
output
(
0
));
auto
res2
=
std
::
make_shared
<
op
::
Result
>
(
split
->
output
(
1
));
auto
res3
=
std
::
make_shared
<
op
::
Result
>
(
split
->
output
(
2
));
ResultVector
res
=
{
res1
,
res2
,
res3
};
auto
f
=
std
::
make_shared
<
Function
>
(
res
,
ParameterVector
{
p0
});
auto
f_specialized
=
specialize_function
(
f
,
{
element
::
f32
},
{
PartialShape
{
1
,
3
,
64
,
64
}},
{
nullptr
},
false
,
false
);
for
(
const
auto
&
op
:
f
->
get_ops
())
{
ASSERT_FALSE
(
is_type
<
op
::
GetOutputElement
>
(
op
));
}
for
(
const
auto
&
op
:
f_specialized
->
get_ops
())
{
ASSERT_FALSE
(
is_type
<
op
::
GetOutputElement
>
(
op
));
}
ASSERT_EQ
(
5
,
f
->
get_ops
().
size
());
ASSERT_EQ
(
f_specialized
->
get_ops
().
size
(),
f
->
get_ops
().
size
());
}
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