namespace ngraph

Overview

ngraph namespace More…

namespace ngraph {

// namespaces

namespace ngraph::builder;
namespace ngraph::descriptor;
    namespace ngraph::descriptor::layout;
namespace ngraph::element;
namespace ngraph::file_util;
namespace ngraph::onnx_import;
    namespace ngraph::onnx_import::detail;
    namespace ngraph::onnx_import::error;
        namespace ngraph::onnx_import::error::node;
namespace ngraph::op;
    namespace ngraph::op::internal;
    namespace ngraph::op::util;
        namespace ngraph::op::util::detail;
        namespace ngraph::op::util::error;
    namespace ngraph::op::v0;
    namespace ngraph::op::v1;
    namespace ngraph::op::v3;
    namespace ngraph::op::v4;
    namespace ngraph::op::v5;
    namespace ngraph::op::v6;
    namespace ngraph::op::v7;
namespace ngraph::opset1;
namespace ngraph::opset2;
namespace ngraph::opset3;
namespace ngraph::opset4;
namespace ngraph::opset5;
namespace ngraph::opset6;
namespace ngraph::opset7;
namespace ngraph::pass;
namespace ngraph::pattern;
    namespace ngraph::pattern::op;
namespace ngraph::reduction;
namespace ngraph::runtime;

// typedefs

typedef std::shared_ptr<runtime::HostTensor> HostTensorPtr;
typedef runtime::HostTensor HostTensor;
typedef std::vector<HostTensorPtr> HostTensorVector;
typedef std::map<std::string, std::shared_ptr<Variant>> EvaluationContext;
typedef std::vector<std::shared_ptr<op::v0::Result>> ResultVector;
typedef std::unordered_map<ngraph::Node*, std::shared_ptr<ngraph::Node>> NodeMap;
typedef Node::type_info_t NodeTypeInfo;
typedef std::map<RawNodeOutput, Output<Node>> RawNodeOutputMap;
typedef std::vector<std::shared_ptr<op::Parameter>> ParameterVector;
typedef std::vector<std::shared_ptr<op::Sink>> SinkVector;
typedef std::shared_ptr<Variable> VariablePtr;
typedef std::vector<VariablePtr> VariableVector;
typedef std::shared_ptr<VariableValue> VariableValuePtr;
typedef std::unordered_map<VariablePtr, VariableValuePtr> VariableMap;
typedef std::vector<std::shared_ptr<Node>> NodeVector;
typedef std::vector<Output<Node>> OutputVector;
typedef std::function<bool(ngraph::pattern::Matcher&m)> matcher_pass_callback;
typedef std::function<bool(ngraph::pattern::Matcher&m)> graph_rewrite_callback;
typedef std::function<bool(ngraph::pattern::RecurrentMatcher&m)> recurrent_graph_rewrite_callback;
typedef std::function<bool(const std::shared_ptr<Node>&node)> handler_callback;
typedef Dimension Rank;
typedef typename element_type_traits<Type>::value_type fundamental_type_for;
typedef DiscreteTypeInfo VariantTypeInfo;

// enums

enum LOG_TYPE;

// structs

struct CheckLocInfo;
struct DiscreteTypeInfo;
struct NullLogger;
struct RawNodeOutput;
struct SlicePlan;
struct VariableInfo;
template <>
struct element_type_traits<element::Type_t::f32>;
template <>
struct element_type_traits<element::Type_t::u64>;
template <>
struct element_type_traits<element::Type_t::u4>;
template <>
struct element_type_traits<element::Type_t::u32>;
template <>
struct element_type_traits<element::Type_t::u8>;
template <element::Type_t>
struct element_type_traits;
template <>
struct element_type_traits<element::Type_t::bf16>;
template <>
struct element_type_traits<element::Type_t::f16>;
template <>
struct element_type_traits<element::Type_t::u16>;
template <>
struct element_type_traits<element::Type_t::i8>;
template <>
struct element_type_traits<element::Type_t::i16>;
template <>
struct element_type_traits<element::Type_t::f64>;
template <>
struct element_type_traits<element::Type_t::u1>;
template <>
struct element_type_traits<element::Type_t::i32>;
template <>
struct element_type_traits<element::Type_t::boolean>;
template <>
struct element_type_traits<element::Type_t::i4>;
template <>
struct element_type_traits<element::Type_t::i64>;

// classes

template <typename AT>
class AttributeAdapter;
template <>
class AttributeAdapter<ResultVector>;
template <>
class AttributeAdapter<reduction::Type>;
template <>
class AttributeAdapter<PartialShape>;
template <>
class AttributeAdapter<Shape>;
template <>
class AttributeAdapter<std::shared_ptr<Node>>;
template <>
class AttributeAdapter<std::shared_ptr<Function>>;
template <>
class AttributeAdapter<std::shared_ptr<runtime::AlignedBuffer>>;
template <>
class AttributeAdapter<std::shared_ptr<Variable>>;
template <>
class AttributeAdapter<ParameterVector>;
template <>
class AttributeAdapter<op::v5::NonMaxSuppression::BoxEncodingType>;
template <>
class AttributeAdapter<op::v4::Interpolate::InterpolateMode>;
template <>
class AttributeAdapter<op::v4::Interpolate::CoordinateTransformMode>;
template <>
class AttributeAdapter<op::v5::Round::RoundMode>;
template <>
class AttributeAdapter<op::v4::Interpolate::NearestMode>;
template <>
class AttributeAdapter<op::v5::Loop::SpecialBodyPorts>;
template <>
class AttributeAdapter<op::v4::Interpolate::ShapeCalcMode>;
template <>
class AttributeAdapter<op::v3::ROIAlign::PoolingMode>;
template <>
class AttributeAdapter<std::string>;
template <>
class AttributeAdapter<std::vector<float>>;
template <>
class AttributeAdapter<Strides>;
template <>
class AttributeAdapter<std::vector<uint8_t>>;
template <>
class AttributeAdapter<std::vector<uint64_t>>;
template <>
class AttributeAdapter<uint16_t>;
template <>
class AttributeAdapter<uint64_t>;
template <>
class AttributeAdapter<uint32_t>;
template <>
class AttributeAdapter<uint8_t>;
template <>
class AttributeAdapter<std::vector<double>>;
template <>
class AttributeAdapter<std::vector<uint16_t>>;
template <>
class AttributeAdapter<std::vector<std::shared_ptr<ngraph::op::util::SubGraphOp::OutputDescription>>>;
template <>
class AttributeAdapter<std::vector<int32_t>>;
template <>
class AttributeAdapter<std::vector<int16_t>>;
template <>
class AttributeAdapter<std::vector<std::string>>;
template <>
class AttributeAdapter<std::vector<int64_t>>;
template <>
class AttributeAdapter<std::vector<std::shared_ptr<ngraph::op::util::SubGraphOp::InputDescription>>>;
template <>
class AttributeAdapter<std::vector<int8_t>>;
template <>
class AttributeAdapter<op::v3::NonMaxSuppression::BoxEncodingType>;
template <>
class AttributeAdapter<std::vector<uint32_t>>;
template <>
class AttributeAdapter<op::v1::NonMaxSuppression::BoxEncodingType>;
template <>
class AttributeAdapter<int16_t>;
template <>
class AttributeAdapter<float>;
template <>
class AttributeAdapter<element::Type_t>;
template <>
class AttributeAdapter<int32_t>;
template <>
class AttributeAdapter<NodeVector>;
template <>
class AttributeAdapter<int8_t>;
template <>
class AttributeAdapter<op::AutoBroadcastSpec>;
template <>
class AttributeAdapter<op::AutoBroadcastType>;
template <>
class AttributeAdapter<op::v1::Reverse::Mode>;
template <>
class AttributeAdapter<double>;
template <>
class AttributeAdapter<AxisVector>;
template <>
class AttributeAdapter<AxisSet>;
template <>
class AttributeAdapter<element::Type>;
template <>
class AttributeAdapter<bool>;
template <>
class AttributeAdapter<CoordinateDiff>;
template <>
class AttributeAdapter<Coordinate>;
template <>
class AttributeAdapter<op::BroadcastModeSpec>;
template <>
class AttributeAdapter<int64_t>;
template <>
class AttributeAdapter<op::EpsMode>;
template <>
class AttributeAdapter<op::TopKSortType>;
template <>
class AttributeAdapter<op::TopKMode>;
template <>
class AttributeAdapter<op::RoundingType>;
template <>
class AttributeAdapter<op::BroadcastType>;
template <>
class AttributeAdapter<op::v0::SpaceToDepth::SpaceToDepthMode>;
template <>
class AttributeAdapter<op::v0::Interpolate::InterpolateMode>;
template <>
class AttributeAdapter<op::v1::BinaryConvolution::BinaryConvolutionMode>;
template <>
class AttributeAdapter<op::RecurrentSequenceDirection>;
template <>
class AttributeAdapter<op::v0::DepthToSpace::DepthToSpaceMode>;
template <>
class AttributeAdapter<op::PadMode>;
template <>
class AttributeAdapter<op::GeluApproximationMode>;
template <>
class AttributeAdapter<op::FrameworkNodeAttrs>;
template <>
class AttributeAdapter<op::PadType>;
template <>
class AttributeAdapter<op::MVNEpsMode>;
template <>
class AttributeAdapter<op::LSTMWeightsFormat>;
class AttributeVisitor;
class AxisSet;
class AxisVector;
class CheckFailure;
class ConstString;
class Coordinate;
class CoordinateDiff;
class DequantizationAttr;
class Dimension;
template <typename AT>
class DirectValueAccessor;
template <typename AT>
class EnumAttributeAdapterBase;
template <typename T>
class EnumMask;
template <typename EnumType>
class EnumNames;
template <typename V>
class Evaluator;
template <typename BASE_TYPE>
class FactoryAttributeAdapter;
template <typename BASE_TYPE>
class FactoryRegistry;
class Function;
class FusedNames;
template <typename AT, typename VAT>
class IndirectScalarValueAccessor;
template <typename AT, typename VAT>
class IndirectVectorValueAccessor;
template <>
class Input<Node>;
template <typename NodeType>
class Input;
template <>
class Input<const Node>;
class Interval;
class LogHelper;
class Logger;
class Node;
class NodeValidationFailure;
class OpSet;
template <>
class Output<const Node>;
template <typename NodeType>
class Output;
template <>
class Output<Node>;
class PartialShape;
class PrimitivesPriority;
class Shape;
class Strides;
template <typename VAT>
class ValueAccessor;
template <>
class ValueAccessor<void*>;
template <>
class ValueAccessor<void>;
class Variable;
class VariableContext;
class VariableExtension;
class VariableValue;
class Variant;
template <typename VT>
class VariantImpl;
template <>
class VariantWrapper<PrimitivesPriority>;
template <>
class VariantWrapper<FusedNames>;
template <>
class VariantWrapper<DequantizationAttr>;
template <>
class VariantWrapper<std::string>;
template <>
class VariantWrapper<int64_t>;
template <typename VT>
class VariantWrapper;
template <>
class VariantWrapper<VariableContext>;
class VisitorAdapter;
class bfloat16;
class float16;
class ngraph_error;
class stopwatch;
class unsupported_op;

// global variables

template class NGRAPH_API VariantImpl< int64_t >;

// global functions

std::string getDequantization(const std::shared_ptr<ngraph::Node>& node);
std::string getFusedNames(const std::shared_ptr<ngraph::Node>& node);
std::vector<std::string> getFusedNamesVector(const std::shared_ptr<ngraph::Node>& node);
std::string getPrimitivesPriority(const std::shared_ptr<ngraph::Node>& node);

template <typename A, typename B>
A copy_from(B& b);

NGRAPH_API std::ostream& operator << (std::ostream& s, const AxisSet& axis_set);

NGRAPH_API std::ostream& operator << (
    std::ostream& s,
    const AxisVector& axis_vector
    );

static std::ostream& write_all_to_stream(std::ostream& str);

template <typename T, typename... TS>
static std::ostream& write_all_to_stream(
    std::ostream& str,
    const T& arg,
    TS&&... args
    );

NGRAPH_API std::ostream& operator << (
    std::ostream& s,
    const Coordinate& coordinate
    );

NGRAPH_API std::ostream& operator << (
    std::ostream& s,
    const CoordinateDiff& coordinate_diff
    );

NGRAPH_API std::ostream& operator << (
    std::ostream& str,
    const Dimension& dimension
    );

template <typename Type, typename Value>
std::enable_if<std::is_convertible<Value, std::string>::value, Type>::type as_enum(const Value& value);

template <typename Value>
const std::string& as_string(Value value);

NGRAPH_API std::string getenv_string(const char* env_var);
NGRAPH_API int32_t getenv_int(const char* env_var, int32_t default_value = -1);
NGRAPH_API bool getenv_bool(const char* env_var, bool default_value = false);
NGRAPH_API std::mutex& get_registry_mutex();

NGRAPH_API void traverse_nodes(
    const std::shared_ptr<const Function> p,
    std::function<void(std::shared_ptr<Node>)> f
    );

NGRAPH_API void traverse_nodes(
    const Function* p,
    std::function<void(std::shared_ptr<Node>)> f
    );

NGRAPH_API void traverse_nodes(
    const NodeVector& subgraph_results,
    std::function<void(std::shared_ptr<Node>)> f,
    const NodeVector& subgraph_params = {}
    );

NGRAPH_API void replace_node(
    std::shared_ptr<Node> target,
    std::shared_ptr<Node> replacement,
    const std::vector<int64_t>& output_order
    );

NGRAPH_API void replace_node(
    const std::shared_ptr<Node>& target,
    const OutputVector& replacement_values
    );

NGRAPH_API void replace_node(
    std::shared_ptr<Node> target,
    std::shared_ptr<Node> replacement
    );

NGRAPH_API void replace_nodes(
    const std::shared_ptr<Function>& f,
    const std::unordered_map<std::shared_ptr<op::v0::Parameter>, std::shared_ptr<op::v0::Parameter>>& parameter_replacement_map,
    const std::unordered_map<std::shared_ptr<Node>, std::shared_ptr<Node>>& body_replacement_map
    );

NGRAPH_API NodeVector find_common_args(
    std::shared_ptr<Node> target,
    std::shared_ptr<Node> replacement
    );

template <typename T>
std::vector<std::shared_ptr<Node>> topological_sort(T root_nodes);

template <typename T>
std::vector<std::shared_ptr<Node>> subgraph_topological_sort(T nodes);

template <typename T>
void validate_nodes_and_infer_types(const T& nodes);

NGRAPH_API bool is_post_dominated(Node* X, Node* Y);

NGRAPH_API bool is_equal_to_const_value(
    std::string const_value,
    const Output<Node>& reduce_constant
    );

NGRAPH_API std::vector<std::shared_ptr<ngraph::Node>> clone_nodes(
    const std::vector<std::shared_ptr<ngraph::Node>>& nodes,
    NodeMap& node_map
    );

NGRAPH_API std::list<std::shared_ptr<ngraph::Node>> clone_nodes(
    const std::vector<std::shared_ptr<ngraph::Node>>& nodes,
    RawNodeOutputMap& node_map
    );

NGRAPH_API std::shared_ptr<ngraph::Function> clone_function(
    const ngraph::Function& func,
    NodeMap& node_map
    );

NGRAPH_API std::shared_ptr<ngraph::Function> clone_function(const ngraph::Function& func);

NGRAPH_API std::pair<std::shared_ptr<op::Result>, std::shared_ptr<op::v0::Parameter>> insert_result_parameter_split(
    const std::shared_ptr<Node>& src_node,
    const std::shared_ptr<Node>& dst_node
    );

NGRAPH_API void insert_new_node_between(
    const std::shared_ptr<Node>& src_node,
    const std::shared_ptr<Node>& dst_node,
    const std::shared_ptr<Node>& new_node
    );

NGRAPH_API std::shared_ptr<Node> make_zero(
    const element::Type& element_type,
    const Shape& shape
    );

NGRAPH_API std::shared_ptr<Node> make_constant_from_string(
    std::string val,
    const element::Type& element_type,
    const Shape& shape
    );

NGRAPH_API bool is_zero(const Output<Node>& reduce_constant);

NGRAPH_API NodeVector get_subgraph_outputs(
    const NodeVector& nodes,
    const NodeVector& exclusions,
    bool ignore_unused = false,
    bool ignore_output_duplicates = true
    );

NGRAPH_API NodeVector extract_subgraph(
    const NodeVector& results,
    const NodeVector& args
    );

NGRAPH_API bool is_one(const Output<Node>& reduce_constant);

NGRAPH_API bool compare_constants(
    const std::shared_ptr<Node>& n1,
    const std::shared_ptr<Node>& n2
    );

NGRAPH_API bool is_used(Node* node);
NGRAPH_API size_t get_user_count(Node* node);
NGRAPH_API bool possibly_overwritten(Node* node);
NGRAPH_API bool is_strided(const Strides& strides);

NGRAPH_API bool is_valid_rank(
    const std::shared_ptr<Node>& node,
    std::vector<size_t> valid_ranks
    );

NGRAPH_API void plot_graph(
    std::shared_ptr<Function> f,
    const std::string& filename,
    std::function<void(const Node&node, std::vector<std::string>&attributes)> = nullptr
    );

NGRAPH_API std::vector<Input<Node>> get_inputs_from(Node& src, Node& dst);
NGRAPH_API std::vector<Output<Node>> get_outputs_to(Node& src, Node& dst);

NGRAPH_API bool check_for_cycles(
    const ngraph::Function* func,
    ngraph::NodeVector& cycle_nodes,
    bool& is_bkwd_cycle
    );

NGRAPH_API bool replace_output_update_name(
    Output<Node> node,
    const Output<Node>& node_input
    );

NGRAPH_API bool replace_node_update_name(
    std::shared_ptr<Node> target,
    std::shared_ptr<Node> replacement
    );

NGRAPH_API std::ostream& operator << (std::ostream& str, const Interval& interval);
constexpr const char* find_last(ConstString s, size_t offset, char ch);
constexpr const char* find_last(ConstString s, char ch);
constexpr const char* get_file_name(ConstString s);
constexpr const char* trim_file_name(ConstString root, ConstString s);
NGRAPH_API void default_logger_handler_func(const std::string& s);

template <typename T>
NullLogger&& operator << (NullLogger&& logger, T&&);

template <typename T>
NullLogger&& operator << (NullLogger&& logger, const T&);

NullLogger&& operator << (
    NullLogger&& logger,
    std::basic_ostream<char, std::char_traits<char>>&&)(std::basic_ostream< char, std::char_traits< char > > &
    );

NGRAPH_API void get_version(
    size_t& major,
    size_t& minor,
    size_t& patch,
    std::string& extra
    );

NGRAPH_API std::string node_validation_failure_loc_string(const Node* node);

const std::shared_ptr<Node>& check_single_output_arg(
    const std::shared_ptr<Node>& node,
    size_t i
    );

NGRAPH_API const NodeVector& check_single_output_args(const NodeVector& args);
NGRAPH_API OutputVector as_output_vector(const NodeVector& args);
NGRAPH_API NodeVector as_node_vector(const OutputVector& values);
NGRAPH_API ResultVector as_result_vector(const OutputVector& values);
NGRAPH_API std::ostream& operator << (std::ostream&, const Node&);
NGRAPH_API std::ostream& operator << (std::ostream&, const Node*);

template <typename T>
void check_new_args_count(const Node* node, T new_args);

NGRAPH_API std::ostream& operator << (std::ostream& out, const Input<Node>& input);

NGRAPH_API std::ostream& operator << (
    std::ostream& out,
    const Input<const Node>& input
    );

NGRAPH_API std::ostream& operator << (
    std::ostream& out,
    const Output<Node>& output
    );

NGRAPH_API std::ostream& operator << (
    std::ostream& out,
    const Output<const Node>& output
    );

NGRAPH_API std::ostream& operator << (
    std::ostream& s,
    const op::v1::BinaryConvolution::BinaryConvolutionMode& type
    );

NGRAPH_API std::ostream& operator << (
    std::ostream& s,
    const op::v0::DepthToSpace::DepthToSpaceMode& type
    );

NGRAPH_API std::ostream& operator << (
    std::ostream& s,
    const op::v0::Interpolate::InterpolateMode& type
    );

NGRAPH_API std::ostream& operator << (
    std::ostream& s,
    const op::v4::Interpolate::InterpolateMode& type
    );

NGRAPH_API std::ostream& operator << (
    std::ostream& s,
    const op::v4::Interpolate::CoordinateTransformMode& type
    );

NGRAPH_API std::ostream& operator << (
    std::ostream& s,
    const op::v4::Interpolate::NearestMode& type
    );

NGRAPH_API std::ostream& operator << (
    std::ostream& s,
    const op::v4::Interpolate::ShapeCalcMode& type
    );

NGRAPH_API std::ostream& operator << (
    std::ostream& s,
    const op::LSTMWeightsFormat& type
    );

NGRAPH_API std::shared_ptr<Node> operator - (const Output<Node>& arg0);

NGRAPH_API std::ostream& operator << (
    std::ostream& s,
    const op::v1::NonMaxSuppression::BoxEncodingType& type
    );

NGRAPH_API std::ostream& operator << (
    std::ostream& s,
    const op::v3::NonMaxSuppression::BoxEncodingType& type
    );

NGRAPH_API std::ostream& operator << (
    std::ostream& s,
    const op::v5::NonMaxSuppression::BoxEncodingType& type
    );

NGRAPH_API std::ostream& operator << (
    std::ostream& s,
    const op::v1::Reverse::Mode& type
    );

std::ostream& operator << (
    std::ostream& s,
    const op::v3::ROIAlign::PoolingMode& mode
    );

NGRAPH_API std::ostream& operator << (
    std::ostream& s,
    const op::v5::Round::RoundMode& type
    );

NGRAPH_API std::ostream& operator << (
    std::ostream& s,
    const op::v0::SpaceToDepth::SpaceToDepthMode& type
    );

const NGRAPH_API OpSet& get_opset1();
const NGRAPH_API OpSet& get_opset2();
const NGRAPH_API OpSet& get_opset3();
const NGRAPH_API OpSet& get_opset4();
const NGRAPH_API OpSet& get_opset5();
const NGRAPH_API OpSet& get_opset6();
const NGRAPH_API OpSet& get_opset7();
PartialShape operator + (const PartialShape& s1, const PartialShape& s2);

NGRAPH_API std::ostream& operator << (
    std::ostream& str,
    const PartialShape& shape
    );

NGRAPH_API void set_provenance_enabled(bool enabled);
NGRAPH_API bool get_provenance_enabled();

NGRAPH_API void copy_runtime_info(
    std::shared_ptr<ngraph::Node> from,
    std::shared_ptr<ngraph::Node> to
    );

NGRAPH_API void copy_runtime_info(
    std::shared_ptr<ngraph::Node> from,
    ngraph::NodeVector to
    );

NGRAPH_API void copy_runtime_info(
    const ngraph::NodeVector& from,
    std::shared_ptr<ngraph::Node> to
    );

NGRAPH_API void copy_runtime_info(
    const ngraph::NodeVector& from,
    ngraph::NodeVector to
    );

template <typename SHAPE_TYPE>
size_t shape_size(const SHAPE_TYPE& shape);

template <typename SHAPE_TYPE>
std::vector<size_t> row_major_strides(const SHAPE_TYPE& shape);

template <typename SHAPE_TYPE>
size_t row_major_stride(
    const SHAPE_TYPE& shape,
    size_t axis
    );

template <typename SHAPE_TYPE>
bool is_scalar(const SHAPE_TYPE& shape);

template <typename SHAPE_TYPE>
bool is_vector(const SHAPE_TYPE& shape);

NGRAPH_API std::ostream& operator << (std::ostream& s, const Shape& shape);

template <typename AXIS_VALUES>
AXIS_VALUES project(
    const AXIS_VALUES& axis_values,
    const AxisSet& axes
    );

NGRAPH_API PartialShape project(const PartialShape& shape, const AxisSet& axes);

template <typename AXIS_VALUES>
AXIS_VALUES reduce(
    const AXIS_VALUES& axis_values,
    const AxisSet& deleted_axes,
    bool keep_dims
    );

NGRAPH_API PartialShape reduce(
    const PartialShape& shape,
    const AxisSet& deleted_axes,
    bool keep_dims
    );

template <typename AXIS_VALUES, typename AXIS_VALUE>
AXIS_VALUES inject_pairs(
    const AXIS_VALUES& axis_values,
    std::vector<std::pair<size_t, AXIS_VALUE>> new_axis_pos_value_pairs
    );

NGRAPH_API PartialShape inject_pairs(
    const PartialShape& shape,
    std::vector<std::pair<size_t, Dimension>> new_axis_pos_value_pairs
    );

template <typename AXIS_VALUES, typename AXIS_VALUE>
AXIS_VALUES inject(
    const AXIS_VALUES& axis_values,
    size_t new_axis_pos,
    AXIS_VALUE new_axis_val
    );

SlicePlan NGRAPH_API make_slice_plan(
    const Shape& input_shape,
    const std::vector<int64_t>& begins,
    const std::vector<int64_t>& ends,
    const std::vector<int64_t>& strides,
    const AxisSet& lower_bounds_mask,
    const AxisSet& upper_bounds_mask,
    const AxisSet& new_axis_mask,
    const AxisSet& shrink_axis_mask,
    const AxisSet& ellipsis_mask
    );

NGRAPH_API std::shared_ptr<Function> specialize_function(
    std::shared_ptr<Function> f,
    const std::vector<element::Type>& parameter_element_types,
    const std::vector<PartialShape>& parameter_shapes,
    const std::vector<void*>& parameter_values
    );

NGRAPH_API std::ostream& operator << (std::ostream& s, const Strides& strides);
bool ::type is_type(Value value);
Type*::type as_type(Value value);
std::enable_if<std::is_convertible<decltype(std::static_pointer_cast<Type>(std::declval<Value>())), std::shared_ptr<Type> std::shared_ptr<Type> ::type as_type_ptr(Value value);
size_t compiler_byte_size(element::Type_t et);

template <typename T>
std::string join(
    const T& v,
    const std::string& sep = ", "
    );

template <typename T>
std::string vector_to_string(const T& v);

NGRAPH_API size_t hash_combine(const std::vector<size_t>& list);
NGRAPH_API void dump(std::ostream& out, const void*, size_t);
NGRAPH_API std::string to_lower(const std::string& s);
NGRAPH_API std::string to_upper(const std::string& s);
NGRAPH_API std::string trim(const std::string& s);

NGRAPH_API std::vector<std::string> split(
    const std::string& s,
    char delimiter,
    bool trim = false
    );

template <typename T>
std::string locale_string(T x);

template <typename T>
T parse_string(const std::string& s);

NGRAPH_API float parse_string< float >(const std::string& s);
NGRAPH_API double parse_string< double >(const std::string& s);
NGRAPH_API int8_t parse_string< int8_t >(const std::string& s);
NGRAPH_API uint8_t parse_string< uint8_t >(const std::string& s);

template <typename T>
std::vector<T> parse_string(const std::vector<std::string>& ss);

template <typename T>
T ceil_div(const T& x, const T& y);

template <typename T>
T subtract_or_zero(T x, T y);

NGRAPH_API void* ngraph_malloc(size_t size);
NGRAPH_API void ngraph_free(void*);
NGRAPH_API size_t round_up(size_t size, size_t alignment);

bool is_valid_permutation(
    ngraph::AxisVector permutation,
    ngraph::Rank rank = Rank::dynamic()
    );

template <typename T>
T apply_permutation(T input, ngraph::AxisVector order);

template NGRAPH_API AxisVector apply_permutation< AxisVector >(
    AxisVector input,
    AxisVector order
    );

template NGRAPH_API Coordinate apply_permutation< Coordinate >(
    Coordinate input,
    AxisVector order
    );

template NGRAPH_API Strides apply_permutation< Strides >(Strides input, AxisVector order);
template NGRAPH_API Shape apply_permutation< Shape >(Shape input, AxisVector order);
NGRAPH_API PartialShape apply_permutation(PartialShape input, AxisVector order);
NGRAPH_API AxisVector get_default_order(size_t rank);
NGRAPH_API AxisVector get_default_order(const Rank& rank);
NGRAPH_API AxisVector get_default_order(const Shape& shape);
NGRAPH_API AxisVector get_default_order(const PartialShape& shape);

NGRAPH_API void parse_version_string(
    std::string version,
    size_t& major,
    size_t& minor,
    size_t& patch,
    std::string& extra
    );

template <typename T>
T double_to_int(
    double x,
    double  float_to_int_converterdouble
    );

NGRAPH_API Strides conv_default_strides(
    const Node* node,
    const PartialShape& data_batch_shape,
    const PartialShape& filters_shape
    );

NGRAPH_API CoordinateDiff conv_default_padding(
    const Node* node,
    const PartialShape& data_batch_shape,
    const PartialShape& filters_shape
    );

NGRAPH_API PartialShape infer_windowed_reduction_output_shape(
    const Node* node,
    const PartialShape& data_shape,
    const Strides& data_dilation,
    const CoordinateDiff& data_padding_below,
    const CoordinateDiff& data_padding_above,
    const PartialShape& window_shape,
    const Strides& window_strides,
    const Strides& window_dilation,
    bool is_window_all_in_padding_allowed,
    bool ceil_mode = false
    );

void validate_conv_params_spatial_dimensions(
    const Node* node,
    const size_t num_spatial_dims,
    const op::PadType auto_pad,
    Strides& strides,
    Strides& dilations,
    CoordinateDiff& pads_begin,
    CoordinateDiff& pads_end
    );

PartialShape validate_and_infer_convolution_forward_output_shape(
    const Node* node,
    const Rank& result_ps_rank,
    const PartialShape& data_batch_pshape,
    const PartialShape& filters_pshape,
    const op::PadType auto_pad,
    Strides& strides,
    Strides& dilations,
    CoordinateDiff& pads_begin,
    CoordinateDiff& pads_end
    );

NGRAPH_API PartialShape infer_convolution_forward(
    const Node* node,
    const PartialShape& data_batch_shape,
    const Strides& data_dilation,
    const CoordinateDiff& data_padding_below,
    const CoordinateDiff& data_padding_above,
    const PartialShape& filters_shape,
    const Strides& filter_strides,
    const Strides& filter_dilation
    );

NGRAPH_API PartialShape infer_batched_pooling_forward(
    const Node* node,
    const PartialShape& data_batch_shape,
    const CoordinateDiff& data_padding_below,
    const CoordinateDiff& data_padding_above,
    const PartialShape& window_shape,
    const Strides& window_strides,
    bool is_window_all_in_padding_allowed,
    bool ceil_mode = false
    );

NGRAPH_API std::tuple<element::Type, PartialShape, PartialShape> infer_batch_norm_forward(
    const Node* node,
    element::Type input_element_type,
    element::Type gamma_element_type,
    element::Type beta_element_type,
    element::Type mean_element_type,
    element::Type variance_element_type,
    const PartialShape& input_shape,
    const PartialShape& gamma_shape,
    const PartialShape& beta_shape,
    const PartialShape& mean_shape,
    const PartialShape& variance_shape
    );

NGRAPH_API std::tuple<element::Type, PartialShape, PartialShape> infer_batch_norm_forward(
    const Node* node,
    element::Type input_element_type,
    element::Type gamma_element_type,
    element::Type beta_element_type,
    const PartialShape& input_shape,
    const PartialShape& gamma_shape,
    const PartialShape& beta_shape
    );

NGRAPH_API bool try_apply_auto_padding(
    const PartialShape& image_shape,
    const Shape& filter_shape,
    const Strides& filter_strides,
    const Strides& filter_dilations,
    const op::PadType pad_type,
    CoordinateDiff& padding_above,
    CoordinateDiff& padding_below
    );

NGRAPH_API void infer_auto_padding(
    const Shape& image_shape,
    const Shape& filter_shape,
    const Strides& filter_strides,
    const Strides& filter_dilations,
    const op::PadType pad_type,
    CoordinateDiff& padding_above,
    CoordinateDiff& padding_below
    );

NGRAPH_API PartialShape infer_slice_shape(
    const Node* node,
    const PartialShape& input_shape,
    const std::vector<int64_t>& begin,
    const std::vector<int64_t>& end,
    const std::vector<int64_t>& strides,
    const AxisSet& begin_mask,
    const AxisSet& end_mask,
    const AxisSet& new_axis_mask,
    const AxisSet& shrink_axis_mask,
    const AxisSet& ellipsis_mask
    );

NGRAPH_API int64_t normalize_axis(
    const Node* node,
    std::int64_t axis,
    const Rank& tensor_rank
    );

NGRAPH_API std::vector<size_t> normalize_axes(
    const std::string& node_description,
    const std::vector<int64_t>& axes,
    const Rank& tensor_rank
    );

NGRAPH_API int64_t normalize_axis(
    const std::string& node_description,
    std::int64_t axis,
    const Rank& tensor_rank
    );

NGRAPH_API int64_t normalize_axis(
    const Node* node,
    std::int64_t axis,
    std::uint64_t tensor_rank,
    std::int64_t axis_range_min,
    std::int64_t axis_range_max
    );

NGRAPH_API int64_t normalize_axis(
    const std::string& node_description,
    std::int64_t axis,
    std::uint64_t tensor_rank,
    std::int64_t axis_range_min,
    std::int64_t axis_range_max
    );

NGRAPH_API std::pair<bool, uint64_t> maximum_value(const Output<Node>& value);

NGRAPH_API void evaluate_nodes(
    std::map<RawNodeOutput, HostTensorPtr>& value_map,
    std::map<RawNodeOutput, HostTensorPtr>& output_tensor_map,
    const OutputVector& outputs,
    const EvaluationContext& evaluation_context = EvaluationContext()
    );

NGRAPH_API HostTensorPtr evaluate_lower_bound(const Output<Node>& output);
NGRAPH_API HostTensorPtr evaluate_upper_bound(const Output<Node>& output);
NGRAPH_API std::pair<HostTensorPtr, HostTensorPtr> evaluate_both_bounds(const Output<Node>& output);

NGRAPH_API bool evaluate_as_partial_shape(
    const Output<Node>& output,
    PartialShape& pshape
    );

NGRAPH_API bool default_upper_bound_evaluator(
    const Node* node,
    const HostTensorVector& output_values
    );

NGRAPH_API bool default_lower_bound_evaluator(
    const Node* node,
    const HostTensorVector& output_values
    );

NGRAPH_API bool interval_bound_evaluator(
    const Node* node,
    const HostTensorVector& lower_output_values,
    const HostTensorVector& upper_output_values
    );

NGRAPH_API bool host_tensor_is_positive(const HostTensorPtr& bound);
NGRAPH_API bool has_and_set_equal_bounds(const Output<Node>& source);
NGRAPH_API std::shared_ptr<op::Constant> get_constant_from_source(const Output<Node>& source);
NGRAPH_API std::shared_ptr<op::Constant> get_constant_max_of_type(element::Type_t t);
NGRAPH_API std::shared_ptr<op::Constant> get_constant_min_of_type(element::Type_t t);

NGRAPH_API bool validate_host_tensor_vector(
    const HostTensorVector& v,
    const size_t& size
    );

} // namespace ngraph

Detailed Documentation

ngraph namespace

Top level nGraph namespace.

The Intel nGraph C++ API.

nGraph C++ API

Typedefs

typedef std::map<std::string, std::shared_ptr<Variant>> EvaluationContext

EvaluationContext stores and manages a context (additional parameters, values and environment) for evaluating ngraph::function.

typedef std::unordered_map<ngraph::Node*, std::shared_ptr<ngraph::Node>> NodeMap

Alias useful for cloning.

typedef Dimension Rank

Alias for Dimension, used when the value represents the number of axes in a shape, rather than the size of one dimension in a shape.

XXX: THIS TYPE IS EXPERIMENTAL AND THE ENTIRE DESIGN IS SUBJECT TO CHANGE.

Global Functions

NGRAPH_API std::ostream& operator << (
    std::ostream& str,
    const Dimension& dimension
    )

Insert a human-readable representation of a dimension into an output stream.

Inserts the string ? if dimension is dynamic; else inserts dimension.get_length().

Parameters:

str

The output stream targeted for insertion.

dimension

The dimension to be inserted into str.

Returns:

A reference to str after insertion.

template <typename Type, typename Value>
std::enable_if<std::is_convertible<Value, std::string>::value, Type>::type as_enum(const Value& value)

Returns the enum value matching the string.

template <typename Value>
const std::string& as_string(Value value)

Returns the string matching the enum value.

NGRAPH_API std::string getenv_string(const char* env_var)

Get the names environment variable as a string.

Parameters:

env_var

The string name of the environment variable to get.

Returns:

Returns string by value or an empty string if the environment variable is not set.

NGRAPH_API int32_t getenv_int(const char* env_var, int32_t default_value = -1)

Get the names environment variable as an integer. If the value is not a valid integer then an exception is thrown.

Parameters:

env_var

The string name of the environment variable to get.

default_value

The value to return if the environment variable is not set.

Returns:

Returns value or default_value if the environment variable is not set.

NGRAPH_API bool getenv_bool(const char* env_var, bool default_value = false)

Get the names environment variable as a boolean. If the value is not a valid boolean then an exception is thrown. Valid booleans are one of 1, 0, on, off, true, false All values are case insensitive. If the environment variable is not set the default_value is returned.

Parameters:

env_var

The string name of the environment variable to get.

default_value

The value to return if the environment variable is not set.

Returns:

Returns the boolean value of the environment variable.

NGRAPH_API void traverse_nodes(
    const NodeVector& subgraph_results,
    std::function<void(std::shared_ptr<Node>)> f,
    const NodeVector& subgraph_params = {}
    )

Visit each node in a sub-graph of the entire graph.

Traverses a sub-graph starting from subgraph_results moving up towards parameter nodes. Traversal stops if it hits a node in subgraph_params.

Most useful for finding parameters of a graph directly from the result nodes and not from function parameters or extracting a subgraph relevant to the computation of certain outputs

Parameters:

subgraph_results

The output nodes of the sub-graph

f

Function to execute at each node in the traversal

subgraph_params

Input nodes of the sub-graph (optional)

NGRAPH_API void replace_node(
    std::shared_ptr<Node> target,
    std::shared_ptr<Node> replacement,
    const std::vector<int64_t>& output_order
    )

Replace the node target with the node replacement, i.e., redirect all users and control dependencies of target to replacement.

This is primarily used in graph-rewriting passes. For example, we might “fuse” two Concat operations as follows:

(Step 0: Original graph)

A B | | v v N0[Concat, concatenation_axis=3] C | | v v N1[Concat, concatenation_axis=3] | | v v some_user another_user

(Step 1: Construct replacement)

shared_ptr<Node> new_N1 = make_shared<op::Concat>({A,B,C},3);

A————————————-. | | | B————-). | | | | v v | | N0[Concat, concatenation_axis=3] C–)). | | | | | v v v v v N1[Concat, concatenation_axis=3] new_N1[Concat, concatenation_axis=3] | | v v some_user another_user

(Step 2: Replace N1 with new_N1)

replace_node(N1, new_N1);

A————————————-. | | | B————-). | | | | v v | | N0[Concat, concatenation_axis=3] C–)). | | | | | v v v v v N1[Concat, concatenation_axis=3] new_N1[Concat, concatenation_axis=3] | | v v some_user another_user

(Step 3: N0 and N1 are now dead, nodes will be freed)

[happens automatically, once all shared_ptrs to N1 are released]

A————————————-. | B————-). | | | | C–)). | | | v v v new_N1[Concat, concatenation_axis=3] | | v v some_user another_user

NOTE 1: replace_node is not type-safe (the graph is not revalidated). For example, the following is allowed, even if node some_user requires an input of shape 2x2:

(Before) A(shape=2x2) B(shape=3x3) | v some_user(requires 2x2 input)

(After graph is now invalid)

replace_node(A, B);

A(shape=2x2)  B(shape=3x3)
              |
              v
           some_user(requires 2x2 input)

NOTE 2: it is possible to insert a cycle into the graph with replace_node, resulting in an invalid graph. Care must be taken to avoid this. One common example is when you are attempting to insert a new node M “after” a node N`. For example, you might expect this to work:

shared_ptr<Node> M = make_shared<SomeUnaryOp>(N); replace_node(M, N);

The problem is that at replacement time, N itself is a user of M. So we end up introducing a cycle as follows:

N
|
v

other users…

|||
vvv

 N------------>M
 |
 v

other users…

|||
vvv

         .----.
        |      |
        |      |
 N      `----->M
               |
               v
          other users...

To avoid the cycle, a valid way to perform the above desired insertion would be,

auto new_N = N->clone_with_new_inputs(N->input_values());
shared_ptr<Node> M = make_shared<SomeUnaryOp>(new_N);
replace_node(N, M);

Parameters:

target

Node to be replaced.

replacement

Node to replace target with.

output_order

Vector determines order of replacement node’s outputs.

NGRAPH_API void replace_node(
    const std::shared_ptr<Node>& target,
    const OutputVector& replacement_values
    )

Replace target.outputs[i] with replacement_values[i] and transfer control dependents and provenance from target to the node(s) in replacement_values.

NGRAPH_API void replace_nodes(
    const std::shared_ptr<Function>& f,
    const std::unordered_map<std::shared_ptr<op::v0::Parameter>, std::shared_ptr<op::v0::Parameter>>& parameter_replacement_map,
    const std::unordered_map<std::shared_ptr<Node>, std::shared_ptr<Node>>& body_replacement_map
    )

Replace multiple nodes in a function.

Limitations:

  • No check is made that the replaced nodes in parameter_replacement_map are actually among the bound parameters of f. (If a parameter appears in the map that is not bound by f, it will be silently ignored.)

  • If a parameter node appears as a key in both parameter_replacement_map and in body_replacement_map, behavior is unspecified.

Parameters:

f

Function where replacement is taking place.

parameter_replacement_map

A mapping from parameter shared pointers to parameter shared pointers. For each pair (k,v) in the map, parameter k is replaced by parameter v, except if k==v or k is not a parameter bound by f, in which case the pair (k,v) is ignored.

body_replacement_map

A mapping from node shared pointers to node shared pointers. For each pair (k,v) in the map, node k is replaced by node v, except if k==v, the pair (k,v) is ignored. Note that if k is a parameter, its users will be redirected to v, but k will not be replaced in the function’s parameter list.

template <typename T>
std::vector<std::shared_ptr<Node>> topological_sort(T root_nodes)

Topological sort of nodes needed to compute root_nodes.

template <typename T>
std::vector<std::shared_ptr<Node>> subgraph_topological_sort(T nodes)

Topological sort of just nodes.

NGRAPH_API std::vector<Input<Node>> get_inputs_from(Node& src, Node& dst)

Returns:

A vector containing handles for each input of dst that is connected to an output of src.

NGRAPH_API std::vector<Output<Node>> get_outputs_to(Node& src, Node& dst)

Returns:

A vector containing a handle for each output of src that is connected to an input of dst.

NGRAPH_API bool check_for_cycles(
    const ngraph::Function* func,
    ngraph::NodeVector& cycle_nodes,
    bool& is_bkwd_cycle
    )

Checks the func for graph cycles starting from results going backwards, then from parameters going forward. It returns true if a cycle is found and the first cycle encountered.

NGRAPH_API void get_version(
    size_t& major,
    size_t& minor,
    size_t& patch,
    std::string& extra
    )

Function to query parsed version information of the version of ngraph which contains this function. Version information strictly follows Semantic Versioning http://semver.org.

Throws a runtime_error if there is an error during parsing

Parameters:

major

Returns the major part of the version

minor

Returns the minor part of the version

patch

Returns the patch part of the version

extra

Returns the extra part of the version. This includes everything following the patch version number.

NGRAPH_API ResultVector as_result_vector(const OutputVector& values)

Returns a ResultVector referencing values.

PartialShape operator + (const PartialShape& s1, const PartialShape& s2)

Elementwise addition of two PartialShape objects.

  • If s1 or s2 has dynamic rank, returns PartialShape::dynamic().

  • If s1 and s2` both have static rank, and their ranks are unequal, throws std::invalid_argument.

  • If s1 and s2 both have static rank, and their ranks are equal, returns a new shape whose i th dimension is s1[i] + s2[i].

Parameters:

s1

Left operand for addition.

s2

Right operand for addition.

std::invalid_argument

If s1 and s2 have inconsistent ranks.

Returns:

The result of elementwise adding s1 to s2 (see description).

NGRAPH_API std::ostream& operator << (
    std::ostream& str,
    const PartialShape& shape
    )

Inserts a human-readable representation of a PartialShape into an output stream.

The output to the stream is in “informal” notation. In other words:

  • If shape has dynamic rank, inserts the string ?.

  • If shape has static rank, inserts the string {, then inserts each dimension of shape into the output stream separated by commas, then inserts }.

Example:

PartialShape s1{PartialShape::dynamic())};
PartialShape s2{};
PartialShape s3{1,Dimension::dynamic(),2,3};
PartialShape s4{2,3,4};
std::cout << s1 << std::endl
          << s2 << std::endl
          << s3 << std::endl
          << s4 << std::endl;

Output :

?
{}
{1,?,2,3}
{2,3,4}

Parameters:

str

The output stream targeted for insertion.

shape

The shape to be inserted into str.

Returns:

A reference to str after insertion.

template <typename SHAPE_TYPE>
size_t shape_size(const SHAPE_TYPE& shape)

Number of elements in spanned by a shape.

template <typename SHAPE_TYPE>
std::vector<size_t> row_major_strides(const SHAPE_TYPE& shape)

Row-major strides for a shape.

NGRAPH_API std::shared_ptr<Function> specialize_function(
    std::shared_ptr<Function> f,
    const std::vector<element::Type>& parameter_element_types,
    const std::vector<PartialShape>& parameter_shapes,
    const std::vector<void*>& parameter_values
    )

Creates a “specialized” clone of a function. The partial shapes and element types of the function’s parameters may be narrowed to more specific shapes and element types, and constant values may optionally be substituted for any or all of the parameters.

Creates a “specialized” clone of an nGraph Function.

For example, suppose that a function f has three parameters with partial shapes:

param0: ?
param1: {1,?,3}
param2: {?,?,4}

Shape specialization would allow us to create a clone of f where the shapes are (for example):

param0: {1,2}
param1: {1,5,3}
param2: {3,?,4}

But not (for example):

param1: {1,5,3,4}  // rank doesn't match {1,?,3}
param1: {2,?,3}    // the "2" doesn't match the "1"
param1: {?,?,3}    // the new shape is too relaxed: it doesn't require 1 for the first dim

Note that validation errors can potentially occur during cloning. For example:

n = Parameter{shape=?}
m = Parameter{shape=?}
x = n + m
f = Function(x,{n,m})

If we specialize n to the shape {1,2,3} and m to the shape {4,5,6}, cloning will fail because when we reconstruct the new x node, it will see that the shapes are inconsistent for elementwise add.

Specialization of element types is also possible: element::dynamic can be specialized to a concrete element type or left dynamic; but a concrete element type can only be specialized to itself (e.g., specialization does not allow you to change element::i32 to element::i64).

Finally, it is possible to specialize parameter values. If the ith element of parameter_values is not nullptr, and fully static element type and shape has been specified for the ith parameter, a Constant node will be created and substituted for the ith parameter, with its data drawn from parameter_values[i]. Note that the Parameter node remains (in order to maintain the arity of the function), but will no longer have any users.

It is required that:

  1. The length of parameter_element_types, parameter_shapes, and parameter_values is the same as the number of f’s parameters.

  2. Each shape in parameter_shapes is a refinement of the shape of the corresponding parameter of f. Roughly speaking, a shape s1 is said to “refine” s2 if s1 can be obtained from s2 by filling in s2’s question marks. See PartialShape::refines for more details.

  3. For all i, either the element type of fp_i is dynamic, or fp_i is the same as parameter_element_types[i]. (Here fp_i is the ith parameter of f.)

  4. For all i where parameter_values[i] != nullptr and parameter_element_types[i] is static and parameter_shapes[i] is static, parameter_values[i] points to a buffer from which a Constant node with element type parameter_element_types[i] and shape parameter_shapes[i] can be created.

TODO(amprocte): convert this to a pass.

Parameters:

f

The function to be cloned.

parameter_element_types

The new parameter element types to substitute. Length must be equal to the number of parameters of f.

parameter_shapes

The new parameter shapes to substitute. Length must be equal to the number of parameters of f.

parameter_values

Parameter values to substitute. Length must be equal to the number of parameters of f, with nullptr indicating that no substitution is to be made for the corresponding parameter.

CheckFailure

if parameter_element_types, parameter_shapes is not valid (see details).

NodeValidationError

if node validation fails as the clone is being constructed.

Returns:

A clone of f, with the parameter element types, shapes, and values specialized.

size_t compiler_byte_size(element::Type_t et)

Return the number of bytes in the compile-time representation of the element type.

template <typename T>
T parse_string(const std::string& s)

Parses a string containing a literal of the underlying type.

NGRAPH_API float parse_string< float >(const std::string& s)

template specializations for float and double to handle INFINITY, -INFINITY and NaN values.

NGRAPH_API int8_t parse_string< int8_t >(const std::string& s)

template specializations for int8_t and uint8_t to handle the fact that default implementation ends up treating values as characters so that the number “0” turns into the parsed value 48, which is it’s ASCII value

template <typename T>
std::vector<T> parse_string(const std::vector<std::string>& ss)

Parses a list of strings containing literals of the underlying type.

NGRAPH_API void parse_version_string(
    std::string version,
    size_t& major,
    size_t& minor,
    size_t& patch,
    std::string& extra
    )

Function to query parsed version information of the version of ngraph which contains this function. Version information strictly follows Semantic Versioning http://semver.org.

Throws a runtime_error if there is an error during parsing

Parameters:

version

The major part of the version

major

Returns the major part of the version

minor

Returns the minor part of the version

patch

Returns the patch part of the version

extra

Returns the extra part of the version. This includes everything following the patch version number.

PartialShape validate_and_infer_convolution_forward_output_shape(
    const Node* node,
    const Rank& result_ps_rank,
    const PartialShape& data_batch_pshape,
    const PartialShape& filters_pshape,
    const op::PadType auto_pad,
    Strides& strides,
    Strides& dilations,
    CoordinateDiff& pads_begin,
    CoordinateDiff& pads_end
    )

Validates input shape ranks and infers convolution forward output shape.

Parameters:

node

Node with convolution operation.

data_batch_pshape

Partial shape of data batch input.

filters_pshape

Partial shape of filters input.

auto_pad

Type of padding.

strides

Strides.

dilations

Dilations.

pads_begin

Pads begin.

pads_end

Pads end.

Returns:

Partial shape of the output.

NGRAPH_API bool try_apply_auto_padding(
    const PartialShape& image_shape,
    const Shape& filter_shape,
    const Strides& filter_strides,
    const Strides& filter_dilations,
    const op::PadType pad_type,
    CoordinateDiff& padding_above,
    CoordinateDiff& padding_below
    )

Apply auto padding to padding_above and padding_below inputs if all needed informations are known.

Parameters:

image_shape

The shape of input image.

filter_shape

The shape of filter input.

filter_strides

The strides of applied padding.

filter_dilations

The dilations of applied padding.

pad_type

The type of padding. Auto padding is applied only for SAME_UPPER and SAME_LOWER mode.

padding_above

The beginning of padding shape.

end

The beginning of padding shape.

Returns:

true if auto padding was applied successfully (all needed informations such as spatial dims are known), false otherwise.

NGRAPH_API int64_t normalize_axis(
    const Node* node,
    std::int64_t axis,
    const Rank& tensor_rank
    )

Handle out of range axis.

Parameters:

node

The node with requested axis.

axis

The requested axis value.

tensor_rank

The corresponding tensor rank.

Returns:

Checking if axis is in range [-tensor_rank, tensor_rank-1], otherwise returns error. If negative axis, it counts from the last to the first axis, by adding tensor_rank to axis.

NGRAPH_API std::vector<size_t> normalize_axes(
    const std::string& node_description,
    const std::vector<int64_t>& axes,
    const Rank& tensor_rank
    )

Handle out of range axes in vector.

Parameters:

node_description

The name of node with requested axes.

axes

The requested vector of axes.

tensor_rank

The corresponding tensor rank.

Returns:

If any negative axis in vector, it counts from the last to the first axis, by adding tensor_rank to axis.

NGRAPH_API int64_t normalize_axis(
    const std::string& node_description,
    std::int64_t axis,
    const Rank& tensor_rank
    )

Handle out of range axis.

Parameters:

node_description

The node with requested axis.

axis

The requested axis value.

tensor_rank

The corresponding tensor rank.

Returns:

Checking if axis is in range [-tensor_rank, tensor_rank-1], otherwise returns error. If negative axis, it counts from the last to the first axis, by adding tensor_rank to axis.

NGRAPH_API int64_t normalize_axis(
    const Node* node,
    std::int64_t axis,
    std::uint64_t tensor_rank,
    std::int64_t axis_range_min,
    std::int64_t axis_range_max
    )

Handle out of range axis.

Parameters:

node

The node with requested axis.

axis

The requested axis value.

tensor_rank

The corresponding tensor rank.

axis_range_min

The min value of accepted range for axis.

axis_range_max

The max value of accepted range for axis.

Returns:

Checking if axis is in range [axis_range_min, axis_range_max], otherwise returns error. If negative axis, it counts from the last to the first axis, by adding tensor_rank to axis.

NGRAPH_API int64_t normalize_axis(
    const std::string& node_description,
    std::int64_t axis,
    std::uint64_t tensor_rank,
    std::int64_t axis_range_min,
    std::int64_t axis_range_max
    )

Handle out of range axis.

Parameters:

node_description

The name of node with requested axis.

axis

The requested axis value.

tensor_rank

The corresponding tensor rank.

axis_range_min

The min value of accepted range for axis.

axis_range_max

The max value of accepted range for axis.

Returns:

Checking if axis is in range [axis_range_min, axis_range_max], otherwise returns error. If negative axis, it counts from the last to the first axis, by adding tensor_rank to axis.

NGRAPH_API std::pair<bool, uint64_t> maximum_value(const Output<Node>& value)

Try to compute the maximum value of value.

Returns:

(true, max_value) if can be determined, or (false, numeric_limits<uint64_t>::max()) if not.

NGRAPH_API void evaluate_nodes(
    std::map<RawNodeOutput, HostTensorPtr>& value_map,
    std::map<RawNodeOutput, HostTensorPtr>& output_tensor_map,
    const OutputVector& outputs,
    const EvaluationContext& evaluation_context = EvaluationContext()
    )

Evaluates outputs, treating values in value_map as already computed. value_map is updated.

Parameters:

value_map

Key is RawNodeOutput in graph, value is the computed value. Updated by the function.

output_tensor_map

Tensors to use for particular outputs

outputs

Root set of values to try to compute

evaluation_context

Storage of additional settings and attributes that can be used when evaluating the function. This additional information can be shared across nodes.

NGRAPH_API HostTensorPtr evaluate_lower_bound(const Output<Node>& output)

Evaluates lower value estimation of the output tensor. Traverses graph up to deduce estimation through it.

Parameters:

Node

output pointing to the tensor for estimation.

Returns:

HostTensorPtr to estimated value if can be determined, or nullptr.

NGRAPH_API HostTensorPtr evaluate_upper_bound(const Output<Node>& output)

Evaluates lower value estimation of the output tensor. Traverses graph up to deduce estimation through it.

Parameters:

output

Tensor to be estimated.

Returns:

HostTensorPtr to estimated value if can be determined, or nullptr.

NGRAPH_API std::pair<HostTensorPtr, HostTensorPtr> evaluate_both_bounds(const Output<Node>& output)

Evaluates lower and upper value estimations of the output tensor. Traverses graph up to deduce estimation through it.

Parameters:

output

Node output pointing to the tensor for estimation.

Returns:

pair with HostTensorPtrs for lower and upper value estimation. Each object in pair could be HostTensorPtr to estimated value if particular bound can be determined, or nullptr.

NGRAPH_API bool evaluate_as_partial_shape(
    const Output<Node>& output,
    PartialShape& pshape
    )

Evaluates lower and upper value estimations for the output tensor. Estimation would be represented as partial shape object using Dimension(min, max) for each element.

Parameters:

output

Node output pointing to the tensor for estimation.

pshape

Resulting estimation would be stored in this PartialShape.

Returns:

boolean status if value evaluation was successful.

NGRAPH_API bool default_upper_bound_evaluator(
    const Node* node,
    const HostTensorVector& output_values
    )

Estimates upper bound for node output tensors using only upper bounds of the nodes inputs.

Parameters:

node

Operation to be performed

output_values

Vector of HostTensorPtrs representing resulting upper value estimations

Returns:

boolean status if value evaluation was successful.

NGRAPH_API bool default_lower_bound_evaluator(
    const Node* node,
    const HostTensorVector& output_values
    )

Estimates lower bound for node output tensors using only lower bounds of the nodes inputs.

Parameters:

node

Operation to be performed

output_values

Vector of HostTensorPtrs representing resulting lower value estimations

Returns:

boolean status if value evaluation was successful.

NGRAPH_API bool interval_bound_evaluator(
    const Node* node,
    const HostTensorVector& lower_output_values,
    const HostTensorVector& upper_output_values
    )

Estimates both bounds for node output tensors using both bounds of inputs. Works for operations with two inputs (in_1 and in_2). Brute forces all the pairs of bounds for inputs and evaluates all of them: {in_1_lower, in_2 lower}, {in_1_lower, in_2 upper}, {in_1_upper, in_2_lower}, {in_1_upper, in_2_upper}. Lower and upper values are selected from all the outputs calculated using input pairs.

Parameters:

node

Operation to be performed

output_values

Vector of HostTensorPtrs representing resulting lower value estimations

Returns:

boolean status if value evaluation was successful.

NGRAPH_API bool host_tensor_is_positive(const HostTensorPtr& bound)

Checks if all the elements of the bound HostTensor are positive.

NGRAPH_API bool has_and_set_equal_bounds(const Output<Node>& source)

Checks if lower and upper bounds of the corresponding tensor are set (not nullptr) and pointers are the same. It doesn’t check if lower and upper values are the same relying only on pointers comparison.

NGRAPH_API std::shared_ptr<op::Constant> get_constant_from_source(const Output<Node>& source)

Runs an estimation of source tensor. If it succeeded to calculate both bounds and they are the same returns Constant operation from the resulting bound, otherwise nullptr.

NGRAPH_API std::shared_ptr<op::Constant> get_constant_max_of_type(element::Type_t t)

Returns a Constant storing scalar value equal to std::numeric_limits<t>::max()

NGRAPH_API std::shared_ptr<op::Constant> get_constant_min_of_type(element::Type_t t)

Returns a Constant storing scalar value equal to std::numeric_limits<t>::min()

NGRAPH_API bool validate_host_tensor_vector(
    const HostTensorVector& v,
    const size_t& size
    )

Checks if size of HostTensorVector is the same as passed size attribute. Then checks that all the HostTensorPtrs are not equal to nullptr.