Tensor Manipulation Routines

Basic manipulations

mars.tensor.copyto Copies values from one array to another, broadcasting as necessary.

Shape manipulation

mars.tensor.reshape Gives a new shape to a tensor without changing its data.
mars.tensor.ravel Return a contiguous flattened tensor.

Transposition

mars.tensor.moveaxis Move axes of a tensor to new positions.
mars.tensor.rollaxis Roll the specified axis backwards, until it lies in a given position.
mars.tensor.swapaxes Interchange two axes of a tensor.
mars.tensor.core.Tensor.T Same as self.transpose(), except that self is returned if self.ndim < 2.
mars.tensor.transpose Permute the dimensions of a tensor.

Edit dimensionalities

mars.tensor.atleast_1d Convert inputs to tensors with at least one dimension.
mars.tensor.atleast_2d View inputs as tensors with at least two dimensions.
mars.tensor.atleast_3d View inputs as tensors with at least three dimensions.
mars.tensor.broadcast_to Broadcast an tensor to a new shape.
mars.tensor.broadcast_arrays Broadcast any number of arrays against each other.
mars.tensor.expand_dims Expand the shape of a tensor.
mars.tensor.squeeze Remove single-dimensional entries from the shape of a tensor.

Changing kind of tensor

mars.tensor.asarray Convert the input to an array.

Joining tensors

mars.tensor.concatenate Join a sequence of arrays along an existing axis.
mars.tensor.stack Join a sequence of tensors along a new axis.
mars.tensor.column_stack Stack 1-D tensors as columns into a 2-D tensor.
mars.tensor.dstack Stack tensors in sequence depth wise (along third axis).
mars.tensor.hstack Stack tensors in sequence horizontally (column wise).
mars.tensor.vstack Stack tensors in sequence vertically (row wise).

Splitting tensors

mars.tensor.split Split a tensor into multiple sub-tensors.
mars.tensor.array_split Split a tensor into multiple sub-tensors.
mars.tensor.dsplit Split tensor into multiple sub-tensors along the 3rd axis (depth).
mars.tensor.hsplit Split a tensor into multiple sub-tensors horizontally (column-wise).
mars.tensor.vsplit Split a tensor into multiple sub-tensors vertically (row-wise).

Tiling tensors

mars.tensor.tile Construct a tensor by repeating A the number of times given by reps.
mars.tensor.repeat Repeat elements of a tensor.

Rearranging elements

mars.tensor.flip Reverse the order of elements in a tensor along the given axis.
mars.tensor.fliplr Flip tensor in the left/right direction.
mars.tensor.flipud Flip tensor in the up/down direction.
mars.tensor.reshape Gives a new shape to a tensor without changing its data.
mars.tensor.roll Roll tensor elements along a given axis.