namespace ngraph

Overview

The Intel nGraph C++ API. More…

namespace ngraph {

// namespaces

namespace ngraph::builder;
    namespace ngraph::builder::opset1;
namespace ngraph::descriptor;
    namespace ngraph::descriptor::layout;
namespace ngraph::element;
namespace ngraph::file_util;
namespace ngraph::op;
    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::v10;
    namespace ngraph::op::v11;
    namespace ngraph::op::v12;
    namespace ngraph::op::v3;
    namespace ngraph::op::v4;
    namespace ngraph::op::v5;
    namespace ngraph::op::v6;
    namespace ngraph::op::v7;
    namespace ngraph::op::v8;
    namespace ngraph::op::v9;
namespace ngraph::opset1;
namespace ngraph::opset10;
namespace ngraph::opset11;
namespace ngraph::opset2;
namespace ngraph::opset3;
namespace ngraph::opset4;
namespace ngraph::opset5;
namespace ngraph::opset6;
namespace ngraph::opset7;
namespace ngraph::opset8;
namespace ngraph::opset9;
namespace ngraph::pass;
namespace ngraph::pattern;
    namespace ngraph::pattern::op;
namespace ngraph::reduction;
namespace ngraph::runtime;
    namespace ngraph::runtime::reference;

// typedefs

typedef ov::AssertFailure CheckFailure;
typedef ov::Exception ngraph_error;
typedef ov::Model Function;
typedef runtime::HostTensor HostTensor;
typedef std::shared_ptr<HostTensor> HostTensorPtr;
typedef std::vector<HostTensorPtr> HostTensorVector;
typedef ov::EvaluationContext EvaluationContext;
typedef std::vector<std::shared_ptr<ngraph::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::unordered_map<VariablePtr, VariableValuePtr> VariableMap;
typedef std::shared_ptr<VariableValue> VariableValuePtr;
typedef ov::NodeVector NodeVector;
typedef ov::OutputVector OutputVector;

// enums

enum LOG_TYPE;

// structs

struct SlicePlan;

// classes

class ConstString;
template <typename V>
class Evaluator;
template <typename BASE_TYPE>
class FactoryAttributeAdapter;
template <typename BASE_TYPE>
class FactoryRegistry;
class LogHelper;
class Logger;
class OpSet;
class unsupported_op;

// global variables

const auto node_validation_failure_loc_string = ov::node_validation_failure_loc_string;
const auto as_output_vector = ov::as_output_vector;
const auto as_node_vector = ov::as_node_vector;
const auto as_result_vector = ov::as_result_vector;

// global functions

NGRAPH_API_DEPRECATED NGRAPH_API std::string getenv_string(const char \* env_var);

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

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

NGRAPH_API_DEPRECATED NGRAPH_API std::mutex& get_registry_mutex();

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

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

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

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

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

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

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

NGRAPH_API_DEPRECATED 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_DEPRECATED 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_DEPRECATED NGRAPH_API std::pair<std::shared_ptr<op::v0::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_DEPRECATED 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_DEPRECATED NGRAPH_API std::shared_ptr<Node> make_zero(
    const element::Type& element_type,
    const Shape& shape
    );

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

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

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

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

NGRAPH_API_DEPRECATED NGRAPH_API bool is_one(const Output<Node>& reduce_constant);
NGRAPH_API_DEPRECATED NGRAPH_API bool is_used(Node \* node);
NGRAPH_API_DEPRECATED NGRAPH_API size_t get_user_count(Node \* node);
NGRAPH_API_DEPRECATED NGRAPH_API bool is_strided(const Strides& strides);

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

NGRAPH_API_DEPRECATED 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_DEPRECATED NGRAPH_API std::vector<Input<Node>> get_inputs_from(
    Node& src,
    Node& dst
    );

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

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

constexpr NGRAPH_API_DEPRECATED const char \* find_last(
    ConstString s,
    size_t offset,
    char ch
    );

constexpr NGRAPH_API_DEPRECATED const char \* find_last(ConstString s, char ch);
constexpr NGRAPH_API_DEPRECATED const char \* get_file_name(ConstString s);
NGRAPH_API_DEPRECATED NGRAPH_API const char \* trim_file_name(const char \*const fname);
NGRAPH_API_DEPRECATED NGRAPH_API void default_logger_handler_func(const std::string& s);

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

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

NGRAPH_API_DEPRECATED AxisSet get_normalized_axes_from_tensor(
    const HostTensorPtr tensor,
    const ngraph::Rank& rank,
    const std::string& node_description
    );

NGRAPH_API_DEPRECATED 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_DEPRECATED const NGRAPH_API OpSet& get_opset1();
NGRAPH_API_DEPRECATED const NGRAPH_API OpSet& get_opset2();
NGRAPH_API_DEPRECATED const NGRAPH_API OpSet& get_opset3();
NGRAPH_API_DEPRECATED const NGRAPH_API OpSet& get_opset4();
NGRAPH_API_DEPRECATED const NGRAPH_API OpSet& get_opset5();
NGRAPH_API_DEPRECATED const NGRAPH_API OpSet& get_opset6();
NGRAPH_API_DEPRECATED const NGRAPH_API OpSet& get_opset7();
NGRAPH_API_DEPRECATED const NGRAPH_API OpSet& get_opset8();
NGRAPH_API_DEPRECATED const NGRAPH_API OpSet& get_opset9();
NGRAPH_API_DEPRECATED const NGRAPH_API OpSet& get_opset10();
NGRAPH_API_DEPRECATED const NGRAPH_API OpSet& get_opset11();
NGRAPH_API_DEPRECATED const NGRAPH_API OpSet& get_opset12();
NGRAPH_API_DEPRECATED const NGRAPH_API OpSet& get_opset13();
NGRAPH_API_DEPRECATED const NGRAPH_API std::map<std::string, std::function<const ngraph::OpSet&()>>& get_available_opsets();

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

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

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

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

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

NGRAPH_API_DEPRECATED 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>
NGRAPH_API_DEPRECATED AXIS_VALUES inject(
    const AXIS_VALUES& axis_values,
    size_t new_axis_pos,
    AXIS_VALUE new_axis_val
    );

NGRAPH_API_DEPRECATED 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_DEPRECATED size_t compiler_byte_size(element::Type_t et);

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

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

NGRAPH_API NGRAPH_API_DEPRECATED size_t hash_combine(const std::vector<size_t>& list);

NGRAPH_API NGRAPH_API_DEPRECATED void dump(
    std::ostream& out,
    const void \*,
    size_t
    );

NGRAPH_API NGRAPH_API_DEPRECATED std::string to_lower(const std::string& s);
NGRAPH_API NGRAPH_API_DEPRECATED std::string to_upper(const std::string& s);
NGRAPH_API NGRAPH_API_DEPRECATED std::string trim(const std::string& s);

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

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

class NGRAPH_API NGRAPH_DEPRECATED("It is obsolete structure and will be removed soon");

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

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

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

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

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

NGRAPH_API NGRAPH_API_DEPRECATED void \* ngraph_malloc(size_t size);
NGRAPH_API NGRAPH_API_DEPRECATED void ngraph_free(void \*);
NGRAPH_API NGRAPH_API_DEPRECATED size_t round_up(size_t size, size_t alignment);
NGRAPH_API NGRAPH_API_DEPRECATED AxisVector get_default_order(size_t rank);
NGRAPH_API NGRAPH_API_DEPRECATED AxisVector get_default_order(const Rank& rank);
NGRAPH_API NGRAPH_API_DEPRECATED AxisVector get_default_order(const Shape& shape);
NGRAPH_API NGRAPH_API_DEPRECATED AxisVector get_default_order(const PartialShape& shape);

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

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

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

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

NGRAPH_API_DEPRECATED 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
    );

NGRAPH_API_DEPRECATED 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
    );

NGRAPH_API_DEPRECATED 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_DEPRECATED 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,
    const Strides& window_dilation = Strides{}
    );

NGRAPH_API_DEPRECATED 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_DEPRECATED 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_DEPRECATED 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_DEPRECATED 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_DEPRECATED NGRAPH_API std::pair<bool, uint64_t> maximum_value(const Output<Node>& value);

NGRAPH_API_DEPRECATED 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_DEPRECATED NGRAPH_API std::shared_ptr<op::Constant> get_constant_max_of_type(element::Type_t t);
NGRAPH_API_DEPRECATED NGRAPH_API std::shared_ptr<op::Constant> get_constant_min_of_type(element::Type_t t);
NGRAPH_API_DEPRECATED NGRAPH_API std::shared_ptr<op::Constant> get_constant_lowest_of_type(element::Type_t t);

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

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

} // namespace ngraph

Detailed Documentation

The Intel nGraph C++ API.

Typedefs

typedef ov::Exception ngraph_error

Base error for ngraph runtime errors.

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

Alias useful for cloning.

Global Functions

NGRAPH_API_DEPRECATED 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_DEPRECATED 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_DEPRECATED 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.

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

Topological sort of just nodes.

NGRAPH_API_DEPRECATED 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_DEPRECATED 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_DEPRECATED 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_DEPRECATED AxisSet get_normalized_axes_from_tensor(
    const HostTensorPtr tensor,
    const ngraph::Rank& rank,
    const std::string& node_description
    )

Extracts the tensor data and returns a set of normalized axes created out of it.

Parameters:

tensor

A pointer to a HostTensor object containing the raw axes data

rank

Rank of an operator’s input data tensor (used to normalize the axes)

node_description

An identifier of the operator’s node (used to report errors)

Returns:

Normalized (positive only) axes as an AxisSet object.

NGRAPH_API_DEPRECATED 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.

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.

NGRAPH_API_DEPRECATED 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>
NGRAPH_API_DEPRECATED T parse_string(const std::string& s)

Parses a string containing a literal of the underlying type.

NGRAPH_API_DEPRECATED 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_DEPRECATED 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>
NGRAPH_API_DEPRECATED std::vector<T> parse_string(const std::vector<std::string>& ss)

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

NGRAPH_API NGRAPH_API_DEPRECATED 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.

NGRAPH_API_DEPRECATED 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_DEPRECATED 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_DEPRECATED NGRAPH_API std::pair<bool, uint64_t> maximum_value(const Output<Node>& value)

Try to compute the maximum value of value.

Deprecated Use evaluate_upper_bound instead

Returns:

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

NGRAPH_API_DEPRECATED 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_DEPRECATED 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_DEPRECATED 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_DEPRECATED NGRAPH_API std::shared_ptr<op::Constant> get_constant_lowest_of_type(element::Type_t t)

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

NGRAPH_API_DEPRECATED 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.

NGRAPH_API NGRAPH_API_DEPRECATED 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.