Unverified Commit eb0d866d authored by Michał Karzyński's avatar Michał Karzyński Committed by GitHub

Replace static functions with anonymous namespaces (#4002)

parent e2673387
...@@ -23,9 +23,12 @@ ...@@ -23,9 +23,12 @@
#include "slice.hpp" #include "slice.hpp"
#include "utils/common.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 namespace ngraph
......
...@@ -27,34 +27,39 @@ ...@@ -27,34 +27,39 @@
#include "utils/common.hpp" #include "utils/common.hpp"
#include "utils/reshape.hpp" #include "utils/reshape.hpp"
/// \return Parse node attribute value for axis and adjust for negative value if needed. namespace
static std::int64_t get_axis(const ngraph::onnx_import::Node& node)
{ {
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 = node.get_ng_inputs().at(0);
auto data_rank = data->get_shape().size(); auto data_rank = data->get_shape().size();
return ngraph::onnx_import::common::validate_axis(node, axis, data_rank); return ngraph::onnx_import::common::validate_axis(node, axis, data_rank);
} }
/// \return Return the second input to the TopK node reshaped to a scalar. /// \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) std::shared_ptr<ngraph::Node> get_k(const ngraph::onnx_import::Node& node)
{ {
auto k_node = node.get_ng_inputs().at(1); auto k_node = node.get_ng_inputs().at(1);
NGRAPH_CHECK(shape_size(k_node->get_shape()) == 1, NGRAPH_CHECK(shape_size(k_node->get_shape()) == 1,
"ONNX TopK operator: 'K' parameter must contain a single positive value.", "ONNX TopK operator: 'K' parameter must contain a single positive value.",
node); 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. /// \return Return the outputs of the TopK node.
static ngraph::NodeVector get_outputs(const std::shared_ptr<ngraph::Node>& 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> values =
std::shared_ptr<ngraph::Node> indices = std::make_shared<ngraph::op::GetOutputElement>(node, 1); 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 namespace ngraph
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment