NNVM Core Tensor Operators

This page contains the list of core tensor operator primitives pre-defined in NNVM. The core tensor operator primitives(nnvm.top) covers typical workloads in deep learning. They can represent workloads in front-end frameworks, and provide basic building blocks for optimization. Since deep learning is a fast evolving field and it is that possible to have operators that are not in here. NNVM is designed for this problem and can easily new operators without changing the core library.

Note

Each operator node in the graph IR contains the following two kinds of parameters.

  • inputs: positional list of input tensors

  • attrs: attributes about operator(e.g. kernel_size in conv2d)

This document lists both inputs and attributes in the parameter field. You can distinguish them by the marked type. The inputs are of type Tensor, while the rest parameters are attributes. To construct the graph with NNVM python API, a user can pass in the input Tensors as positional arguments, and attributes as keyword arguments.

Overview of Operators

Level 1: Basic Operators

This level enables fully connected multi-layer perceptron.

nnvm.symbol.dense

Applies a linear transformation: \(Y = XW^T + b\).

nnvm.symbol.relu

Computes rectified linear.

nnvm.symbol.prelu

Parametric version of a Rectified Linear Unit.

nnvm.symbol.tanh

Computes hyperbolic tangent.

nnvm.symbol.sigmoid

Computes sigmoid.

nnvm.symbol.exp

Returns the exp input array, computed element-wise.

nnvm.symbol.log

Returns the log input array, computed element-wise.

nnvm.symbol.sqrt

Returns the sqrt input array, computed element-wise.

nnvm.symbol.logical_and

Elementwise compute the logical AND

nnvm.symbol.logical_or

Elementwise compute the logical OR

nnvm.symbol.logical_not

Elementwise compute the logical NOT

nnvm.symbol.elemwise_add

Element-wise add

nnvm.symbol.elemwise_sub

Element-wise substraction

nnvm.symbol.elemwise_mul

Element-wise multiplication

nnvm.symbol.elemwise_div

Element-wise division

nnvm.symbol.elemwise_sum

Adds all input arguments element-wise.

nnvm.symbol.elemwise_mod

Element-wise modulo

nnvm.symbol.elemwise_pow

Element-wise power

nnvm.symbol.flatten

Flattens the input into a 2-D array.

nnvm.symbol.concatenate

Joins input arrays along a given axis.

nnvm.symbol.expand_dims

Inserts a new axis of size 1 into the array shape

nnvm.symbol.squeeze

Squeeze axises in the array.

nnvm.symbol.split

Splits an array along a particular axis into multiple sub-arrays.

nnvm.symbol.dropout

Applies dropout operation to input array.

nnvm.symbol.batch_norm

Batch normalization layer (Ioffe and Szegedy, 2014).

nnvm.symbol.softmax

Computes softmax.

nnvm.symbol.log_softmax

Computes log softmax.

nnvm.symbol.pad

Pad for n-D tensor.

nnvm.symbol.block_grad

Blocks gradient computation for input.

nnvm.symbol.matmul

Matrix multiplication of two arrays.

nnvm.symbol.resize

Perform resize to input array with nearest neighbour or bilinear interpolation.

nnvm.symbol.upsampling

Perform upsampling to input array with nearest neighbour or bilinear interpolation.

nnvm.symbol.take

Take elements from an array along an axis.

nnvm.symbol.l2_normalize

L2NORMALIZE layer

nnvm.symbol.flip

Reverse the elements of an array.

nnvm.symbol.lrn

LRN layer

nnvm.symbol.where

Return the elements, either from x or y, depending on the condition.

nnvm.symbol.gather_nd

Gather elements or slices from data into a tensor specified by indices.

Level 2: Convolutions

This level enables typical convnet models.

nnvm.symbol.conv2d

2D convolution layer (e.g.

nnvm.symbol.conv2d_transpose

Transposed 2D convolution layer (sometimes called Deconvolution).

nnvm.symbol.max_pool2d

Max pooling operation for one dimensional data.

nnvm.symbol.avg_pool2d

Average pooling operation for one dimensional data.

nnvm.symbol.global_max_pool2d

Global max pooling operation for 2D data.

nnvm.symbol.global_avg_pool2d

Global average pooling operation for 2D data.

Level 3: Additional Tensor Ops

nnvm.symbol.reshape

Reshapes the input array.

nnvm.symbol.copy

Copy tensor to another one.

nnvm.symbol.negative

Elemenwise numeric negative

nnvm.symbol.floor

Take floor input array, computed element-wise.

nnvm.symbol.ceil

Take ceil input array, computed element-wise.

nnvm.symbol.round

Round elements of the input to nearest integer.

nnvm.symbol.trunc

Take truncated value of the input, element-wise.

nnvm.symbol.abs

Take absolute value of elements of the input.

nnvm.symbol.leaky_relu

Leaky version of a Rectified Linear Unit.

nnvm.symbol.__add_scalar__

Tensor add scalar

nnvm.symbol.__sub_scalar__

Tensor substract scalar

nnvm.symbol.__rsub_scalar__

scalar substract Tensor

nnvm.symbol.__mul_scalar__

Tensor multiplies scalar

nnvm.symbol.__div_scalar__

Tensor divides scalar

nnvm.symbol.__rdiv_scalar__

scalar divides Tensor

nnvm.symbol.__pow_scalar__

Tensor power scalar

nnvm.symbol.__rpow_scalar__

scalar power Tensor

nnvm.symbol.__lshift_scalar__

Tensor left shift by scalar

nnvm.symbol.__rshift_scalar__

Tensor right shift by scalar

Level 4: Broadcast and Reductions

nnvm.symbol.transpose

Permutes the dimensions of an array.

nnvm.symbol.broadcast_to

Broadcasts the input array to a new shape.

nnvm.symbol.sum

Computes the sum of array elements over given axes.

nnvm.symbol.min

Computes the min of array elements over given axes.

nnvm.symbol.max

Computes the max of array elements over given axes.

nnvm.symbol.mean

Computes the mean of array elements over given axes.

nnvm.symbol.prod

Computes the products of array elements over given axes.

nnvm.symbol.broadcast_add

Returns element-wise sum of the input arrays with broadcasting.

nnvm.symbol.broadcast_sub

Returns element-wise difference of the input arrays with broadcasting.

nnvm.symbol.broadcast_mul

Returns element-wise product of the input arrays with broadcasting.

nnvm.symbol.broadcast_div

Returns element-wise division of the input arrays with broadcasting.

nnvm.symbol.clip

Clips (limits) the values in an array.

nnvm.symbol.greater

Greater function that returns a mask tensor with 1.0 if (left > right), otherwise 0.0 element-wise.

nnvm.symbol.less

Less function that returns a mask tensor with 1.0 if (left < right), otherwise 0.0 element-wise.

nnvm.symbol.expand_like

Expand an input array with the shape of second array.

nnvm.symbol.reshape_like

Reshapes the input array by the size of another array.

nnvm.symbol.full

Fill array with scalar value

nnvm.symbol.full_like

Return an scalar value array with the same shape and type as the input array

nnvm.symbol.ones

Fill target with ones

nnvm.symbol.ones_like

Return an array of ones with the same shape and type as the input array.

nnvm.symbol.zeros

Fill target with zeros

nnvm.symbol.zeros_like

Return an array of zeros with the same shape and type as the input array.

nnvm.symbol.slice_like

Slice the first input respect to the second input.

nnvm.symbol.strided_slice

Strided slice of an array.

nnvm.symbol.argmax

Creates an operation that finds the indices of the maximum values over a given axis.

nnvm.symbol.argmin

Creates an operation that finds the indices of the minimum values over a given axis.

nnvm.symbol.collapse_sum

Reduces lhs to the shape of rhs via sum

nnvm.symbol.broadcast_equal

Returns element-wise x == y of the input arrays with broadcasting.

nnvm.symbol.broadcast_greater_equal

Returns element-wise x >= y of the input arrays with broadcasting.

nnvm.symbol.broadcast_greater

Returns element-wise x > y of the input arrays with broadcasting.

nnvm.symbol.broadcast_left_shift

Returns element-wise x << y of the input arrays with broadcasting.

nnvm.symbol.broadcast_less_equal

Returns element-wise x <= y of the input arrays with broadcasting.

nnvm.symbol.broadcast_less

Returns element-wise x < y of the input arrays with broadcasting.

nnvm.symbol.broadcast_max

Returns element-wise max of the input arrays with broadcasting.

nnvm.symbol.broadcast_min

Returns element-wise minimum of the input arrays with broadcasting.

nnvm.symbol.broadcast_mod

Returns element-wise mod of the input arrays with broadcasting.

nnvm.symbol.broadcast_not_equal

Returns element-wise x != y of the input arrays with broadcasting.

nnvm.symbol.broadcast_pow

Returns element-wise x^y of the input arrays with broadcasting.

nnvm.symbol.broadcast_right_shift

Returns element-wise x >> y of the input arrays with broadcasting.

Level 5: Vision Operators

nnvm.symbol.multibox_prior

“Generate prior(anchor) boxes from data, sizes and ratios.”

nnvm.symbol.multibox_transform_loc

“Location transformation for multibox detection.”

nnvm.symbol.nms

nnvm.symbol.yolo_region

nnvm.symbol.yolo_reorg

Perform reorg operation on input array based on the stride value.

Detailed Definitions

nnvm.symbol.dense(*args, **kwargs)

Applies a linear transformation: \(Y = XW^T + b\).

  • data: (x1, x2, …, xn, input_dim)

  • weight: (units, input_dim)

  • bias: (units,)

  • out: (x1, x2, …, xn, units)

The learnable parameters include both weight and bias.

If use_bias is set to be false, then the bias term is ignored.

Defined in /workspace/nnvm/src/top/nn/nn.cc:L95

Parameters
  • data (nD Tensor) – Input data.

  • weight (2D Tensor) – Weight matrix.

  • bias (1D Tensor) – Bias parameter.

  • units (int, required) – Number of hidden units of the dense transformation.

  • use_bias (boolean, optional, default=1) – Whether to use bias parameter

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.relu(*args, **kwargs)

Computes rectified linear.

\[max(input, 0)\]

Defined in /workspace/nnvm/src/top/nn/nn.cc:L146

Parameters

data (Tensor) – The input tensor.

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.prelu(*args, **kwargs)

Parametric version of a Rectified Linear Unit. It accepts two arguments: an input x and a channelwise slope alpha and computes the output as \(PReLU(x) y = x > 0 ? x : alpha * x\), where \(*\) is an channelwise multiplication for each sample in the

Defined in /workspace/nnvm/src/top/nn/nn.cc:L567

Parameters
  • data (Tensor) – Input data.

  • alpha (Tensor) – Input channelwise alpha.

  • axis (int, optional, default='1') – Specify which shape axis the channel is specified.

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.tanh(*args, **kwargs)

Computes hyperbolic tangent.

\[Y = sinh(X) / cosh(X)\]

Defined in /workspace/nnvm/src/top/tensor/elemwise.cc:L151

Parameters

data (Tensor) – The input tensor.

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.sigmoid(*args, **kwargs)

Computes sigmoid.

\[Y = 1 / (1 + exp(-X))\]

Defined in /workspace/nnvm/src/top/tensor/elemwise.cc:L121

Parameters

data (Tensor) – The input tensor.

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.exp(*args, **kwargs)

Returns the exp input array, computed element-wise.

\[exp(x)\]

Defined in /workspace/nnvm/src/top/tensor/elemwise.cc:L181

Parameters

data (Tensor) – The input tensor.

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.log(*args, **kwargs)

Returns the log input array, computed element-wise.

\[log(x)\]

Defined in /workspace/nnvm/src/top/tensor/elemwise.cc:L207

Parameters

data (Tensor) – The input tensor.

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.sqrt(*args, **kwargs)

Returns the sqrt input array, computed element-wise.

\[\sqrt(x)\]

Defined in /workspace/nnvm/src/top/tensor/elemwise.cc:L233

Parameters

data (Tensor) – The input tensor.

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.logical_and(*args, **kwargs)

Elementwise compute the logical AND

Parameters
  • lhs (Tensor) – first input

  • rhs (Tensor) – second input

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.logical_or(*args, **kwargs)

Elementwise compute the logical OR

Parameters
  • lhs (Tensor) – first input

  • rhs (Tensor) – second input

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.logical_not(*args, **kwargs)

Elementwise compute the logical NOT

Defined in /workspace/nnvm/src/top/tensor/elemwise.cc:L433

Parameters

data (Tensor) – The input tensor.

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.elemwise_add(*args, **kwargs)

Element-wise add

Parameters
  • lhs (Tensor) – first input

  • rhs (Tensor) – second input

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.elemwise_sub(*args, **kwargs)

Element-wise substraction

Defined in /workspace/nnvm/src/top/tensor/elemwise.cc:L282

Parameters
  • lhs (Tensor) – first input

  • rhs (Tensor) – second input

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.elemwise_mul(*args, **kwargs)

Element-wise multiplication

Defined in /workspace/nnvm/src/top/tensor/elemwise.cc:L305

Parameters
  • lhs (Tensor) – first input

  • rhs (Tensor) – second input

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.elemwise_div(*args, **kwargs)

Element-wise division

Defined in /workspace/nnvm/src/top/tensor/elemwise.cc:L330

Parameters
  • lhs (Tensor) – first input

  • rhs (Tensor) – second input

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.elemwise_sum(*args, **kwargs)

Adds all input arguments element-wise.

Defined in /workspace/nnvm/src/top/tensor/elemwise.cc:L832

Parameters

args (Symbol[]) – Positional input arguments

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.elemwise_mod(*args, **kwargs)

Element-wise modulo

Defined in /workspace/nnvm/src/top/tensor/elemwise.cc:L361

Parameters
  • lhs (Tensor) – first input

  • rhs (Tensor) – second input

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.elemwise_pow(*args, **kwargs)

Element-wise power

Defined in /workspace/nnvm/src/top/tensor/elemwise.cc:L373

Parameters
  • lhs (Tensor) – first input

  • rhs (Tensor) – second input

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.flatten(*args, **kwargs)

Flattens the input into a 2-D array.

For an input array with shape (d1, d2, ..., dk), flatten operation reshapes the input array into an output array of shape (d1, d2*...*dk).

Example:

x = [[
    [1,2,3],
    [4,5,6],
    [7,8,9]
],
[   [1,2,3],
    [4,5,6],
    [7,8,9]
]],

flatten(x) = [[ 1.,  2.,  3.,  4.,  5.,  6.,  7.,  8.,  9.],
   [ 1.,  2.,  3.,  4.,  5.,  6.,  7.,  8.,  9.]]

Defined in /workspace/nnvm/src/top/tensor/transform.cc:L83

Parameters

data (Tensor) – Input data.

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.concatenate(*args, **kwargs)

Joins input arrays along a given axis.

The dimensions of the input arrays should be the same except the axis along which they will be concatenated. The dimension of the output array along the concatenated axis will be equal to the sum of the corresponding dimensions of the input arrays.

Example:

x = [[1,1],[2,2]]
y = [[3,3],[4,4],[5,5]]
z = [[6,6], [7,7],[8,8]]

concatenate(x,y,z,axis=0) = [[ 1.,  1.],
                            [ 2.,  2.],
                            [ 3.,  3.],
                            [ 4.,  4.],
                            [ 5.,  5.],
                            [ 6.,  6.],
                            [ 7.,  7.],
                            [ 8.,  8.]]

Note that you cannot concat x,y,z along dimension 1 since dimension
0 is not the same for all the input arrays.

concatenate(y,z,axis=1) = [[ 3.,  3.,  6.,  6.],
                          [ 4.,  4.,  7.,  7.],
                          [ 5.,  5.,  8.,  8.]]

Defined in /workspace/nnvm/src/top/tensor/transform.cc:L208

Parameters
  • data (Tensor-or-Tensor[]) – List of arrays to concatenate

  • axis (int, optional, default='1') – the axis to be concated.

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.expand_dims(*args, **kwargs)

Inserts a new axis of size 1 into the array shape

For example, given x with shape (2,3,4), then expand_dims(x, axis=1, num_newaxis=5) will return a new array with shape (2,1,1,1,1,1,3,4).

Defined in /workspace/nnvm/src/top/tensor/transform.cc:L261

Parameters
  • data (Tensor) – Input tensor

  • axis (int, required) – the axis to be expanded.

  • num_newaxis (int, optional, default='1') – Number of new axis to be inserted.

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.squeeze(*args, **kwargs)

Squeeze axises in the array.

Examples:

x = [[[0], [1], [2]]]
x.shape = (1, 3, 1)

squeeze(x) = [0, 1, 2]

squeeze(x, 0) = [[0], [1], [2]]

squeeze(x, (0, 2)) = [0, 1, 2]

Defined in /workspace/nnvm/src/top/tensor/transform.cc:L762

Parameters
  • data (Tensor) – Source input

  • axis (, optional, default=[]) – The axis to squeeze in the input tensor.

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.split(*args, **kwargs)

Splits an array along a particular axis into multiple sub-arrays.

Note that indices_or_sections should evenly divide the length of the axis along which to split the array.

Defined in /workspace/nnvm/src/top/tensor/transform.cc:L423

Parameters
  • data (Tensor) – Array to be splitted

  • indices_or_sections (tuple of <int>, required) – Number of outputs to be splitted

  • axis (int, optional, default='1') – the axis to be splitted.

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.dropout(*args, **kwargs)

Applies dropout operation to input array.

  • During training, each element of the input is set to zero with probability p. The whole array is rescaled by \(1/(1-p)\) to keep the expected sum of the input unchanged.

Defined in /workspace/nnvm/src/top/nn/nn.cc:L179

Parameters
  • data (Tensor) – Input to which dropout will be applied

  • rate (float, optional, default=0.5) – Fraction of the input that gets dropped out during training time.

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.batch_norm(*args, **kwargs)

Batch normalization layer (Ioffe and Szegedy, 2014). Normalizes the input at each batch, i.e. applies a transformation that maintains the mean activation close to 0 and the activation standard deviation close to 1.

\[\begin{split}data\_mean[i] = mean(data[:,i,:,...]) \\ data\_var[i] = var(data[:,i,:,...])\end{split}\]

Then compute the normalized output, which has the same shape as input, as following:

\[out[:,i,:,...] = \frac{data[:,i,:,...] - data\_mean[i]}{\sqrt{data\_var[i]+\epsilon}} * gamma[i] + beta[i]\]

Both mean and var returns a scalar by treating the input as a vector.

Assume the input has size k on axis 1, then both gamma and beta have shape (k,).

Besides the inputs and the outputs, this operator accepts two auxiliary states, moving_mean and moving_var, which are k-length vectors. They are global statistics for the whole dataset, which are updated by:

moving_mean = moving_mean * momentum + data_mean * (1 - momentum)
moving_var = moving_var * momentum + data_var * (1 - momentum)

The parameter axis specifies which axis of the input shape denotes the ‘channel’ (separately normalized groups). The default is 1. Specifying -1 sets the channel axis to be the last item in the input shape.

Note

This operator can be optimized away for inference.

Defined in /workspace/nnvm/src/top/nn/nn.cc:L319

Parameters
  • data (Tensor) – Input to which dropout will be applied

  • gamma (Tensor) – The gamma scale factor

  • beta (Tensor) – The beta offset factor

  • moving_mean (Tensor) – running mean of input

  • moving_var (Tensor) – running variance of input

  • axis (int, optional, default='1') – Specify which shape axis the channel is specified.

  • epsilon (double, optional, default=1.0000000000000001e-05) – Small float added to variance to avoid dividing by zero.

  • center (boolean, optional, default=1) – If True, add offset of beta to normalized tensor.If False, beta is ignored.

  • scale (boolean, optional, default=1) – If True, multiply by gamma. If False, gamma is not used.When the next layer is piecewise linear (also e.g. nn.relu),this can be disabled since the scalingwill be done by the next layer.

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.softmax(*args, **kwargs)

Computes softmax.

\[\text{softmax}(x)_i = \frac{exp(x_i)}{\sum_j exp(x_j)}\]

Note

This operator can be optimized away for inference.

Defined in /workspace/nnvm/src/top/nn/nn.cc:L357

Parameters
  • data (Tensor) – Input data.

  • axis (int, optional, default='-1') – The axis to sum over when computing softmax.

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.log_softmax(*args, **kwargs)

Computes log softmax.

\[\text{log_softmax}(x)_i = \log \frac{exp(x_i)}{\sum_j exp(x_j)}\]

Note

This operator can be optimized away for inference.

Defined in /workspace/nnvm/src/top/nn/nn.cc:L416

Parameters
  • data (Tensor) – Input data.

  • axis (int, optional, default='-1') – The axis to sum over when computing softmax.

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.pad(*args, **kwargs)

Pad for n-D tensor.

Defined in /workspace/nnvm/src/top/nn/nn.cc:L613

Parameters
  • data (n-D Tensor) – Input data.

  • pad_value (float, optional, default=0) – The value to be padded.

  • pad_width (tuple of <tuple of <int>>, required) – Number of values padded to the edges of each axis, in the format of ((before_1, after_1), … (before_N, after_N))

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.block_grad(*args, **kwargs)

Blocks gradient computation for input.

Defined in /workspace/nnvm/src/top/tensor/elemwise.cc:L856

Parameters

data (Tensor) – The input tensor.

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.matmul(*args, **kwargs)

Matrix multiplication of two arrays.

dot’s behavior depends on the input array dimensions:

  • 1-D arrays: inner product of vectors

  • 2-D arrays: matrix multiplication

  • N-D arrays: a sum product over the last axis of the first input and the first axis of the second input

    For example, given 3-D x with shape (n,m,k) and y with shape (k,r,s), the result array will have shape (n,m,r,s). It is computed by:

    dot(x,y) = sum(x[i,j,:]*y[:,a,b])
    

Defined in /workspace/nnvm/src/top/tensor/matrix_op.cc:L106

Parameters
  • transpose_a (boolean, optional, default=0) – If true then transpose the first input before dot.

  • transpose_b (boolean, optional, default=0) – If true then transpose the second input before dot.

  • lhs (NDArray-or-Symbol) – The first input

  • rhs (NDArray-or-Symbol) – The second input

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.resize(*args, **kwargs)

Perform resize to input array with nearest neighbour or bilinear interpolation.

  • data: data is 4D array of shape

    (batch_size, channels, in_height, in_width) for NCHW (batch_size, in_height, in_width, channels) for NHWC

  • out: Output is 4D array of shape

    for layout NCHW (batch_size, channels, size[0], size[1])

    for layout NHWC (batch_size, size[0], size[1], channels)

Defined in /workspace/nnvm/src/top/image/resize.cc:L97

Parameters
  • data (4D Tensor) – Input data.

  • size (, required) – Output size

  • layout (string, optional, default='NCHW') – Dimension ordering of data. Can be ‘NCHW’, ‘NHWC’, etc.’N’, ‘C’, ‘H’, ‘W’ stands for batch, channel, height, and widthdimensions respectively. Resize is applied on the ‘H’ and’W’ dimensions.

  • method (string, optional, default='BILINEAR') – Specify the mode to use for scaling.NEAREST_NEIGHBOR - Nearest NeighborBILINEAR - Bilinear Interpolation

  • align_corners (boolean, optional, default=0) – Should be true to preserve the values at the corner pixels

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.upsampling(*args, **kwargs)

Perform upsampling to input array with nearest neighbour or bilinear interpolation.

  • data: data is 4D array of shape

    (batch_size, channels, in_height, in_width) for NCHW (batch_size, in_height, in_width, channels) for NHWC

  • out: Output is 4D array of shape

    for layout NCHW (batch_size, channels, in_height*scale, in_width*scale)

    for layout NHWC (batch_size, in_height*scale, in_width*scale, channels)

Defined in /workspace/nnvm/src/top/nn/upsampling.cc:L95

Parameters
  • data (4D Tensor) – Input data.

  • scale (int, required) – upsampling scaling factor

  • layout (string, optional, default='NCHW') – Dimension ordering of data. Can be ‘NCHW’, ‘NHWC’, etc.’N’, ‘C’, ‘H’, ‘W’ stands for batch, channel, height, and widthdimensions respectively. Upsampling is applied on the ‘H’ and’W’ dimensions.

  • method (string, optional, default='NEAREST_NEIGHBOR') – Specify the mode to use for scaling.NEAREST_NEIGHBOR - Nearest NeighborBILINEAR - Bilinear Interpolation

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.take(*args, **kwargs)

Take elements from an array along an axis.

When axis is not None, this function does the same thing as ‘fancy’ indexing (indexing arrays using arrays); however, it can be easier to use if you need elements along a given axis.

Note that when axis is none the flattened input array is used.

Examples:

a = [[ 1, 2],
     [ 3, 4]]
indices = [3, 0, 2]
take(a, indices) = [ 4, 1, 3]

a = [[ 1., 2.],
     [ 3., 4.]]
indices = [1, 0]
take(a, indices, axis=1) = [[ 2., 1.],
                            [ 4., 3.]]

Defined in /workspace/nnvm/src/top/tensor/transform.cc:L1166

Parameters
  • data (Tensor) – Array to be indexed

  • indices (Tensor) – The indices of the values to extract

  • axis (int or None, optional, default='None') – the axis over which to select values.

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.l2_normalize(*args, **kwargs)

L2NORMALIZE layer

Defined in /workspace/nnvm/src/top/nn/nn.cc:L736

Parameters

data (4D Tensor) – Input data.

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.flip(*args, **kwargs)

Reverse the elements of an array.

Examples:

x = [[ 1, 2],
     [ 3, 4]]

flip(x) = [[ 3.,  4.],
           [ 1.,  2.]]

x = [[[ 1.,  2.],
      [ 3.,  4.]],

     [[ 5.,  6.],
      [ 7.,  8.]]]

flip(x) = [[[ 5.,  6.],
            [ 7.,  8.]],

           [[ 1.,  2.],
            [ 3.,  4.]]]

flip(x, axis=1) = [[[ 3.,  4.],
                    [ 1.,  2.]],

                   [[ 7.,  8.],
                    [ 5.,  6.]]]

Defined in /workspace/nnvm/src/top/tensor/transform.cc:L1054

Parameters
  • data (Tensor) – Source input

  • axis (int, optional, default='0') – the axis to be reveresed.

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.lrn(*args, **kwargs)

LRN layer

Defined in /workspace/nnvm/src/top/nn/nn.cc:L713

Parameters

data (4D Tensor) – Input data.

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.where(*args, **kwargs)

Return the elements, either from x or y, depending on the condition.

Given three ndarrays, condition, x, and y, return an ndarray with the elements from x or y, depending on the elements from condition are true or false. x and y must have the same shape. If condition has the same shape as x, each element in the output array is from x if the corresponding element in the condition is true, and from y if false.

If condition does not have the same shape as x, it must be a 1D array whose size is the same as x’s first dimension size. Each row of the output array is from x’s row if the corresponding element from condition is true, and from y’s row if false.

Note that all non-zero values are interpreted as True in condition.

Examples:

x = [[1, 2], [3, 4]]
y = [[5, 6], [7, 8]]
cond = [[0, 1], [-1, 0]]
where(cond, x, y) = [[5, 2], [3, 8]]


cond = [1, 0]
where(cond, x, y) = [[1, 2], [7, 8]]

Defined in /workspace/nnvm/src/top/tensor/transform.cc:L1375

Parameters
  • condition (Tensor) – Condition array

  • x (Tensor) – First array to be selected

  • y (Tensor) – Second array to be selected

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.gather_nd(*args, **kwargs)

Gather elements or slices from data into a tensor specified by indices.

The shape of output tensor is inferred from indices. Given data with shape (X0, X1, ..., X_{N-1}) and indices with shape (Y_0, ..., Y_{M-1}), the output will have shape (Y_1, ..., Y_{M-1}, X_{Y_0}, ..., X_{N-1}) when Y_0 < N, or (Y_1, ..., Y_{M-1}) when Y_0 == N. The operator is invalid when Y_0 > N.

The element in output is defined as follows:

output[y_1, ..., y_{M-1}, x_{Y_0}, ..., x_{N-1}] = data[indices[0, y_1, ..., y_{M-1}],
                                                   ...,
                                                   indices[Y_0-1, y_1, ..., y_{M-1}],
                                                   x_{Y_0}, ..., x_{N-1}]

Examples:

data = [[0, 1], [2, 3]]
indices = [[1], [0]]
gather_nd(data, indices) = [2]

data = [[0, 1], [2, 3]]
indices = [[1, 1, 0], [0, 1, 0]]
gather_nd(data, indices) = [2, 3, 0]

data = [[[1, 2], [3, 4]], [[5, 6], [7, 8]]]
indices = [[0, 1], [1, 0]]
gather_nd(data, indices) = [[3, 4], [5, 6]]

Defined in /workspace/nnvm/src/top/tensor/transform.cc:L1479

Parameters
  • data (Tensor) – Input data.

  • indices (Tensor) – Indices of data

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.conv2d(*args, **kwargs)

2D convolution layer (e.g. spatial convolution over images).

This layer creates a convolution kernel that is convolved with the layer input to produce a tensor of outputs. If use_bias is True, a bias vector is created and added to the outputs.

  • data: This depends on the layout parameter. Input is 4D array of shape

    (batch_size, in_channels, height, width) if layout is NCHW.

  • weight: (channels, in_channels, kernel_size[0], kernel_size[1])

  • bias: (channels,)

  • out: This depends on the layout parameter. Output is 4D array of shape

    (batch_size, channels, out_height, out_width) if layout is NCHW.

Defined in /workspace/nnvm/src/top/nn/convolution.cc:L326

Parameters
  • data (4D Tensor) – Input data.

  • weight (4D Tensor) – Weight matrix.

  • bias (1D Tensor) – Bias parameter.

  • channels (int, required) – The dimensionality of the output spacei.e. the number of output channels in the convolution.

  • kernel_size (, required) – Specifies the dimensions of the convolution window.

  • strides (, optional, default=[1,1]) – Specifies the strides of the convolution.

  • padding (, optional, default=[0,0]) – If padding is non-zero, then the input is implicitly zero-paddedon both sides for padding number of points

  • dilation (, optional, default=[1,1]) – Specifies the dilation rate to use for dilated convolution.

  • groups (int, optional, default='1') – Controls the connections between inputs and outputs.At groups=1, all inputs are convolved to all outputs.At groups=2, the operation becomes equivalent to having two convolutionlayers side by side, each seeing half the input channels, and producinghalf the output channels, and both subsequently concatenated.

  • layout (string, optional, default='NCHW') – Dimension ordering of input data. Can be ‘NCHW’, ‘NHWC’, etc.’N’, ‘C’, ‘H’, ‘W’ stands for batch, channel, height, and widthdimensions respectively. Convolution is applied on the ‘H’ and’W’ dimensions.

  • out_layout (string, optional, default='__undef__') – Dimension ordering of output. Can be ‘NCHW’, ‘NHWC’, etc.’N’, ‘C’, ‘H’, ‘W’ stands for batch, channel, height, and widthdimensions respectively. Default to be same as input layout.

  • kernel_layout (string, optional, default='OIHW') – Dimension ordering of weight. Can be ‘OIHW’, ‘OIHW16o16i’, etc.’O’, ‘I’, ‘H’, ‘W’ stands for num_filter, input_channel, height, and widthdimensions respectively.

  • out_dtype ({'float16', 'float32', 'float64', 'int16', 'int32', 'int64', 'int8', 'same', 'uint16', 'uint32', 'uint64', 'uint8'},optional, default='same') – Output data type, set to explicit type under mixed precision setting

  • use_bias (boolean, optional, default=1) – Whether the layer uses a bias vector.

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.conv2d_transpose(*args, **kwargs)

Transposed 2D convolution layer (sometimes called Deconvolution).

The need for transposed convolutions generally arises from the desire to use a transformation going in the opposite direction of a normal convolution, i.e., from something that has the shape of the output of some convolution to something that has the shape of its input while maintaining a connectivity pattern that is compatible with said convolution.

  • data: This depends on the layout parameter. Input is 4D array of shape

    (batch_size, in_channels, height, width) if layout is NCHW.

  • weight: (in_channels, channels, kernel_size[0], kernel_size[1])

  • bias: (channels,)

  • out: This depends on the layout parameter. Output is 4D array of shape

v (batch_size, channels, out_height, out_width) if layout is NCHW.

out_height and out_width are calculated as::

out_height = (height-1)*strides[0]-2*padding[0]+kernel_size[0]+output_padding[0] out_width = (width-1)*strides[1]-2*padding[1]+kernel_size[1]+output_padding[1]

Defined in /workspace/nnvm/src/top/nn/convolution.cc:L644

Parameters
  • data (4D Tensor) – Input data.

  • weight (4D Tensor) – Weight matrix.

  • bias (1D Tensor) – Bias parameter.

  • channels (int, required) – The dimensionality of the output spacei.e. the number of output channels in the convolution.

  • kernel_size (, required) – Specifies the dimensions of the convolution window.

  • strides (, optional, default=[1,1]) – Specifies the strides of the convolution.

  • output_padding (, optional, default=[0,0]) – Zero-padding added to one side of the output.

  • padding (, optional, default=[0,0]) – If padding is non-zero, then the input is implicitly zero-paddedon both sides for padding number of points

  • dilation (, optional, default=[1,1]) – Specifies the dilation rate to use for dilated convolution.

  • groups (int, optional, default='1') – Controls the connections between inputs and outputs.At groups=1, all inputs are convolved to all outputs.At groups=2, the operation becomes equivalent to having two convolutionlayers side by side, each seeing half the input channels, and producinghalf the output channels, and both subsequently concatenated.

  • layout (string, optional, default='NCHW') – Dimension ordering of data. Can be ‘NCHW’, ‘NHWC’, etc.’N’, ‘C’, ‘H’, ‘W’ stands for batch, channel, height, and widthdimensions respectively. Convolution is applied on the ‘H’ and’W’ dimensions.

  • kernel_layout (string, optional, default='OIHW') – Dimension ordering of data and weight. Can be ‘OIHW’, ‘OIHW16o16i’, etc.’O’, ‘I’, ‘H’, ‘W’ stands for num_filter, input_channel, height, and widthdimensions respectively.

  • out_dtype ({'float16', 'float32', 'float64', 'int16', 'int32', 'int64', 'int8', 'same', 'uint16', 'uint32', 'uint64', 'uint8'},optional, default='same') – Output data type, set to explicit type under mixed precision setting

  • use_bias (boolean, optional, default=1) – Whether the layer uses a bias vector.

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.max_pool2d(*args, **kwargs)

Max pooling operation for one dimensional data.

  • data: This depends on the layout parameter. Input is 4D array of shape

    (batch_size, channels, height, width) if layout is NCHW.

  • out: This depends on the layout parameter. Output is 4D array of shape

    (batch_size, channels, out_height, out_width) if layout is NCHW. out_height and out_width are calculated as:

    out_height = floor((height+padding[0]+padding[2]-pool_size[0])/strides[0])+1
    out_width = floor((width+padding[1]+padding[3]-pool_size[1])/strides[1])+1
    
    where padding will be an expanded array based on number of values passed as::

    one int : all sides same padding used. two int : bottom, right use same as top and left. four int: padding width in the order of (top, left, bottom, right).

    When ceil_mode is True, ceil will be used instead of floor in this equation.

Defined in /workspace/nnvm/src/top/nn/pooling.cc:L157

Parameters
  • data (4D Tensor) – Input data.

  • pool_size (, required) – Size of the pooling windows..

  • strides (, optional, default=[1,1]) – Specifies the strides of the convolution.

  • padding (, optional, default=[0,0]) – If padding is non-zero, then the input is implicitly zero-paddedPadding support both symmetric and asymmetric asone int : same padding used on all sidestwo int : bottom, right will use same padding as top, leftfour int : padding width in the order of (top, left, bottom, right)

  • layout (string, optional, default='NCHW') – Dimension ordering of data and weight. Can be ‘NCHW’, ‘NHWC’, etc.’N’, ‘C’, ‘H’, ‘W’ stands for batch, channel, height, and widthdimensions respectively. Convolution is applied on the ‘H’ and’W’ dimensions.

  • ceil_mode (boolean, optional, default=0) – When true, will use ceil instead of floor to compute the output shape.

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.avg_pool2d(*args, **kwargs)

Average pooling operation for one dimensional data.

  • data: This depends on the layout parameter. Input is 4D array of shape

    (batch_size, channels, height, width) if layout is NCHW.

  • out: This depends on the layout parameter. Output is 4D array of shape

    (batch_size, channels, out_height, out_width) if layout is NCHW. out_height and out_width are calculated as:

    out_height = floor((height+padding[0]+padding[2]-pool_size[0])/strides[0])+1
    out_width = floor((width+padding[1]+padding[3]-pool_size[1])/strides[1])+1
    
    where padding will be an expanded array based on number of values passed as::

    one int : all sides same padding used. two int : bottom, right use same as top and left. four int: padding width in the order of (top, left, bottom, right).

    When ceil_mode is True, ceil will be used instead of floor in this equation.

Defined in /workspace/nnvm/src/top/nn/pooling.cc:L245

Parameters
  • data (4D Tensor) – Input data.

  • pool_size (, required) – Size of the pooling windows..

  • strides (, optional, default=[1,1]) – Specifies the strides of the convolution.

  • padding (, optional, default=[0,0]) – If padding is non-zero, then the input is implicitly zero-paddedPadding support both symmetric and asymmetric asone int : same padding used on all sidestwo int : bottom, right will use same padding as top, leftfour int : padding width in the order of (top, left, bottom, right)

  • layout (string, optional, default='NCHW') – Dimension ordering of data and weight. Can be ‘NCHW’, ‘NHWC’, etc.’N’, ‘C’, ‘H’, ‘W’ stands for batch, channel, height, and widthdimensions respectively. Convolution is applied on the ‘H’ and’W’ dimensions.

  • ceil_mode (boolean, optional, default=0) – When true, will use ceil instead of floor to compute the output shape.

  • count_include_pad (boolean, optional, default=0) – When true, will include padding to compute the average

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.global_max_pool2d(*args, **kwargs)

Global max pooling operation for 2D data.

  • data: This depends on the layout parameter. Input is 4D array of shape

    (batch_size, channels, height, width) if layout is NCHW.

  • out: This depends on the layout parameter. Output is 4D array of shape

    (batch_size, channels, 1, 1) if layout is NCHW.

Defined in /workspace/nnvm/src/top/nn/pooling.cc:L361

Parameters
  • data (4D Tensor) – Input data.

  • layout (string, optional, default='NCHW') – Dimension ordering of data and weight. Can be ‘NCHW’, ‘NHWC’, etc.’N’, ‘C’, ‘H’, ‘W’ stands for batch, channel, height, and widthdimensions respectively. Convolution is applied on the ‘H’ and’W’ dimensions.

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.global_avg_pool2d(*args, **kwargs)

Global average pooling operation for 2D data.

  • data: This depends on the layout parameter. Input is 4D array of shape

    (batch_size, channels, height, width) if layout is NCHW.

  • out: This depends on the layout parameter. Output is 4D array of shape

    (batch_size, channels, 1, 1) if layout is NCHW.

Defined in /workspace/nnvm/src/top/nn/pooling.cc:L402

Parameters
  • data (4D Tensor) – Input data.

  • layout (string, optional, default='NCHW') – Dimension ordering of data and weight. Can be ‘NCHW’, ‘NHWC’, etc.’N’, ‘C’, ‘H’, ‘W’ stands for batch, channel, height, and widthdimensions respectively. Convolution is applied on the ‘H’ and’W’ dimensions.

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.reshape(*args, **kwargs)

Reshapes the input array.

Given an array and a shape, this function returns a copy of the array in the new shape. The shape is a tuple of integers such as (2,3,4). The size of the new shape should be same as the size of the input array.

Example:

reshape([1,2,3,4], shape=(2,2)) = [[1,2], [3,4]]

To give user more convenience in without doing manual shape inference, some dimensions of the shape can take special values from the set {0, -1, -2, -3, -4}. The significance of each is explained below:

  • 0 copy this dimension from the input to the output shape.

    Example:

    - input shape = (2,3,4), shape = (4,0,2), output shape = (4,3,2)
    - input shape = (2,3,4), shape = (2,0,0), output shape = (2,3,4)
    
  • -1 infers the dimension of the output shape by using the remainder of the input dimensions keeping the size of the new array same as that of the input array. At most one dimension of shape can be -1.

    Example:

    - input shape = (2,3,4), shape = (6,1,-1), output shape = (6,1,4)
    - input shape = (2,3,4), shape = (3,-1,8), output shape = (3,1,8)
    - input shape = (2,3,4), shape=(-1,), output shape = (24,)
    
  • -2 copy all/remainder of the input dimensions to the output shape.

    Example:

    - input shape = (2,3,4), shape = (-2,), output shape = (2,3,4)
    - input shape = (2,3,4), shape = (2,-2), output shape = (2,3,4)
    - input shape = (2,3,4), shape = (-2,1,1), output shape = (2,3,4,1,1)
    
  • -3 use the product of two consecutive dimensions of the input shape as the output dimension.

    Example:

    - input shape = (2,3,4), shape = (-3,4), output shape = (6,4)
    - input shape = (2,3,4,5), shape = (-3,-3), output shape = (6,20)
    - input shape = (2,3,4), shape = (0,-3), output shape = (2,12)
    - input shape = (2,3,4), shape = (-3,-2), output shape = (6,4)
    
  • -4 split one dimension of the input into two dimensions passed subsequent to -4 in shape (can contain -1).

    Example:

    - input shape = (2,3,4), shape = (-4,1,2,-2), output shape =(1,2,3,4)
    - input shape = (2,3,4), shape = (2,-4,-1,3,-2), output shape = (2,1,3,4)
    

Defined in /workspace/nnvm/src/top/tensor/transform.cc:L626

Parameters
  • data (Tensor) – Input data.

  • shape (tuple of <long>, required) –

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.copy(*args, **kwargs)

Copy tensor to another one.

Defined in /workspace/nnvm/src/top/tensor/elemwise.cc:L446

Parameters

data (Tensor) – The input tensor.

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.negative(*args, **kwargs)

Elemenwise numeric negative

Defined in /workspace/nnvm/src/top/tensor/elemwise.cc:L411

Parameters

data (Tensor) – The input tensor.

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.floor(*args, **kwargs)

Take floor input array, computed element-wise.

Defined in /workspace/nnvm/src/top/tensor/elemwise.cc:L57

Parameters

data (Tensor) – The input tensor.

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.ceil(*args, **kwargs)

Take ceil input array, computed element-wise.

Defined in /workspace/nnvm/src/top/tensor/elemwise.cc:L69

Parameters

data (Tensor) – The input tensor.

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.round(*args, **kwargs)

Round elements of the input to nearest integer.

Defined in /workspace/nnvm/src/top/tensor/elemwise.cc:L93

Parameters

data (Tensor) – The input tensor.

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.trunc(*args, **kwargs)

Take truncated value of the input, element-wise.

Defined in /workspace/nnvm/src/top/tensor/elemwise.cc:L81

Parameters

data (Tensor) – The input tensor.

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.abs(*args, **kwargs)

Take absolute value of elements of the input.

Defined in /workspace/nnvm/src/top/tensor/elemwise.cc:L105

Parameters

data (Tensor) – The input tensor.

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.leaky_relu(*args, **kwargs)

Leaky version of a Rectified Linear Unit.

y = x > 0 ? x : alpha * x

Defined in /workspace/nnvm/src/top/nn/nn.cc:L477

Parameters
  • data (Tensor) – Input data.

  • alpha (double, optional, default=0.25) – slope coefficient for the negative half axis.

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.__add_scalar__(*args, **kwargs)

Tensor add scalar

Defined in /workspace/nnvm/src/top/tensor/elemwise.cc:L607

Parameters
  • data (Tensor) – The input tensor.

  • scalar (double, required) –

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.__sub_scalar__(*args, **kwargs)

Tensor substract scalar

Defined in /workspace/nnvm/src/top/tensor/elemwise.cc:L626

Parameters
  • data (Tensor) – The input tensor.

  • scalar (double, required) –

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.__rsub_scalar__(*args, **kwargs)

scalar substract Tensor

Defined in /workspace/nnvm/src/top/tensor/elemwise.cc:L644

Parameters
  • data (Tensor) – The input tensor.

  • scalar (double, required) –

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.__mul_scalar__(*args, **kwargs)

Tensor multiplies scalar

Defined in /workspace/nnvm/src/top/tensor/elemwise.cc:L697

Parameters
  • data (Tensor) – The input tensor.

  • scalar (double, required) –

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.__div_scalar__(*args, **kwargs)

Tensor divides scalar

Defined in /workspace/nnvm/src/top/tensor/elemwise.cc:L720

Parameters
  • data (Tensor) – The input tensor.

  • scalar (double, required) –

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.__rdiv_scalar__(*args, **kwargs)

scalar divides Tensor

Defined in /workspace/nnvm/src/top/tensor/elemwise.cc:L743

Parameters
  • data (Tensor) – The input tensor.

  • scalar (double, required) –

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.__pow_scalar__(*args, **kwargs)

Tensor power scalar

Defined in /workspace/nnvm/src/top/tensor/elemwise.cc:L773

Parameters
  • data (Tensor) – The input tensor.

  • scalar (double, required) –

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.__rpow_scalar__(*args, **kwargs)

scalar power Tensor

Defined in /workspace/nnvm/src/top/tensor/elemwise.cc:L803

Parameters
  • data (Tensor) – The input tensor.

  • scalar (double, required) –

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.__lshift_scalar__(*args, **kwargs)

Tensor left shift by scalar

Defined in /workspace/nnvm/src/top/tensor/elemwise.cc:L665

Parameters
  • data (Tensor) – The input tensor.

  • scalar (double, required) –

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.__rshift_scalar__(*args, **kwargs)

Tensor right shift by scalar

Defined in /workspace/nnvm/src/top/tensor/elemwise.cc:L681

Parameters
  • data (Tensor) – The input tensor.

  • scalar (double, required) –

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.transpose(*args, **kwargs)

Permutes the dimensions of an array.

Examples:

x = [[ 1, 2],
     [ 3, 4]]

transpose(x) = [[ 1.,  3.],
                [ 2.,  4.]]

x = [[[ 1.,  2.],
      [ 3.,  4.]],

     [[ 5.,  6.],
      [ 7.,  8.]]]

transpose(x) = [[[ 1.,  5.],
                 [ 3.,  7.]],

                [[ 2.,  6.],
                 [ 4.,  8.]]]

transpose(x, axes=(1,0,2)) = [[[ 1.,  2.],
                               [ 5.,  6.]],

                              [[ 3.,  4.],
                               [ 7.,  8.]]]

Defined in /workspace/nnvm/src/top/tensor/transform.cc:L879

Parameters
  • data (Tensor) – Source input

  • axes (, optional, default=[]) – Target axis order. By default the axes will be inverted.

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.broadcast_to(*args, **kwargs)

Broadcasts the input array to a new shape.

Broadcasting is a mechanism that allows NDArrays to perform arithmetic operations with arrays of different shapes efficiently without creating multiple copies of arrays. Also see, Broadcasting for more explanation.

Broadcasting is allowed on axes with size 1, such as from (2,1,3,1) to (2,8,3,9). Elements will be duplicated on the broadcasted axes.

For example:

broadcast_to([[1,2,3]], shape=(2,3)) = [[ 1.,  2.,  3.],
                                        [ 1.,  2.,  3.]])

The dimension which you do not want to change can also be kept as 0 which means copy the original value. So with shape=(2,0), we will obtain the same result as in the above example.

Defined in /workspace/nnvm/src/top/tensor/broadcast.cc:L90

Parameters
  • data (Tensor) – Input data.

  • shape (, optional, default=[]) – The shape of the desired array. We can set the dim to zero if it’s same as the original. E.g A = broadcast_to(B, shape=(10, 0, 0))

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.sum(*args, **kwargs)

Computes the sum of array elements over given axes.

Example:

data = [[[1,2],[2,3],[1,3]],
        [[1,4],[4,3],[5,2]],
        [[7,1],[7,2],[7,3]]]

sum(data, axis=1)
[[  4.   8.]
 [ 10.   9.]
 [ 21.   6.]]

sum(data, axis=[1,2])
[ 12.  19.  27.]

Defined in /workspace/nnvm/src/top/tensor/reduce.cc:L176

Parameters
  • axis (, optional, default=[]) –

    The axis or axes along which to perform the reduction.

    The default, axis=(), will compute over all elements into a scalar array with shape (1,).

    If axis is int, a reduction is performed on a particular axis.

    If axis is a tuple of ints, a reduction is performed on all the axes specified in the tuple.

    If exclude is true, reduction will be performed on the axes that are NOT in axis instead.

  • keepdims (boolean, optional, default=0) – If this is set to True, the reduced axes are left in the result as dimension with size one.

  • exclude (boolean, optional, default=0) – Whether to perform reduction on axis that are NOT in axis instead.

  • dtype ({'float16', 'float32', 'float64', 'int16', 'int32', 'int64', 'int8', 'uint16', 'uint32', 'uint64', 'uint8'},optional, default='int32') – Target data type.

  • data (Tensor) – The input

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.min(*args, **kwargs)

Computes the min of array elements over given axes.

Defined in /workspace/nnvm/src/top/tensor/reduce.cc:L244

Parameters
  • axis (, optional, default=[]) –

    The axis or axes along which to perform the reduction.

    The default, axis=(), will compute over all elements into a scalar array with shape (1,).

    If axis is int, a reduction is performed on a particular axis.

    If axis is a tuple of ints, a reduction is performed on all the axes specified in the tuple.

    If exclude is true, reduction will be performed on the axes that are NOT in axis instead.

  • keepdims (boolean, optional, default=0) – If this is set to True, the reduced axes are left in the result as dimension with size one.

  • exclude (boolean, optional, default=0) – Whether to perform reduction on axis that are NOT in axis instead.

  • dtype ({'float16', 'float32', 'float64', 'int16', 'int32', 'int64', 'int8', 'uint16', 'uint32', 'uint64', 'uint8'},optional, default='int32') – Target data type.

  • data (Tensor) – The input

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.max(*args, **kwargs)

Computes the max of array elements over given axes.

Defined in /workspace/nnvm/src/top/tensor/reduce.cc:L211

Parameters
  • axis (, optional, default=[]) –

    The axis or axes along which to perform the reduction.

    The default, axis=(), will compute over all elements into a scalar array with shape (1,).

    If axis is int, a reduction is performed on a particular axis.

    If axis is a tuple of ints, a reduction is performed on all the axes specified in the tuple.

    If exclude is true, reduction will be performed on the axes that are NOT in axis instead.

  • keepdims (boolean, optional, default=0) – If this is set to True, the reduced axes are left in the result as dimension with size one.

  • exclude (boolean, optional, default=0) – Whether to perform reduction on axis that are NOT in axis instead.

  • dtype ({'float16', 'float32', 'float64', 'int16', 'int32', 'int64', 'int8', 'uint16', 'uint32', 'uint64', 'uint8'},optional, default='int32') – Target data type.

  • data (Tensor) – The input

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.mean(*args, **kwargs)

Computes the mean of array elements over given axes.

Example:

data = [[[1,2],[2,3],[1,3]],
        [[1,4],[4,3],[5,2]],
        [[7,1],[7,2],[7,3]]]

mean(data)
[3.22]

mean(data, axis=[1,2])
[ 2.  3.16666667  4.5]

Defined in /workspace/nnvm/src/top/tensor/reduce.cc:L360

Parameters
  • axis (, optional, default=[]) –

    The axis or axes along which to perform the reduction.

    The default, axis=(), will compute over all elements into a scalar array with shape (1,).

    If axis is int, a reduction is performed on a particular axis.

    If axis is a tuple of ints, a reduction is performed on all the axes specified in the tuple.

    If exclude is true, reduction will be performed on the axes that are NOT in axis instead.

  • keepdims (boolean, optional, default=0) – If this is set to True, the reduced axes are left in the result as dimension with size one.

  • exclude (boolean, optional, default=0) – Whether to perform reduction on axis that are NOT in axis instead.

  • dtype ({'float16', 'float32', 'float64', 'int16', 'int32', 'int64', 'int8', 'uint16', 'uint32', 'uint64', 'uint8'},optional, default='int32') – Target data type.

  • data (Tensor) – The input

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.prod(*args, **kwargs)

Computes the products of array elements over given axes.

Example:

data = [[[1,2],[2,3],[1,3]],
        [[1,4],[4,3],[5,2]],
        [[7,1],[7,2],[7,3]]]

mean(data, axis=1)
[35562240]

mean(data, axis=[1,2])
[ 36  480  2058]

Defined in /workspace/nnvm/src/top/tensor/reduce.cc:L395

Parameters
  • axis (, optional, default=[]) –

    The axis or axes along which to perform the reduction.

    The default, axis=(), will compute over all elements into a scalar array with shape (1,).

    If axis is int, a reduction is performed on a particular axis.

    If axis is a tuple of ints, a reduction is performed on all the axes specified in the tuple.

    If exclude is true, reduction will be performed on the axes that are NOT in axis instead.

  • keepdims (boolean, optional, default=0) – If this is set to True, the reduced axes are left in the result as dimension with size one.

  • exclude (boolean, optional, default=0) – Whether to perform reduction on axis that are NOT in axis instead.

  • dtype ({'float16', 'float32', 'float64', 'int16', 'int32', 'int64', 'int8', 'uint16', 'uint32', 'uint64', 'uint8'},optional, default='int32') – Target data type.

  • data (Tensor) – The input

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.broadcast_add(*args, **kwargs)

Returns element-wise sum of the input arrays with broadcasting.

Example:

x = [[ 1.,  1.,  1.],
     [ 1.,  1.,  1.]]

y = [[ 0.],
     [ 1.]]

broadcast_add(x, y) = [[ 1.,  1.,  1.],
                       [ 2.,  2.,  2.]]

Defined in /workspace/nnvm/src/top/tensor/broadcast.cc:L260

Parameters
  • lhs (Tensor) – first input

  • rhs (Tensor) – second input

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.broadcast_sub(*args, **kwargs)

Returns element-wise difference of the input arrays with broadcasting.

Example:

x = [[ 1.,  1.,  1.],
     [ 1.,  1.,  1.]]

y = [[ 0.],
     [ 1.]]

broadcast_sub(x, y) = [[ 1.,  1.,  1.],
                       [ 0.,  0.,  0.]]

Defined in /workspace/nnvm/src/top/tensor/broadcast.cc:L286

Parameters
  • lhs (Tensor) – first input

  • rhs (Tensor) – second input

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.broadcast_mul(*args, **kwargs)

Returns element-wise product of the input arrays with broadcasting.

Example:

x = [[ 1.,  1.,  1.],
     [ 1.,  1.,  1.]]

y = [[ 0.],
     [ 1.]]

broadcast_mul(x, y) = [[ 0.,  0.,  0.],
                       [ 1.,  1.,  1.]]

Defined in /workspace/nnvm/src/top/tensor/broadcast.cc:L314

Parameters
  • lhs (Tensor) – first input

  • rhs (Tensor) – second input

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.broadcast_div(*args, **kwargs)

Returns element-wise division of the input arrays with broadcasting.

Example:

x = [[ 6.,  6.,  6.],
     [ 6.,  6.,  6.]]

y = [[ 2.],
     [ 3.]]

broadcast_div(x, y) = [[ 3.,  3.,  3.],
                       [ 2.,  2.,  2.]]

Defined in /workspace/nnvm/src/top/tensor/broadcast.cc:L347

Parameters
  • lhs (Tensor) – first input

  • rhs (Tensor) – second input

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.clip(*args, **kwargs)

Clips (limits) the values in an array. Given an interval, values outside the interval are clipped to the interval edges. Clipping x between a_min and a_x would be:

clip(x, a_min, a_max) = max(min(x, a_max), a_min))
Example::

x = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] clip(x,1,8) = [ 1., 1., 2., 3., 4., 5., 6., 7., 8., 8.]

Defined in /workspace/nnvm/src/top/tensor/elemwise.cc:L939

Parameters
  • data (NDArray-or-Symbol) – Input array.

  • a_min (double, required) – Minimum value such that value smaller then this will be clipped.

  • a_max (double, required) – Maximum value such that value larger then this will be clipped.

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.greater(*args, **kwargs)

Greater function that returns a mask tensor with 1.0 if (left > right), otherwise 0.0 element-wise.

Defined in /workspace/nnvm/src/top/tensor/elemwise.cc:L871

Parameters
  • lhs (Tensor) – First input

  • rhs (Tensor) – Second input

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.less(*args, **kwargs)

Less function that returns a mask tensor with 1.0 if (left < right), otherwise 0.0 element-wise.

Defined in /workspace/nnvm/src/top/tensor/elemwise.cc:L889

Parameters
  • lhs (Tensor) – First input

  • rhs (Tensor) – Second input

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.expand_like(*args, **kwargs)

Expand an input array with the shape of second array. This operation can be thought of as a composition of expand_dims and broadcast_to. If the dimensions are already expanded then it just broadcasts. Examples:

input = [ 12.  19.  27.]
input.shape = (3,)
new_shape_array = [[[1,2],[2,3],[1,3]],
                   [[1,4],[4,3],[5,2]],
                   [[7,1],[7,2],[7,3]]]
new_shape_array.shape = (3, 3, 2)
expand_like(input, [1,2], new_shape_array) =
                  [[[12,12],[12,12],[12,12]],
                   [[19,19],[19,19],[19,19]],
                   [[27,27],[27,27],[27,27]]]

Defined in /workspace/nnvm/src/top/tensor/transform.cc:L302

Parameters
  • input (Tensor) – Source input

  • shape_like (Tensor) – Input with new shape

  • axis (, optional, default=[]) –

    The axis or axes along which to perform the indicator rule.

    The default, axis=(), will compute over all elements into a scalar array with shape (1,).

    If axis is int, rule is applied on a particular axis.

    If axis is a tuple of ints, rule is applied on all the axes specified in the tuple.

    If exclude is true, rule will be applied on the axes that are NOT in axis instead.

  • exclude (boolean, optional, default=0) – Whether to apply rule on axis that are NOT in axis instead.

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.reshape_like(*args, **kwargs)

Reshapes the input array by the size of another array. For an input array with shape (d1, d2, ..., dk), reshape_like operation reshapes the input array into an output array with the same shape as the second input array. .. note:

Sizes for both array should be compatible.

Defined in /workspace/nnvm/src/top/tensor/transform.cc:L667

Parameters
  • data (Tensor) – Input data.

  • shape_like (Tensor) – Input data.

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.full(*args, **kwargs)

Fill array with scalar value

Defined in /workspace/nnvm/src/top/tensor/elemwise.cc:L471

Parameters
  • shape (, optional, default=[]) –

  • dtype ({'float16', 'float32', 'float64', 'int16', 'int32', 'int64', 'int8', 'uint16', 'uint32', 'uint64', 'uint8'},optional, default='float32') – Target data type.

  • fill_value (double, required) – Scalar value to fill

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.full_like(*args, **kwargs)

Return an scalar value array with the same shape and type as the input array

Defined in /workspace/nnvm/src/top/tensor/elemwise.cc:L542

Parameters
  • data (Tensor) – The input tensor.

  • fill_value (double, required) – Scalar value to be filled

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.ones(*args, **kwargs)

Fill target with ones

Defined in /workspace/nnvm/src/top/tensor/elemwise.cc:L517

Parameters
  • shape (, optional, default=[]) –

  • dtype ({'float16', 'float32', 'float64', 'int16', 'int32', 'int64', 'int8', 'uint16', 'uint32', 'uint64', 'uint8'},optional, default='float32') – Target data type.

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.ones_like(*args, **kwargs)

Return an array of ones with the same shape and type as the input array.

Parameters

data (Tensor) – The input tensor.

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.zeros(*args, **kwargs)

Fill target with zeros

Defined in /workspace/nnvm/src/top/tensor/elemwise.cc:L494

Parameters
  • shape (, optional, default=[]) –

  • dtype ({'float16', 'float32', 'float64', 'int16', 'int32', 'int64', 'int8', 'uint16', 'uint32', 'uint64', 'uint8'},optional, default='float32') – Target data type.

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.zeros_like(*args, **kwargs)

Return an array of zeros with the same shape and type as the input array.

Parameters

data (Tensor) – The input tensor.

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.slice_like(*args, **kwargs)

Slice the first input respect to the second input.

Defined in /workspace/nnvm/src/top/tensor/transform.cc:L1244

Parameters
  • data (Tensor) – Input data to be sliced.

  • slice_like (Tensor) – Tensor with target shape

  • axis (tuple of <int>, optional, default=[]) – List of axes on which input data will be sliced according to the corresponding size of the second input. By default will slice on all axes. Negative axes are supported.

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.strided_slice(*args, **kwargs)

Strided slice of an array.

Examples:

x = [[  1.,   4.,   7.,  10.],
     [  2.,   5.,   8.,  11.],
     [  3.,   6.,   9.,  12.]]

strided_slice(x, begin=[0, 1], end=[2, 4], stride=[1, 1]) = [[ 4.,  7.,  10.],
                                                             [ 5.,  8.,  11.]]

x = [[[ 1.,  2.],
      [ 3.,  4.]],

     [[ 5.,  6.],
      [ 7.,  8.]]]

strided_slice(x, begin=[0, 0], end=[2, 2]) = [[[ 1.,  2.],
                                               [ 3.,  4.]],

                                              [[ 5.,  6.],
                                               [ 7.,  8.]]]

Defined in /workspace/nnvm/src/top/tensor/transform.cc:L987

Parameters
  • data (Tensor) – Array to be sliced

  • begin (tuple of <long>, required) – Indices for begin of slice

  • end (tuple of <long>, required) – Indices for end of the slice

  • stride (tuple of <long>, optional, default=[]) – Stride values of the slice

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.argmax(*args, **kwargs)

Creates an operation that finds the indices of the maximum values over a given axis.

Defined in /workspace/nnvm/src/top/tensor/reduce.cc:L303

Parameters
  • axis (, optional, default=[]) –

    The axis or axes along which to perform the reduction.

    The default, axis=(), will compute over all elements into a scalar array with shape (1,).

    If axis is int, a reduction is performed on a particular axis.

    If axis is a tuple of ints, a reduction is performed on all the axes specified in the tuple.

    If exclude is true, reduction will be performed on the axes that are NOT in axis instead.

  • keepdims (boolean, optional, default=0) – If this is set to True, the reduced axes are left in the result as dimension with size one.

  • exclude (boolean, optional, default=0) – Whether to perform reduction on axis that are NOT in axis instead.

  • dtype ({'float16', 'float32', 'float64', 'int16', 'int32', 'int64', 'int8', 'uint16', 'uint32', 'uint64', 'uint8'},optional, default='int32') – Target data type.

  • data (Tensor) – The input

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.argmin(*args, **kwargs)

Creates an operation that finds the indices of the minimum values over a given axis.

Defined in /workspace/nnvm/src/top/tensor/reduce.cc:L326

Parameters
  • axis (, optional, default=[]) –

    The axis or axes along which to perform the reduction.

    The default, axis=(), will compute over all elements into a scalar array with shape (1,).

    If axis is int, a reduction is performed on a particular axis.

    If axis is a tuple of ints, a reduction is performed on all the axes specified in the tuple.

    If exclude is true, reduction will be performed on the axes that are NOT in axis instead.

  • keepdims (boolean, optional, default=0) – If this is set to True, the reduced axes are left in the result as dimension with size one.

  • exclude (boolean, optional, default=0) – Whether to perform reduction on axis that are NOT in axis instead.

  • dtype ({'float16', 'float32', 'float64', 'int16', 'int32', 'int64', 'int8', 'uint16', 'uint32', 'uint64', 'uint8'},optional, default='int32') – Target data type.

  • data (Tensor) – The input

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.collapse_sum(*args, **kwargs)

Reduces lhs to the shape of rhs via sum

Defined in /workspace/nnvm/src/top/tensor/reduce.cc:L281

Parameters
  • axis (, optional, default=[]) –

    The axis or axes along which to perform the reduction.

    The default, axis=(), will compute over all elements into a scalar array with shape (1,).

    If axis is int, a reduction is performed on a particular axis.

    If axis is a tuple of ints, a reduction is performed on all the axes specified in the tuple.

    If exclude is true, reduction will be performed on the axes that are NOT in axis instead.

  • keepdims (boolean, optional, default=0) – If this is set to True, the reduced axes are left in the result as dimension with size one.

  • exclude (boolean, optional, default=0) – Whether to perform reduction on axis that are NOT in axis instead.

  • dtype ({'float16', 'float32', 'float64', 'int16', 'int32', 'int64', 'int8', 'uint16', 'uint32', 'uint64', 'uint8'},optional, default='int32') – Target data type.

  • data (Tensor) – The input

  • as (Tensor) – The reference

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.broadcast_equal(*args, **kwargs)

Returns element-wise x == y of the input arrays with broadcasting.

Example:

x = [[ 1.,  2.,  3.],
     [ 4.,  5.,  6.]]

y = [[ 2.],
     [ 5.]]

broadcast_equal(x, y) = [[ 0.,  1.,  0.],
                         [ 0.,  1.,  0.]]

Defined in /workspace/nnvm/src/top/tensor/broadcast.cc:L530

Parameters
  • lhs (Tensor) – first input

  • rhs (Tensor) – second input

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.broadcast_greater_equal(*args, **kwargs)

Returns element-wise x >= y of the input arrays with broadcasting.

Example:

x = [[ 1.,  2.,  3.],
     [ 4.,  5.,  6.]]

y = [[ 2.],
     [ 6.]]

broadcast_greater_equal(x, y) = [[ 0.,  1.,  1.],
                                 [ 0.,  0.,  1.]]

Defined in /workspace/nnvm/src/top/tensor/broadcast.cc:L578

Parameters
  • lhs (Tensor) – first input

  • rhs (Tensor) – second input

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.broadcast_greater(*args, **kwargs)

Returns element-wise x > y of the input arrays with broadcasting.

Example:

x = [[ 1.,  2.,  3.],
     [ 4.,  5.,  6.]]

y = [[ 2.],
     [ 3.]]

broadcast_greater(x, y) = [[ 0.,  0.,  1.],
                           [ 1.,  1.,  1.]]

Defined in /workspace/nnvm/src/top/tensor/broadcast.cc:L484

Parameters
  • lhs (Tensor) – first input

  • rhs (Tensor) – second input

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.broadcast_left_shift(*args, **kwargs)

Returns element-wise x << y of the input arrays with broadcasting.

Example:

x = [[ 1.,  2.,  3.],
     [ 4.,  5.,  6.]]

y = [[ 2.],
     [ 1.]]

broadcast_left_shift(x, y) = [[ 4.,  8.,  12.],
                              [ 8.,  10., 12.]]

Defined in /workspace/nnvm/src/top/tensor/broadcast.cc:L450

Parameters
  • lhs (Tensor) – first input

  • rhs (Tensor) – second input

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.broadcast_less_equal(*args, **kwargs)

Returns element-wise x <= y of the input arrays with broadcasting.

Example:

x = [[ 1.,  2.,  3.],
     [ 4.,  5.,  6.]]

y = [[ 1.],
     [ 5.]]

broadcast_less_equal(x, y) = [[ 1.,  0.,  0.],
                              [ 1.,  1.,  0.]]

Defined in /workspace/nnvm/src/top/tensor/broadcast.cc:L603

Parameters
  • lhs (Tensor) – first input

  • rhs (Tensor) – second input

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.broadcast_less(*args, **kwargs)

Returns element-wise x < y of the input arrays with broadcasting.

Example:

x = [[ 1.,  2.,  3.],
     [ 4.,  5.,  6.]]

y = [[ 2.],
     [ 3.]]

broadcast_less(x, y) = [[ 1.,  0.,  0.],
                        [ 0.,  0.,  0.]]

Defined in /workspace/nnvm/src/top/tensor/broadcast.cc:L507

Parameters
  • lhs (Tensor) – first input

  • rhs (Tensor) – second input

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.broadcast_max(*args, **kwargs)

Returns element-wise max of the input arrays with broadcasting.

Example:

x = [[ 1.,  2.,  3.],
     [ 4.,  5.,  6.]]

y = [[ 2.],
     [ 3.]]

broadcast_max(x, y) = [[ 2.,  2.,  3.],
                       [ 4.,  5.,  6.]]

Defined in /workspace/nnvm/src/top/tensor/broadcast.cc:L399

Parameters
  • lhs (Tensor) – first input

  • rhs (Tensor) – second input

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.broadcast_min(*args, **kwargs)

Returns element-wise minimum of the input arrays with broadcasting.

Example:

x = [[ 1.,  2.,  3.],
     [ 4.,  5.,  6.]]

y = [[ 2.],
     [ 3.]]

broadcast_min(x, y) = [[ 1.,  2.,  2.],
                       [ 3.,  3.,  3.]]

Defined in /workspace/nnvm/src/top/tensor/broadcast.cc:L416

Parameters
  • lhs (Tensor) – first input

  • rhs (Tensor) – second input

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.broadcast_mod(*args, **kwargs)

Returns element-wise mod of the input arrays with broadcasting.

Example:

x = [[ 1.,  2.,  3.],
     [ 4.,  5.,  6.]]

y = [[ 2.],
     [ 3.]]

broadcast_mod(x, y) = [[ 1.,  0.,  1.],
                       [ 1.,  2.,  0.]]

Defined in /workspace/nnvm/src/top/tensor/broadcast.cc:L382

Parameters
  • lhs (Tensor) – first input

  • rhs (Tensor) – second input

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.broadcast_not_equal(*args, **kwargs)

Returns element-wise x != y of the input arrays with broadcasting.

Example:

x = [[ 1.,  2.,  3.],
     [ 4.,  5.,  6.]]

y = [[ 2.],
     [ 4.]]

broadcast_not_equal(x, y) = [[ 1.,  0.,  1.],
                             [ 0.,  1.,  1.]]

Defined in /workspace/nnvm/src/top/tensor/broadcast.cc:L553

Parameters
  • lhs (Tensor) – first input

  • rhs (Tensor) – second input

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.broadcast_pow(*args, **kwargs)

Returns element-wise x^y of the input arrays with broadcasting.

Example:

x = [[ 1.,  2.,  3.],
     [ 4.,  5.,  6.]]

y = [[ 1.],
     [ 2.]]

broadcast_pow(x, y) = [[ 1.,   2.,   3. ],
                       [ 16.,  25.,  36.]]

Defined in /workspace/nnvm/src/top/tensor/broadcast.cc:L433

Parameters
  • lhs (Tensor) – first input

  • rhs (Tensor) – second input

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.broadcast_right_shift(*args, **kwargs)

Returns element-wise x >> y of the input arrays with broadcasting.

Example:

x = [[ 4.,  8.,  12.],
     [ 8.,  10., 12.]]

y = [[ 2.],
     [ 1.]]

broadcast_right_shift(x, y) = [[ 1.,  2.,  3.],
                               [ 4.,  5.,  6.]]

Defined in /workspace/nnvm/src/top/tensor/broadcast.cc:L467

Parameters
  • lhs (Tensor) – first input

  • rhs (Tensor) – second input

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.multibox_prior(*args, **kwargs)

“Generate prior(anchor) boxes from data, sizes and ratios.”

Defined in /workspace/nnvm/src/top/vision/ssd/mutibox_op.cc:L82

Parameters
  • sizes (tuple of <float>, optional, default=[1]) – List of sizes of generated MultiBoxPriores.

  • ratios (tuple of <float>, optional, default=[1]) – List of aspect ratios of generated MultiBoxPriores.

  • steps (tuple of <float>, optional, default=[-1,-1]) – Priorbox step across y and x, -1 for auto calculation.

  • offsets (tuple of <float>, optional, default=[0.5,0.5]) – Priorbox center offsets, y and x respectively.

  • clip (boolean, optional, default=0) – Whether to clip out-of-boundary boxes.

  • data (Tensor) – Input data

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.multibox_transform_loc(*args, **kwargs)

“Location transformation for multibox detection.”

Defined in /workspace/nnvm/src/top/vision/ssd/mutibox_op.cc:L157

Parameters
  • clip (boolean, optional, default=1) – Clip out-of-boundary boxes.

  • threshold (float, optional, default=0.00999999978) – Threshold to be a positive prediction.

  • variances (tuple of <float>, optional, default=[0.1,0.1,0.2,0.2]) – Variances to be decoded from box regression output.

  • cls_prob (Tensor) – Class probabilities.

  • loc_pred (Tensor) – Location regression predictions.

  • anchor (Tensor) – Multibox prior anchor boxes

Returns

result – The result Tensor.

Return type

Tensor

nnvm.symbol.yolo_reorg(*args, **kwargs)

Perform reorg operation on input array based on the stride value. - data: Input is 4D array of shape (batch_size, channels, in_height, in_width). - out: Output is 4D array of shape (batch_size, channels/(stride*stride), in_height*stride, in_width*stride).

Defined in /workspace/nnvm/src/top/vision/yolo/reorg.cc:L59

Parameters
  • data (Tensor) – Data input to reorganize

  • stride (int, optional, default='1') – Stride value

Returns

result – The result Tensor.

Return type

Tensor