# ngraph package

ngraph module namespace, exposing factory functions for all ops and other classes.

## ngraph.exceptions module¶

ngraph exceptions hierarchy. All exceptions are descendants of NgraphError.

exception ngraph.exceptions.NgraphError[source]

Bases: Exception

Base class for Ngraph exceptions.

exception ngraph.exceptions.NgraphTypeError[source]

Bases: ngraph.exceptions.NgraphError, TypeError

Type mismatch error.

exception ngraph.exceptions.UserInputError[source]

User provided unexpected input.

## ngraph.ops module¶

Factory functions for all ngraph ops.

ngraph.ops.absolute(node, name=None)[source]

Return node which applies f(x) = abs(x) to the input node element-wise.

Parameters
• node – One of: input node, array or scalar.

• name – Optional new name for output node.

Returns

New node with Abs operation applied on it.

ngraph.ops.acos(node, name=None)[source]

Apply inverse cosine function on the input node element-wise.

Parameters
• node – One of: input node, array or scalar.

• name – Optional new name for output node.

Returns

New node with arccos operation applied on it.

ngraph.ops.add(left_node, right_node, name=None)[source]

Return node which applies f(x) = A+B to the input nodes element-wise.

ngraph.ops.argmax(data, axis=0)[source]

Return a node which performs ArgMax index reduction operation.

Parameters
• data – Input data.

• axis – Reduction Axis.

Returns

The new node which performs ArgMax

ngraph.ops.argmin(data, axis=0)[source]

Return a node which performs ArgMin index reduction operation.

Parameters
• data – Input data.

• axis – Reduction Axis.

Returns

The new node which performs ArgMin

ngraph.ops.asin(node, name=None)[source]

Apply inverse sine function on the input node element-wise.

Parameters
• node – One of: input node, array or scalar.

• name – Optional new name for output node.

Returns

New node with arcsin operation applied on it.

ngraph.ops.atan(node, name=None)[source]

Apply inverse tangent function on the input node element-wise.

Parameters
• node – One of: input node, array or scalar.

• name – Optional new name for output node.

Returns

New node with arctan operation applied on it.

ngraph.ops.avg_pool(data_batch, window_shape, window_strides=None, padding_below=None, padding_above=None, include_padding=False, name=None)[source]

Return average pooling node.

Parameters
• data_batch – The input node providing data.

• window_shape – The pooling window shape.

• window_strides – The window movement strides.

• padding_below – The input data optional padding below filled with zeros.

• padding_above – The input data optional padding below filled with zeros.

• include_padding – Whether or not to include zero padding in average computations.

• name – Optional name for the new output node.

Returns

New node with AvgPool operation applied on its data.

ngraph.ops.batch_norm(eps, gamma, beta, data, mean=None, variance=None, name=None)[source]

Return batch normalization node.

ngraph.ops.broadcast(node, new_shape, broadcast_axes, name=None)[source]

Create a node which broadcasts the input node’s values along specified axes to a desired shape.

Parameters
• node – The node with input tensor data.

• new_shape – The new shape we want to broadcast tensor to.

• broadcast_axes – The axis positions (0-based) in the result that are being broadcast.

• name – Optional new name for output node.

Returns

ngraph.ops.broadcast_to(node, new_shape, axis=None, name=None)[source]

Create a node which broadcasts the input node’s values to a desired shape.

The optional axis parameter specifies the starting axis position (0-based) in the output shape from which the current shape of the tensor matches the desired new shape.

e.g. current_shape: [4, 5], new_shape: [2, 3, 4, 5, 6], axis: 2

By using the axis parameter you can control which output axis to broadcast along.

Example:

>>> input_node = ng.constant([1, 2, 3])
>>> current_shape = [3]
>>> new_shape = [3, 3]
array([[1, 2, 3],
[1, 2, 3],
[1, 2, 3]])

>>> ng.broadcast_to(input_node, new_shape, axis=0)
array([[1, 1, 1],
[2, 2, 2],
[3, 3, 3]])


If the axis parameter is not specified, broadcast_to will attempt to match shapes, assuming the current shape matches the rightmost positions of the desired new shape. This behaviour is similar to NumPy’s broadcasting.

i.e. default axis = len(new_shape) - len(current_shape)

Parameters
• node – The node with input tensor data.

• new_shape – The new shape we want to broadcast tensor to.

• axis – The axis along which we perform broadcasting.

• name – Optional new name for output node.

Returns

ngraph.ops.ceiling(node, name=None)[source]

Return node which applies ceiling to the input node element-wise.

Parameters
• node – The node providing data to ceiling operation.

• name – Optional name for output node.

Returns

The node performing element-wise ceiling.

ngraph.ops.clamp(data, min_value, max_value, name=None)[source]

Perform clamp element-wise on data from input node.

Performs a clipping operation on an input value between a pair of boundary values.

For each element in data, if the element’s value is lower than min_value, it will be replaced with min_value. If the value is higher than max_value, it will be replaced by max_value. Intermediate values of data are returned without change.

Clamp uses the following logic:

if data < min_value:
data=min_value
elif data > max_value:
data=max_value

Parameters
• data – Input tensor. One of: input node, array or scalar.

• min_value – The lower bound of the <min_value;max_value> range. Scalar value.

• max_value – The upper bound of the <min_value;max_value> range. Scalar value.

• name – Optional output node name.

Returns

The new node performing a clamp operation on its input data element-wise.

ngraph.ops.concat(nodes, axis, name=None)[source]

Concatenate input nodes into single new node along specified axis.

Parameters
• nodes – The nodes we want concatenate into single new node.

• axis – The axis along which we want to concatenate input nodes.

• name – The optional new name for output node.

Returns

Return new node that is a concatenation of input nodes.

ngraph.ops.constant(value, dtype=None, name=None)[source]

Create a Constant node from provided value.

Parameters
• value – One of: array of values or scalar to initialize node with.

• dtype – The data type of provided data.

• name – Optional name for output node.

Returns

The Constant node initialized with provided data.

ngraph.ops.convert(node, new_type, name=None)[source]

Return node which casts input node values to specified type.

ngraph.ops.convolution(data_batch, filter_weights, filter_strides=None, filter_dilation_strides=None, padding_below=None, padding_above=None, data_dilation_strides=None, name=None)[source]

Return node performing batched convolution operation.

Parameters
• data_batch – The node providing data batch tensor.

• filter_weights – The node providing filters tensor.

• filter_strides – The kernel window movement strides.

• filter_dilation_strides – The filters dilation strides.

• padding_below – The number of zero padding elements to add on each axis below 0 coordinate.

• padding_above – The number of zero padding elements to add on each axis above max coordinate.

• data_dilation_strides – The data batch dilation strides.

• name – The optional new name for output node.

Returns

New node performing batched convolution operation.

ngraph.ops.convolution_backprop_data(data_batch_shape, filters, output_delta, window_movement_strides_forward=None, window_dilation_strides_forward=None, padding_below_forward=None, padding_above_forward=None, data_dilation_strides_forward=None, name=None)[source]

Return node performing a batched-convolution data batch-backprop operation.

Parameters
• data_batch_shape – The shape of the data batch from forward-prop.

• filters – The node producing the filters from forward-prop.

• output_delta – The node producing output delta.

• window_movement_strides_forward – The window movement strides from forward-prop.

• window_dilation_strides_forward – The window dilation strides from forward-prop.

• data_dilation_strides_forward – The data dilation strides from forward-prop.

ngraph.ops.cos(node, name=None)[source]

Apply cosine function on the input node element-wise.

Parameters
• node – One of: input node, array or scalar.

• name – Optional new name for output node.

Returns

New node with cos operation applied on it.

ngraph.ops.cosh(node, name=None)[source]

Apply hyperbolic cosine function on the input node element-wise.

Parameters
• node – One of: input node, array or scalar.

• name – Optional new name for output node.

Returns

New node with cosh operation applied on it.

ngraph.ops.depth_to_space(node, block_size, name=None)[source]

Rearranges input tensor from depth into blocks of spatial data.

Values from the height and width dimensions are moved to the depth dimension.

Input tensor has shape [N,C,H,W], where N is the batch axis, C is the channel or depth, H is the height and W is the width.

Output node produces a tensor with shape:

[N, C * block_size * block_size, H / block_size, W / block_size]

Parameters
• node – The node with input tensor data.

• block_size – The size of the spatial block of values describing how the tensor’s data is to be rearranged.

• name – Optional output node name.

Returns

The new node performing an DepthToSpace operation on its input tensor.

ngraph.ops.divide(left_node, right_node, name=None)[source]

Return node which applies f(x) = A/B to the input nodes element-wise.

Parameters
• left_node – The node providing dividend data.

• right_node – The node providing divisor data.

• name – Optional name for output node.

Returns

The node performing element-wise division.

ngraph.ops.dot(left_node, right_node, reduction_axes_count=None, name=None)[source]

Return node which performs generalized dot product of two input nodes.

This operation is capable of performing scalar-tensor, matrix-vector product and matrix multiplication.

Parameters
• left_node – The node providing left hand side data.

• right_node – The node providing right hand side data.

• reduction_axes_count – The number of axes to reduce during dot-product.

• name – The optional name for output node.

Returns

The new node performing dot-product on input two nodes.

ngraph.ops.elu(data, alpha, name=None)[source]

Perform Exponential Linear Unit operation element-wise on data from input node.

Computes exponential linear: alpha * (exp(data) - 1) if < 0, data otherwise.

For more information refer to: Fast and Accurate Deep Network Learning by Exponential Linear Units (ELUs)

Parameters
• data – Input tensor. One of: input node, array or scalar.

• alpha – Multiplier for negative values. One of: input node or scalar value.

• name – Optional output node name.

Returns

The new node performing an ELU operation on its input data element-wise.

ngraph.ops.equal(left_node, right_node, name=None)[source]

Return node which checks if input nodes are equal element-wise.

Parameters
• left_node – The first input node for equal operation.

• right_node – The second input node for equal operation.

• name – The optional name for output new node.

Returns

The node performing element-wise equality check.

ngraph.ops.exp(node, name=None)[source]

Return node which applies exp to the input node element-wise.

Parameters
• node – The node providing data for operation.

• name – The optional name for new output node.

Returns

The new node performing natural exponential operation.

ngraph.ops.fake_quantize(data, input_low, input_high, output_low, output_high, levels, name=None)[source]

Perform an element-wise linear quantization on input data.

Input floating point values are quantized into a discrete set of floating point values.

if x <= input_low:
output = output_low
if x > input_high:
output = output_high
else:
output = fake_quantize(output)


Fake quantize uses the following logic:

$output = \dfrac{round( \dfrac{data - input\_low}{(input\_high - input\_low)\cdot (levels-1)})} {(levels-1)\cdot (output\_high - output\_low)} + output\_low$
Parameters
• data – The node with data tensor.

• input_low – The node with the minimum for input values.

• input_high – The node with the maximum for input values.

• output_low – The node with the minimum quantized value.

• output_high – The node with the maximum quantized value.

• levels – The number of quantization levels. Integer value.

Returns

New node with quantized value.

ngraph.ops.floor(node, name=None)[source]

Return node which applies floor to the input node element-wise.

Parameters
• node – The input node providing data.

• name – The optional name for new output node.

Returns

The node performing element-wise floor operation.

ngraph.ops.gelu(node, name=None)[source]

Perform Gaussian Error Linear Unit operation element-wise on data from input node.

Computes GELU function:

$f(x) = 0.5\cdot x\cdot(1 + erf( \dfrac{x}{\sqrt{2}})$

Parameters
• node – Input tensor. One of: input node, array or scalar.

• name – Optional output node name.

Returns

The new node performing a GELU operation on its input data element-wise.

ngraph.ops.gemm(A, B, C, alpha, beta, transA, transB, name=None)[source]

Perform General matrix-matrix multiplication on input tensors A, B and C.

Computes:

$Y = alpha\cdot A'\cdot B' + beta\cdot C$

A' is the transpose of matrix A with shape (M, K), if transA is True, otherwise A with shape (K, N).

B' is the transpose of matrix B with shape (K, N), if transB is True, otherwise B with shape (N, K).

C: Matrix broadcastable to shape (M, N).

Y: Matrix with shape (M, N).

Parameters
• A – The node with input tensor A.

• B – The node with input tensor B.

• C – The node with input tensor C.

• alpha – Scalar multiplier for the product of input tensors A * B.

• beta – Scalar multiplier for input tensor C.

• transA – Whether A should be transposed. Boolean value.

• transB – Whether B should be transposed. Boolean value.

• name – Optional name for the output node.

Returns

Return node with tensor of shape (M, N).

ngraph.ops.get_output_element(data, index)[source]

Return the n-th element of the input tuple.

ngraph.ops.greater(left_node, right_node, name=None)[source]

Return node which checks if left input node is greater than the right node element-wise.

Parameters
• left_node – The first input node providing data.

• right_node – The second input node providing data.

• name – The optional new name for output node.

Returns

The node performing element-wise check whether left_node is greater than right_node.

ngraph.ops.greater_eq(left_node, right_node, name=None)[source]

Return node which checks if left node is greater or equal to the right node element-wise.

Parameters
• left_node – The first input node providing data.

• right_node – The second input node providing data.

• name – The optional new name for output node.

Returns

The node performing element-wise check whether left_node is greater than or equal right_node.

ngraph.ops.grn(data, bias, name=None)[source]

Perform Global Response Normalization with L2 norm (across channels only).

Computes GRN operation on channels for input tensor:

$output_i = \dfrac{input_i}{\sqrt{\sum_{i}^{C} input_i}}$
Parameters
• data – The node with data tensor.

• bias – The bias added to the variance. Scalar value.

• name – Optional output node name.

Returns

The new node performing a GRN operation on tensor’s channels.

ngraph.ops.hard_sigmoid(data, alpha, beta, name=None)[source]

Perform Hard Sigmoid operation element-wise on data from input node.

Hard Sigmoid uses the following logic:

y = max(0, min(1, alpha * data + beta))

Parameters
• data – The node with data tensor.

• alpha – Alpha parameter. Scalar value.

• beta – Beta parameter. Scalar value.

• name – Optional output node name.

Returns

The new node performing a Hard Sigmoid element-wise on input tensor.

ngraph.ops.less(left_node, right_node, name=None)[source]

Return node which checks if left input node is less than the right node element-wise.

Parameters
• left_node – The first input node providing data.

• right_node – The second input node providing data.

• name – The optional new name for output node.

Returns

The node performing element-wise check whether left_node is less than the right_node.

ngraph.ops.less_eq(left_node, right_node, name=None)[source]

Return node which checks if left input node is less or equal the right node element-wise.

Parameters
• left_node – The first input node providing data.

• right_node – The second input node providing data.

• name – The optional new name for output node.

Returns

The node performing element-wise check whether left_node is less than or equal the right_node.

ngraph.ops.log(node, name=None)[source]

Return node which applies natural logarithm to the input node element-wise.

Parameters
• node – The input node providing data for operation.

• name – The optional new name for output node.

Returns

The new node performing log operation element-wise.

ngraph.ops.logical_and(left_node, right_node, name=None)[source]

Return node which perform logical and operation on input nodes element-wise.

Parameters
• left_node – The first input node providing data.

• right_node – The second input node providing data.

• name – The optional new name for output node.

Returns

The node performing logical and operation on input nodes corresponding elements.

ngraph.ops.logical_not(node, name=None)[source]

Return node which applies logical negation to the input node elementwise.

ngraph.ops.logical_or(left_node, right_node, name=None)[source]

Return node which performs logical or operation on input nodes element-wise.

Parameters
• left_node – The first input node providing data.

• right_node – The second input node providing data.

• name – The optional new name for output node.

Returns

The node performing logical or operation on input nodes corresponding elements.

ngraph.ops.lrn(data, alpha=1, beta=0.5, bias=1, size=5, name=None)[source]

Return a node which performs element-wise Local Response Normalization (LRN) operation.

Parameters
• data – Input data.

• alpha – A scale factor (usually positive).

• beta – An exponent.

• bias – An offset (usually positive) to avoid dividing by 0.

• size – Width of the 1-D normalization window.

• name – An optional name of the output node.

Returns

The new node which performs LRN.

ngraph.ops.max(node, reduction_axes=None, name=None)[source]

Max-reduction operation on input tensor, eliminating the specified reduction axes.

Parameters
• node – The tensor we want to max-reduce.

• reduction_axes – The axes to eliminate through max operation.

• name – Optional name for output node.

ngraph.ops.max_pool(x, window_shape, strides=None, padding_above=None, padding_below=None, name=None)[source]

Return max pooling node.

ngraph.ops.maximum(left_node, right_node, name=None)[source]

Return node which applies the maximum operation to input nodes elementwise.

ngraph.ops.min(node, reduction_axes=None, name=None)[source]

Min-reduction operation on input tensor, eliminating the specified reduction axes.

Parameters
• node – The tensor we want to min-reduce.

• reduction_axes – The axes to eliminate through min operation.

• name – Optional name for output node.

ngraph.ops.minimum(left_node, right_node, name=None)[source]

Return node which applies the minimum operation to input nodes elementwise.

ngraph.ops.multiply(left_node, right_node, name=None)[source]

Return node which applies f(x) = A*B to the input nodes elementwise.

ngraph.ops.mvn(data, axes, normalize_variance, eps, name=None)[source]

Perform Mean Variance Normalization operation on data from input node.

Computes MVN on the input tensor data (called X) using formula:

$Y = \dfrac{X-EX}{\sqrt{E(X-EX)^2}}$
Parameters
• data – The node with data tensor.

• axes – A list of axes, along which to reduce. Array of integers.

• normalize_variance – Flag that denotes if mean values are shared across channels. Boolen value.

• eps – The number added to the variance to avoid division by zero when normalizing the value. Scalar value.

• name – Optional output node name.

Returns

The new node performing a MVN operation on input tensor.

ngraph.ops.negative(node, name=None)[source]

Return node which applies f(x) = -x to the input node elementwise.

ngraph.ops.not_equal(left_node, right_node, name=None)[source]

Return node which checks if input nodes are unequal element-wise.

Parameters
• left_node – The first input node for not-equal operation.

• right_node – The second input node for not-equal operation.

• name – The optional name for output new node.

Returns

The node performing element-wise inequality check.

ngraph.ops.one_hot(node, shape, one_hot_axis, name=None)[source]

Create node performing one-hot encoding on input data.

Parameters
• node – The input node providing data for operation.

• shape – The output node shape including the new one-hot axis.

• one_hot_axis – The index within the output shape of the new one-hot axis.

• name – The optional name for new output node.

Returns

New node performing one-hot operation.

ngraph.ops.pad(data_batch, value, padding_below=None, padding_above=None, padding_in=None, name=None)[source]

Parameters
• data_batch – The input node providing data.

• value – The node producing the scalar value to be inserted for padding.

• name – The optional new name for output node.

Returns

Return node that represents a padding of input nodes data.

ngraph.ops.parameter(shape, dtype=<class 'numpy.float32'>, name=None)[source]

Return an ngraph Parameter object.

ngraph.ops.power(left_node, right_node, name=None)[source]

Return node which perform element-wise exponentiation operation.

Parameters
• left_node – The node providing the base of operation.

• right_node – The node providing the exponent of operation.

• name – The optional name for the new output node.

Returns

The new node performing element-wise exponentiation operation on input nodes.

ngraph.ops.prelu(data, slope, name=None)[source]

Perform Parametrized Relu operation element-wise on data from input node.

PRelu uses the following logic:

if data < 0:
data = data * slope
elif data >= 0:
data = data

Parameters
• data – The node with data tensor.

• slope – The node with the multipliers for negative values.

• name – Optional output node name.

Returns

The new node performing a PRelu operation on tensor’s channels.

ngraph.ops.prod(node, reduction_axes=None, name=None)[source]

Product-reduction operation on input tensor, eliminating the specified reduction axes.

Parameters
• node – The tensor we want to product-reduce.

• reduction_axes – The axes to eliminate through product operation.

• name – Optional name for output node.

Returns

The new node performing product-reduction operation.

ngraph.ops.relu(node, name=None)[source]

Perform rectified linear unit operation on input node element-wise.

Parameters
• node – One of: input node, array or scalar.

• name – The optional ouptut node name.

Returns

The new node performing relu operation on its input element-wise.

ngraph.ops.replace_slice(dest_node, src_node, lower_bounds, upper_bounds, strides=None, name=None)[source]

Return a copy of dest_node with the specified slice overwritten by the src_node data.

Parameters
• dest_node – The node providing data to be overwritten by the specified slice.

• src_node – The node providing data for overwriting.

• lower_bounds – The (inclusive) lower-bound coordinates for the replaced slice.

• upper_bounds – The (exclusive) upper-bound coordinates for the replaced slice.

• strides – The strides for the replaced slice.

• name – The optional name for the output new node.

Returns

The new node with copy of dest_node with the specified slice overwritten by the src_node.

ngraph.ops.reshape(node, output_shape, input_order=None, name=None)[source]

Return reshaped node according to provided parameters.

Parameters
• node – The tensor we want to reshape.

• input_order – The order in which to iterate over input axes of input tensor.

• output_shape – The new shape for input tensor.

ngraph.ops.reverse(node, reversed_axes, name=None)[source]

Perform axis-reverse operation.

Parameters
• node – The input node on which operation will be carried out.

• reversed_axes – The list of indices of axes to be reversed.

• name – The optional name of the output node.

Returns

The new node with reversed axes.

ngraph.ops.scale_shift(data, scale, shift, name=None)[source]

Perform ScaleShift transformation on input node.

Computes ScaleShift:

$Y = scale\cdot data + shift$
Parameters
• data – The node with data tensor.

• scale – The node with data tensor that scale input data.

• shift – The node with data tensor that shift input data.

• name – Optional output node name.spa

Returns

The new node performing a ScaleShift operation on input tensor.

ngraph.ops.select(selection_node, input_node1, input_node2, name=None)[source]

Perform an element-wise selection operation on input tensors.

Parameters
• selection_node – The node providing selection values of bool type.

• input_node1 – The node providing data to be selected if respective selection_node item value is True.

• input_node2 – The node providing data to be selected if respective selection_node item value is False.

• name – The optional new name for output node.

Returns

The new node with values selected according to provided arguments.

ngraph.ops.sign(node, name=None)[source]

Perform element-wise sign operation.

Parameters
• node – One of: input node, array or scalar.

• name – The optional new name for ouptut node.

Returns

The node with mapped elements of the input tensor to -1 (if it is negative), 0 (if it is zero), or 1 (if it is positive).

ngraph.ops.sin(node, name=None)[source]

Apply sine function on the input node element-wise.

Parameters
• node – One of: input node, array or scalar.

• name – Optional new name for output node.

Returns

New node with sin operation applied on it.

ngraph.ops.sinh(node, name=None)[source]

Apply hyperbolic sine function on the input node element-wise.

Parameters
• node – One of: input node, array or scalar.

• name – Optional new name for output node.

Returns

New node with sin operation applied on it.

ngraph.ops.slice(node, lower_bounds, upper_bounds, strides=None, name=None)[source]

Take a slice of an input tensor, (sub-tensor) that resides within a bounding box.

Optionally this function may be provided with stride along each axis.

Parameters
• node – The tensor we want to slice.

• lower_bounds – The (inclusive) lower-bound coordinates for the tensor slice.

• upper_bounds – The (exclusive) upper-bound coordinates for the tensor slice.

• strides – The strides for the tensor slice.

• name – Optional name for the output node.

Returns

Return node that represents a slice of input nodes data.

ngraph.ops.softmax(node, axes, name=None)[source]

Apply softmax operation on each element of input tensor.

Parameters
• node – The tensor providing input data.

• axes – The list of axes indices which are used to calculate divider of the softmax function.

• name – The optional new name for output node.

Returns

The new node with softmax operation applied on each element.

ngraph.ops.space_to_depth(data, block_size, name=None)[source]

Perform SpaceToDepth operation on the input tensor.

SpaceToDepth rearranges blocks of spatial data into depth. The operator returns a copy of the input tensor where values from the height and width dimensions are moved to the depth dimension.

Parameters
• data – The node with data tensor.

• block_size – The size of the block of values to be moved. Scalar value.

• name – Optional output node name.

Returns

The new node performing a SpaceToDepth operation on input tensor.

ngraph.ops.sqrt(node, name=None)[source]

Return node which applies square root to the input node element-wise.

Parameters
• node – One of: input node, array or scalar.

• name – Optional new name for output node.

Returns

The new node with sqrt operation applied element-wise.

ngraph.ops.subtract(left_node, right_node, name=None)[source]

Return node which applies f(x) = A-B to the input nodes element-wise.

Parameters
• left_node – The node providing data for left hand side of operator.

• right_node – The node providing data for right hand side of operator.

• name – The optional name for output node.

Returns

The new output node performing subtraction operation on both tensors element-wise.

ngraph.ops.sum(node, reduction_axes=None, name=None)[source]

Perform element-wise sums of the input tensor, eliminating the specified reduction axes.

Parameters
• node – The node providing data for operation.

• reduction_axes – The axes to eliminate through summation.

• name – The optional new name for ouptut node.

Returns

The new node performing summation along reduction_axes element-wise.

ngraph.ops.tan(node, name=None)[source]

Apply tangent function on the input node element-wise.

Parameters
• node – One of: input node, array or scalar.

• name – Optional new name for output node.

Returns

New node with tan operation applied on it.

ngraph.ops.tanh(node, name=None)[source]

Return node which applies hyperbolic tangent to the input node element-wise.

Parameters
• node – One of: input node, array or scalar.

• name – Optional new name for output node.

Returns

New node with tanh operation applied on it.

ngraph.ops.topk(data, k, kaxis=-1, cmax=True)[source]

Return a node which performs TopK.

Parameters
• data – Input data.

• kaxis – TopK Axis.

• k

• cmax – Compute TopK largest (True) or smallest (False)

Returns

The new node which performs TopK (both indices and values)

ngraph.ops.unsqueeze(data, axes, name=None)[source]

Perform unsqueeze operation on input tensor.

Insert single-dimensional entries to the shape of a tensor. Takes one required argument axes, a list of dimensions that will be inserted. Dimension indices in axes are as seen in the output tensor.

For example: Inputs: tensor with shape [3, 4, 5], axes=[0, 4]

Result: tensor with shape [1, 3, 4, 5, 1]

Parameters
• data – The node with data tensor.

• axes – List of non-negative integers, indicate the dimensions to be inserted. One of: input node or array.

Returns

The new node performing an unsqueeze operation on input tensor.

## ngraph.runtime module¶

Provide a layer of abstraction for the ngraph++ runtime environment.

class ngraph.runtime.Computation(runtime, ng_function)[source]

Bases: object

ngraph callable computation object.

serialize(indent=0)[source]

Serialize function (compute graph) to a JSON string.

Parameters

indent – set indent of serialized output

Returns

serialized model

class ngraph.runtime.Runtime(backend_name)[source]

Bases: object

Represents the ngraph++ runtime environment.

computation(node_or_function, *inputs)[source]

Return a callable Computation object.

ngraph.runtime.runtime(backend_name='CPU')[source]

Create a Runtime object (helper factory).

Use signature to parameterize runtime as needed.