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
eb0d866d
Unverified
Commit
eb0d866d
authored
Dec 06, 2019
by
Michał Karzyński
Committed by
GitHub
Dec 06, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace static functions with anonymous namespaces (#4002)
parent
e2673387
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
24 deletions
+32
-24
slice.cpp
src/ngraph/frontend/onnx_import/op/slice.cpp
+5
-2
topk.cpp
src/ngraph/frontend/onnx_import/op/topk.cpp
+27
-22
No files found.
src/ngraph/frontend/onnx_import/op/slice.cpp
View file @
eb0d866d
...
...
@@ -23,9 +23,12 @@
#include "slice.hpp"
#include "utils/common.hpp"
static
inline
int64_t
get_valid_array_idx
(
int64_t
idx
,
int64_t
last_idx
)
namespace
{
return
(
idx
>=
0
)
?
std
::
min
(
idx
,
last_idx
)
:
std
::
max
<
int64_t
>
(
0
,
last_idx
+
idx
);
int64_t
get_valid_array_idx
(
int64_t
idx
,
int64_t
last_idx
)
{
return
(
idx
>=
0
)
?
std
::
min
(
idx
,
last_idx
)
:
std
::
max
<
int64_t
>
(
0
,
last_idx
+
idx
);
}
}
namespace
ngraph
...
...
src/ngraph/frontend/onnx_import/op/topk.cpp
View file @
eb0d866d
...
...
@@ -27,34 +27,39 @@
#include "utils/common.hpp"
#include "utils/reshape.hpp"
/// \return Parse node attribute value for axis and adjust for negative value if needed.
static
std
::
int64_t
get_axis
(
const
ngraph
::
onnx_import
::
Node
&
node
)
namespace
{
std
::
int64_t
axis
{
node
.
get_attribute_value
<
std
::
int64_t
>
(
"axis"
,
-
1
)};
/// \return Parse node attribute value for axis and adjust for negative value if needed.
std
::
int64_t
get_axis
(
const
ngraph
::
onnx_import
::
Node
&
node
)
{
std
::
int64_t
axis
{
node
.
get_attribute_value
<
std
::
int64_t
>
(
"axis"
,
-
1
)};
auto
data
=
node
.
get_ng_inputs
().
at
(
0
);
auto
data_rank
=
data
->
get_shape
().
size
();
return
ngraph
::
onnx_import
::
common
::
validate_axis
(
node
,
axis
,
data_rank
);
}
auto
data
=
node
.
get_ng_inputs
().
at
(
0
);
auto
data_rank
=
data
->
get_shape
().
size
();
return
ngraph
::
onnx_import
::
common
::
validate_axis
(
node
,
axis
,
data_rank
);
}
/// \return Return the second input to the TopK node reshaped to a scalar.
static
std
::
shared_ptr
<
ngraph
::
Node
>
get_k
(
const
ngraph
::
onnx_import
::
Node
&
node
)
{
auto
k_node
=
node
.
get_ng_inputs
().
at
(
1
);
NGRAPH_CHECK
(
shape_size
(
k_node
->
get_shape
())
==
1
,
"ONNX TopK operator: 'K' parameter must contain a single positive value."
,
node
);
/// \return Return the second input to the TopK node reshaped to a scalar.
std
::
shared_ptr
<
ngraph
::
Node
>
get_k
(
const
ngraph
::
onnx_import
::
Node
&
node
)
{
auto
k_node
=
node
.
get_ng_inputs
().
at
(
1
);
NGRAPH_CHECK
(
shape_size
(
k_node
->
get_shape
())
==
1
,
"ONNX TopK operator: 'K' parameter must contain a single positive value."
,
node
);
return
ngraph
::
onnx_import
::
reshape
::
interpret_as_scalar
(
k_node
);
}
return
ngraph
::
onnx_import
::
reshape
::
interpret_as_scalar
(
k_node
);
}
/// \return Return the outputs of the TopK node.
static
ngraph
::
NodeVector
get_outputs
(
const
std
::
shared_ptr
<
ngraph
::
Node
>&
node
)
{
std
::
shared_ptr
<
ngraph
::
Node
>
values
=
std
::
make_shared
<
ngraph
::
op
::
GetOutputElement
>
(
node
,
0
);
std
::
shared_ptr
<
ngraph
::
Node
>
indices
=
std
::
make_shared
<
ngraph
::
op
::
GetOutputElement
>
(
node
,
1
);
/// \return Return the outputs of the TopK node.
ngraph
::
NodeVector
get_outputs
(
const
std
::
shared_ptr
<
ngraph
::
Node
>&
node
)
{
std
::
shared_ptr
<
ngraph
::
Node
>
values
=
std
::
make_shared
<
ngraph
::
op
::
GetOutputElement
>
(
node
,
0
);
std
::
shared_ptr
<
ngraph
::
Node
>
indices
=
std
::
make_shared
<
ngraph
::
op
::
GetOutputElement
>
(
node
,
1
);
return
{
values
,
indices
};
return
{
values
,
indices
};
}
}
namespace
ngraph
...
...
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