1. Definitions

1.1. Main

This section describes the master topsaten aten header file.

1.2. Define

This section describes topsaten definitions.

enum topsatenDataType_t

topsatenDataType_t

Values:

enumerator TOPSATEN_DATA_NONE

TOPSATEN_DATA_NONE -1

enumerator TOPSATEN_DATA_I8

TOPSATEN_DATA_I8 0

enumerator TOPSATEN_DATA_U8

TOPSATEN_DATA_U8 1

enumerator TOPSATEN_DATA_I16

TOPSATEN_DATA_I16 2

enumerator TOPSATEN_DATA_U16

TOPSATEN_DATA_U16 3

enumerator TOPSATEN_DATA_FP16

TOPSATEN_DATA_FP16 4

enumerator TOPSATEN_DATA_BF16

TOPSATEN_DATA_BF16 5

enumerator TOPSATEN_DATA_I32

TOPSATEN_DATA_I32 6

enumerator TOPSATEN_DATA_U32

TOPSATEN_DATA_U32 7

enumerator TOPSATEN_DATA_FP32

TOPSATEN_DATA_FP32 8

enumerator TOPSATEN_DATA_EF32

TOPSATEN_DATA_EF32 9

enumerator TOPSATEN_DATA_TF32

TOPSATEN_DATA_TF32 10

enumerator TOPSATEN_DATA_I64

TOPSATEN_DATA_I64 11

enumerator TOPSATEN_DATA_U64

TOPSATEN_DATA_U64 12

enumerator TOPSATEN_DATA_F64

TOPSATEN_DATA_F64 13

enumerator TOPSATEN_DATA_PRED

TOPSATEN_DATA_PRED 14

enumerator TOPSATEN_DATA_I4

TOPSATEN_DATA_I4 15

enumerator TOPSATEN_DATA_CI8

TOPSATEN_DATA_CI8 16

enumerator TOPSATEN_DATA_CU8

TOPSATEN_DATA_CU8 17

enumerator TOPSATEN_DATA_CI16

TOPSATEN_DATA_CI16 18

enumerator TOPSATEN_DATA_CU16

TOPSATEN_DATA_CU16 19

enumerator TOPSATEN_DATA_CFP16

TOPSATEN_DATA_CFP16 20

enumerator TOPSATEN_DATA_CBF16

TOPSATEN_DATA_CBF16 21

enumerator TOPSATEN_DATA_CI32

TOPSATEN_DATA_CI32 22

enumerator TOPSATEN_DATA_CU32

TOPSATEN_DATA_CU32 23

enumerator TOPSATEN_DATA_CFP32

TOPSATEN_DATA_CFP32 24

enumerator TOPSATEN_DATA_CEF32

TOPSATEN_DATA_CEF32 25

enumerator TOPSATEN_DATA_CTF32

TOPSATEN_DATA_CTF32 26

enumerator TOPSATEN_DATA_CI64

TOPSATEN_DATA_CI64 27

enumerator TOPSATEN_DATA_CU64

TOPSATEN_DATA_CU64 28

enumerator TOPSATEN_DATA_CF64

TOPSATEN_DATA_CF64 29

enumerator TOPSATEN_DATA_CPRED

TOPSATEN_DATA_CPRED 30

enumerator TOPSATEN_DATA_CI4

TOPSATEN_DATA_CI4 31

enum topsatenStatus_t

topsatenStatus_t

Values:

enumerator TOPSATEN_STATUS_SUCCESS

TOPSATEN_STATUS_SUCCESS 0

enumerator TOPSATEN_STATUS_ALLOC_FAILED

TOPSATEN_STATUS_ALLOC_FAILED 1

enumerator TOPSATEN_STATUS_BAD_PARAM

TOPSATEN_STATUS_BAD_PARAM 2

enumerator TOPSATEN_STATUS_NOT_SUPPORT

TOPSATEN_STATUS_NOT_SUPPORT 3

enumerator TOPSATEN_STATUS_INTERNAL_ERROR

TOPSATEN_STATUS_INTERNAL_ERROR 4

enumerator TOPSATEN_STATUS_RUNTIME_ERROR

TOPSATEN_STATUS_RUNTIME_ERROR 5

enumerator TOPSATEN_STATUS_EXECUTE_ERROR

TOPSATEN_STATUS_EXECUTE_ERROR 6

enum topsatenMemoryFormat_t

topsatenMemoryFormat_t

Values:

enumerator TOPSATEN_MEMORY_NONE

topsatenMemoryFormat_t == null

enumerator TOPSATEN_MEMORY_CONTIGUOUS

strides in decreasing order

enumerator TOPSATEN_MEMORY_NHWC

NHWC order

enumerator TOPSATEN_MEMORY_NDHWC

NDHWC order

enumerator TOPSATEN_MEMORY_PRESERVE

preserve the format as input tensor

enum topsatenDevice_t

topsatenDevice_t

Values:

enumerator TOPSATEN_DEVICE_CPU

tensor on cpu

enumerator TOPSATEN_DEVICE_GCU

tensor on gcu

enum topsatenActivationMode_t

topsatenActivationMode_t

Values:

enumerator TOPSATEN_ACTIVATION_NONE

TOPSATEN_ACTIVATION_NONE 0

enumerator TOPSATEN_ACTIVATION_RELU

TOPSATEN_ACTIVATION_RELU 1

enumerator TOPSATEN_ACTIVATION_SIGMOID

TOPSATEN_ACTIVATION_SIGMOID 2

enumerator TOPSATEN_ACTIVATION_CLIPPED_RELU

TOPSATEN_ACTIVATION_CLIPPED_RELU 3

enumerator TOPSATEN_ACTIVATION_ELU

TOPSATEN_ACTIVATION_ELU 4

enumerator TOPSATEN_ACTIVATION_IDENTITY

TOPSATEN_ACTIVATION_IDENTITY 5

enumerator TOPSATEN_ACTIVATION_TANH

TOPSATEN_ACTIVATION_TANH 6

enumerator TOPSATEN_ACTIVATION_SWISH

TOPSATEN_ACTIVATION_SWISH 7

enumerator TOPSATEN_ACTIVATION_LEAKY_RELU

TOPSATEN_ACTIVATION_LEAKY_RELU 8

enumerator TOPSATEN_ACTIVATION_GELU

TOPSATEN_ACTIVATION_GELU 9

enumerator TOPSATEN_ACTIVATION_SWIGLU

TOPSATEN_ACTIVATION_SWIGLU 10

enumerator TOPSATEN_ACTIVATION_HARD_SWISH

TOPSATEN_ACTIVATION_HARD_SWISH 11

enum topsatenTopkCmpMode_t

topsatenTopkCmpMode_t

Values:

enumerator TOPSATEN_TOPK_TYPE_INVALID

TOPSATEN_TOPK_TYPE_INVALID 0

enumerator TOPSATEN_TOPK_TYPE_MAX

TOPSATEN_TOPK_TYPE_MAX 1

enumerator TOPSATEN_TOPK_TYPE_MIN

TOPSATEN_TOPK_TYPE_MIN 2

enum topsatenSortCmpMode_t

topsatenSortCmpMode_t

Values:

enumerator TOPSATEN_SORT_TYPE_INVALID

TOPSATEN_SORT_TYPE_INVALID 0

enumerator TOPSATEN_SORT_TYPE_ASCEND

TOPSATEN_SORT_TYPE_ASCEND 1

enumerator TOPSATEN_SORT_TYPE_DESCEND

TOPSATEN_SORT_TYPE_DESCEND 2

enum topsatenSortStableMode_t

topsatenSortStableMode_t

Values:

enumerator TOPSATEN_SORT_STABLE_INVALID

TOPSATEN_SORT_STABLE_INVALID 0

enumerator TOPSATEN_SORT_STABLE

TOPSATEN_SORT_STABLE 1

enumerator TOPSATEN_SORT_INSTABLE

TOPSATEN_SORT_INSTABLE 2

enum topsatenBatchNormMode_t

Values:

enumerator TOPSATEN_BATCHNORM_PER_ACTIVATION
enumerator TOPSATEN_BATCHNORM_SPATIAL
enumerator TOPSATEN_BATCHNORM_SPATIAL_PERSISTENT
enum topsatenScatterType_t

topsatenScatterType_t

Values:

enumerator TOPSATEN_SCATTER_ADD

TOPSATEN_SCATTER_ADD 0

enumerator TOPSATEN_SCATTER_SUB

TOPSATEN_SCATTER_SUB 1

enumerator TOPSATEN_SCATTER_MUL

TOPSATEN_SCATTER_MUL 2

enumerator TOPSATEN_SCATTER_MAX

TOPSATEN_SCATTER_MAX 3

enumerator TOPSATEN_SCATTER_MIN

TOPSATEN_SCATTER_MIN 4

enum topsatenScatterComputationType_t

topsatenScatterComputationType_t

Values:

enumerator TOPSATEN_SCATTER_COMP_UPDATE

TOPSATEN_SCATTER_COMP_UPDATE 0

enumerator TOPSATEN_SCATTER_COMP_ADD

TOPSATEN_SCATTER_COMP_ADD 1

enumerator TOPSATEN_SCATTER_COMP_SUB

TOPSATEN_SCATTER_COMP_SUB 2

enumerator TOPSATEN_SCATTER_COMP_NUM

TOPSATEN_SCATTER_COMP_NUM 3

enum topsatenConvolutionFwdAlgo_t

Values:

enumerator TOPSATEN_CONVOLUTION_FWD_ALGO_AUTO
enumerator TOPSATEN_CONVOLUTION_FWD_ALGO_IMPLICIT_GEMM
enumerator TOPSATEN_CONVOLUTION_FWD_ALGO_IMPLICIT_PRECOMP_GEMM
enumerator TOPSATEN_CONVOLUTION_FWD_ALGO_GEMM
enumerator TOPSATEN_CONVOLUTION_FWD_ALGO_DIRECT
enumerator TOPSATEN_CONVOLUTION_FWD_ALGO_FFT
enumerator TOPSATEN_CONVOLUTION_FWD_ALGO_FFT_TILING
enumerator TOPSATEN_CONVOLUTION_FWD_ALGO_WINOGRAD
enumerator TOPSATEN_CONVOLUTION_FWD_ALGO_WINOGRAD_NONFUSED
enumerator TOPSATEN_CONVOLUTION_FWD_ALGO_COUNT
enum topsatenConvolutionBwdFilterAlgo_t

Values:

enumerator TOPSATEN_CONVOLUTION_BWD_FILTER_ALGO_0
enumerator TOPSATEN_CONVOLUTION_BWD_FILTER_ALGO_1
enumerator TOPSATEN_CONVOLUTION_BWD_FILTER_ALGO_FFT
enumerator TOPSATEN_CONVOLUTION_BWD_FILTER_ALGO_3
enumerator TOPSATEN_CONVOLUTION_BWD_FILTER_ALGO_WINOGRAD
enumerator TOPSATEN_CONVOLUTION_BWD_FILTER_ALGO_WINOGRAD_NONFUSED
enumerator TOPSATEN_CONVOLUTION_BWD_FILTER_ALGO_FFT_TILING
enumerator TOPSATEN_CONVOLUTION_BWD_FILTER_ALGO_COUNT
enum topsatenRoiAlignOpType_t

topsatenRoiAlignOpType_t

Values:

enumerator TOPSATEN_ROIALIGN_AVG_FP32
enumerator TOPSATEN_ROIALIGN_AVG_FP16
enumerator TOPSATEN_ROIALIGN_MAX_FP32
enumerator TOPSATEN_ROIALIGN_MAX_FP16
enum topsatenConvolutionBwdDataAlgo_t

Values:

enumerator TOPSATEN_CONVOLUTION_BWD_DATA_ALGO_0
enumerator TOPSATEN_CONVOLUTION_BWD_DATA_ALGO_1
enumerator TOPSATEN_CONVOLUTION_BWD_DATA_ALGO_FFT
enumerator TOPSATEN_CONVOLUTION_BWD_DATA_ALGO_FFT_TILING
enumerator TOPSATEN_CONVOLUTION_BWD_DATA_ALGO_WINOGRAD
enumerator TOPSATEN_CONVOLUTION_BWD_DATA_ALGO_WINOGRAD_NONFUSED
enumerator TOPSATEN_CONVOLUTION_BWD_DATA_ALGO_COUNT
enum topsatenRoiAlignMode_t

topsatenRoiAlignMode_t

Values:

enumerator TOPSATEN_ROIALIGN_AVG
enumerator TOPSATEN_ROIALIGN_MAX
enum topsatenPadMode_t

topsatenPadMode_t

Values:

enumerator TOPSATEN_PAD_CONSTANT
enumerator TOPSATEN_PAD_REFLECT
enumerator TOPSATEN_PAD_EDGE
enumerator TOPSATEN_PAD_CIRCULAR
enumerator TOPSATEN_PAD_MAXIMUM
enumerator TOPSATEN_PAD_LINEAR_RAMP
enumerator TOPSATEN_PAD_MEAN
enumerator TOPSATEN_PAD_MEDIAN
enumerator TOPSATEN_PAD_MINIMUM
enumerator TOPSATEN_PAD_SYMMETRIC
enumerator TOPSATEN_PAD_WRAP
enumerator TOPSATEN_PAD_EMPTY
enum topsatenRoiAlignCoordinateTransformationMode_t

topsatenRoiAlignCoordinateTransformationMode_t

Values:

enumerator TOPSATEN_ROIALIGN_HALF_PIXL_TRUE
enumerator TOPSATEN_ROIALIGN_HALF_PIXL_FALSE
enum topsatenColorConversionCodes_t

topsatenColorConversionCodes_t

Values:

enumerator TOPSATEN_COLORCVT_YUV2RGB

YUV444packed to RGB888packed

enumerator TOPSATEN_COLORCVT_YUV2BGR

YUV444packed to BGR888packed

enumerator TOPSATEN_COLORCVT_RGB2GRAY

RGB888packed to GRAY

enumerator TOPSATEN_COLORCVT_BGR2GRAY

BGR888packed to GRAY

enum topsatenBlasOperation_t

Values:

enumerator TOPSATEN_BLAS_OP_N
enumerator TOPSATEN_BLAS_OP_T
enumerator TOPSATEN_BLAS_OP_C
enumerator TOPSATEN_BLAS_OP_HERMITAN
enumerator TOPSATEN_BLAS_OP_CONJG
enum topsatenLayoutType_t

topsatenLayoutType_t

Values:

enumerator TOPSATEN_LAYOUT_STRIDED

TOPSATEN_LAYOUT_STRIDED 0

enumerator TOPSATEN_LAYOUT_SPARSE

TOPSATEN_LAYOUT_SPARSE 1

enum topsatenAlgorithm_t

Values:

enumerator TOPSATEN_DEFAULT_ALGO
enumerator TOPSATEN_PHILOX4_32_ALGO
typedef topsError_t (*topsatenMallocAsyncFunc)(void**, size_t, topsStream_t, uint64_t)
typedef topsError_t (*topsatenMallocFunc)(void**, size_t)
typedef topsError_t (*topsatenFreeAsyncFunc)(void*, topsStream_t)
typedef topsError_t (*topsatenFreeFunc)(void*)
typedef void *topsatenDeviceMemHandle_t

The type of device memory handle.

topsatenStatus_t TOPSATEN_EXPORT topsatenInit ()

Get the version of the Device-Independent Operator Inetrface.

This function initialize the topsAten library, this function must be called prior to making any other topsAten calls.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenFinalize ()

This function finalize the topOP library, this function is usually the last call made to topsAten.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGetVersionInfo (char *version_info)

This function get the version info of the aten lib.

Returns

topsatenStatus_t.

TOPSATEN_EXPORT std::ostream & operator<< (std::ostream &os, const topsatenTensor &tensor)
TOPSATEN_EXPORT std::ostream & operator<< (std::ostream &os, const topsatenDataType_t &dtype)
TOPSATEN_EXPORT std::ostream & operator<< (std::ostream &os, const topsatenStatus_t &status)
TOPSATEN_EXPORT std::ostream & operator<< (std::ostream &os, const topsatenSize_t &size)
TOPSATEN_EXPORT std::ostream & operator<< (std::ostream &os, const topsatenScalar_t &scalar)
TOPSATEN_EXPORT std::ostream & operator<< (std::ostream &os, const topsatenGenerator_t &generator)
topsatenStatus_t TOPSATEN_EXPORT topsatenMallocAsyncFuncRegister (topsatenMallocAsyncFunc p_func)
topsatenStatus_t TOPSATEN_EXPORT topsatenMallocFuncRegister (topsatenMallocFunc p_func)
topsatenStatus_t TOPSATEN_EXPORT topsatenFreeAsyncFuncRegister (topsatenFreeAsyncFunc p_func)
topsatenStatus_t TOPSATEN_EXPORT topsatenFreeFuncRegister (topsatenFreeFunc p_func)
TOPSATEN_EXPORT

#define TOPSATEN_EXPORT

TOPSATEN_VERSION_INFO_LEN

#define TOPSATEN_VERSION_INFO_LEN 128

This macro defines the length of the version info string used in the application.

struct topsatenSize_t
#include <topsaten_define.h>

A struct to descript a data pointer and its length

struct topsatenScalar_t
#include <topsaten_define.h>

A struct to descript a scalar

struct topsatenGenerator_t
#include <topsaten_define.h>

A struct to descript a random number generator

class topsatenTensor
#include <topsaten_define.h>

2. TopsAten API Function

2.1. Aten ops

This section describes topsaten common aten ops api definitions.

topsatenStatus_t TOPSATEN_EXPORT topsatenIndexSelect (topsatenTensor &out, const topsatenTensor &in, int64_t dim, const topsatenTensor &index, topsStream_t stream=nullptr)

Index_select operator.

Parameters
  • out – The output tensor.

  • in – Input tensor.

  • dim – The dimension in which to index.

  • index – The 1-D tensor containing the indices to index.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenLinspace (topsatenTensor &output, const topsatenScalar_t &start, const topsatenScalar_t &end, const int64_t step, topsStream_t stream=nullptr)

This function performs the Linspace function.

Parameters
  • output – The output tensor.

  • start – The topsatenScalar_t of start.

  • end – The topsatenScalar_t of end.

  • step – The step for linspace.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenRemainder (topsatenTensor &out, const topsatenTensor &lhs, const topsatenTensor &rhs, topsStream_t stream=nullptr)

Remainder.

Applies the function: Remainder(x, y) = a - b * floor(a / b).

Parameters
  • out – The output tensor.

  • lhs – Input lhs tensor.

  • rhs – Input rhs tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenRemainder (topsatenTensor &out, const topsatenTensor &lhs, const topsatenScalar_t &rhs, topsStream_t stream=nullptr)

Remainder.

Applies the function: Remainder(x, y) = a - b * floor(a / b).

Parameters
  • out – The output tensor.

  • lhs – Input lhs tensor.

  • rhs – Input rhs scalar.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenRemainder (topsatenTensor &out, const topsatenScalar_t &lhs, const topsatenTensor &rhs, topsStream_t stream=nullptr)

Remainder.

Applies the function: Remainder(x, y) = a - b * floor(a / b).

Parameters
  • out – The output tensor.

  • lhs – Input lhs scalar.

  • rhs – Input rhs tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenFmod (topsatenTensor &out, const topsatenTensor &lhs, const topsatenTensor &rhs, topsStream_t stream=nullptr)

Fmod.

Applies the function: Mod(x, y) = a - b * trunc(a / b).

Parameters
  • out – The output tensor.

  • lhs – Input lhs tensor.

  • rhs – Input rhs tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenFmod (topsatenTensor &out, const topsatenTensor &lhs, const topsatenScalar_t &rhs, topsStream_t stream=nullptr)

Fmod.

Applies the function: Mod(x, y) = a - b * trunc(a / b).

Parameters
  • out – The output tensor.

  • lhs – Input lhs tensor.

  • rhs – Input rhs scalar.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenFmod (topsatenTensor &out, const topsatenScalar_t &lhs, const topsatenTensor &rhs, topsStream_t stream=nullptr)

Fmod.

Applies the function: Mod(x, y) = a - b * trunc(a / b).

Parameters
  • out – The output tensor.

  • lhs – Input lhs scalar.

  • rhs – Input rhs tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenAtan2 (topsatenTensor &out, const topsatenTensor &lhs, const topsatenTensor &rhs, topsStream_t stream=nullptr)

Atan2.

Applies the function: Atan2(x, y) return element-wise arctangent with consideration of the quadrant.

Parameters
  • out – The output tensor.

  • lhs – Input lhs tensor.

  • rhs – Input rhs tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenAtan2 (topsatenTensor &out, const topsatenTensor &lhs, const topsatenScalar_t &rhs, topsStream_t stream=nullptr)

Atan2.

Applies the function: Atan2(x, y) return element-wise arctangent with consideration of the quadrant.

Parameters
  • out – The output tensor.

  • lhs – Input lhs tensor.

  • rhs – Input rhs scalar.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenAtan2 (topsatenTensor &out, const topsatenScalar_t &lhs, const topsatenTensor &rhs, topsStream_t stream=nullptr)

Atan2.

Applies the function: Atan2(x, y) return element-wise arctangent with consideration of the quadrant.

Parameters
  • out – The output tensor.

  • lhs – Input lhs scalar.

  • rhs – Input rhs tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenArctan2 (topsatenTensor &out, const topsatenTensor &lhs, const topsatenTensor &rhs, topsStream_t stream=nullptr)

Arctan2.

Alias for atan2.

Parameters
  • out – The output tensor.

  • lhs – Input lhs tensor.

  • rhs – Input rhs tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenXlogy (topsatenTensor &out, const topsatenTensor &lhs, const topsatenTensor &rhs, topsStream_t stream=nullptr)

Xlogy.

Applies the function: XLogy(x, y) = x * log(y).

Parameters
  • out – The output tensor.

  • lhs – Input lhs tensor.

  • rhs – Input rhs tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenXlogy (topsatenTensor &out, const topsatenTensor &lhs, const topsatenScalar_t &rhs, topsStream_t stream=nullptr)

Xlogy.

Applies the function: XLogy(x, y) = x * log(y).

Parameters
  • out – The output tensor.

  • lhs – Input lhs tensor.

  • rhs – Input rhs scalar.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenXlogy (topsatenTensor &out, const topsatenScalar_t &lhs, const topsatenTensor &rhs, topsStream_t stream=nullptr)

Xlogy.

Applies the function: XLogy(x, y) = x * log(y).

Parameters
  • out – The output tensor.

  • lhs – Input lhs scalar.

  • rhs – Input rhs tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenLogAddExp (topsatenTensor &out, const topsatenTensor &lhs, const topsatenTensor &rhs, topsStream_t stream=nullptr)

Logaddexp.

Applies the function: LogAddExp(x, y) = log(exp(x) + exp(y)).

Parameters
  • out – The output tensor.

  • lhs – Input lhs tensor.

  • rhs – Input rhs tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenLogAddExp (topsatenTensor &out, const topsatenTensor &lhs, const topsatenScalar_t &rhs, topsStream_t stream=nullptr)

Logaddexp.

Applies the function: LogAddExp(x, y) = log(exp(x) + exp(y)).

Parameters
  • out – The output tensor.

  • lhs – Input lhs tensor.

  • rhs – Input rhs scalar.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenLogAddExp (topsatenTensor &out, const topsatenScalar_t &lhs, const topsatenTensor &rhs, topsStream_t stream=nullptr)

Logaddexp.

Applies the function: LogAddExp(x, y) = log(exp(x) + exp(y)).

Parameters
  • out – The output tensor.

  • lhs – Input lhs scalar.

  • rhs – Input rhs tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenLogAddExp2 (topsatenTensor &out, const topsatenTensor &lhs, const topsatenTensor &rhs, topsStream_t stream=nullptr)

Logaddexp2.

Applies the function: Logaddexp2(x, y) = log2(2^x + 2^y).

Parameters
  • out – The output tensor.

  • lhs – Input lhs tensor.

  • rhs – Input rhs tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenLogAddExp2 (topsatenTensor &out, const topsatenTensor &lhs, const topsatenScalar_t &rhs, topsStream_t stream=nullptr)

Logaddexp2.

Applies the function: Logaddexp2(x, y) = log2(2^x + 2^y) Inputs and output can be different, char, short, int, unsigned char, unsigned short, unsigned int, __fp16, __bf16, float are supported.

Parameters
  • out – The output tensor.

  • lhs – Input lhs tensor.

  • rhs – Input rhs scalar.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenLogAddExp2 (topsatenTensor &out, const topsatenScalar_t &lhs, const topsatenTensor &rhs, topsStream_t stream=nullptr)

Logaddexp2.

Applies the function: Logaddexp2(x, y) = log2(2^x + 2^y) Inputs and output can be different, char, short, int, unsigned char, unsigned short, unsigned int, __fp16, __bf16, float are supported.

Parameters
  • out – The output tensor.

  • lhs – Input lhs scalar.

  • rhs – Input rhs tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenHypot (topsatenTensor &out, const topsatenTensor &lhs, const topsatenTensor &rhs, topsStream_t stream=nullptr)

Hypot.

Applies the function: Hypot(x,y)=sqrt(x**2+y**2) return square root of two numbers.

Parameters
  • out – The output tensor.

  • lhs – Input lhs tensor.

  • rhs – Input rhs tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenHypot (topsatenTensor &out, const topsatenTensor &lhs, const topsatenScalar_t &rhs, topsStream_t stream=nullptr)

Hypot.

Applies the function: Hypot(x,y)=sqrt(x**2+y**2) return square root of two numbers.

Parameters
  • out – The output tensor.

  • lhs – Input lhs tensor.

  • rhs – Input rhs scalar.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenHypot (topsatenTensor &out, const topsatenScalar_t &lhs, const topsatenTensor &rhs, topsStream_t stream=nullptr)

Hypot.

Applies the function: Hypot(x,y)=sqrt(x**2+y**2) return square root of two numbers.

Parameters
  • out – The output tensor.

  • lhs – Input lhs scalar.

  • rhs – Input rhs tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenAdd (topsatenTensor &out, const topsatenTensor &lhs, const topsatenTensor &rhs, const topsatenScalar_t &alpha, topsStream_t stream=nullptr)

Add operator.

Parameters
  • out – The output tensor.

  • lhs – Input lhs tensor.

  • rhs – Input rhs tensor.

  • alpha – The multiplier for lhs tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenAdd (topsatenTensor &out, const topsatenScalar_t &lhs, const topsatenTensor &rhs, const topsatenScalar_t &alpha, topsStream_t stream=nullptr)

Add operator.

Parameters
  • out – The output tensor.

  • lhs – Input lhs scalar.

  • rhs – Input rhs tensor.

  • alpha – The multiplier for lhs tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenAdd (topsatenTensor &out, const topsatenTensor &lhs, const topsatenScalar_t &rhs, const topsatenScalar_t &alpha, topsStream_t stream=nullptr)

Add operator.

Parameters
  • out – The output tensor.

  • lhs – Input lhs tensor.

  • rhs – Input rhs scalar.

  • alpha – The multiplier for lhs tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenAll (topsatenTensor &output, const topsatenTensor &input, int64_t dim, bool keepdim, topsStream_t stream=nullptr)

This function returns True if all element in the row evaluate to True and False otherwise, for each row of input in the given dimension dim.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • dim – The dimension to reduce.

  • keepdim – Whether the output tensor has dim retained or not.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenAll (topsatenTensor &output, const topsatenTensor &input, const topsatenSize_t &dim, bool keepdim, topsStream_t stream=nullptr)

This function returns True if all element in the rows evaluate to True and False otherwise, for rows of input in the given dimensions.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • dim – The dimensions to reduce.

  • keepdim – Whether the output tensor has dim retained or not.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenAll (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

This function returns True if all element in the input evaluate to True and False otherwise.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenAny (topsatenTensor &output, const topsatenTensor &input, int64_t dim, bool keepdim, topsStream_t stream=nullptr)

This function returns True if any element in the row evaluate to True and False otherwise, for each row of input in the given dimension dim.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • dim – The dimension to reduce.

  • keepdim – Whether the output tensor has dim retained or not.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenAny (topsatenTensor &output, const topsatenTensor &input, const topsatenSize_t &dim, bool keepdim, topsStream_t stream=nullptr)

This function returns True if any element in the rows evaluate to True and False otherwise, for rows of input in the given dimensions.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • dim – The dimensions to reduce.

  • keepdim – Whether the output tensor has dim retained or not.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenAny (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

This function returns True if any element in the input evaluate to True and False otherwise.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenOnes (topsatenTensor &output, const topsatenSize_t &size, const topsatenDataType_t &data_type, topsStream_t stream=nullptr)

Returns a tensor filled with the scalar value one.

Parameters
  • output – Result tensor.

  • size – Output shape.

  • data_type – Output data type.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenClamp (topsatenTensor &output, const topsatenTensor &input, const topsatenScalar_t &min, const topsatenScalar_t &max, topsStream_t stream=nullptr)

Returns the tensor after performing a lower and a higher bound truncation operation on the input tensor.

Parameters
  • output – The output tensor.

  • input – Input tensor to perform lower bound truncation operation.

  • min – Replace elements less than the specified lower limit tensor with elements corresponding to the lower limit tensor.

  • max – Replace elements less than the specified higher limit tensor with elements corresponding to the higher limit tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenClamp (topsatenTensor &output, const topsatenTensor &input, const topsatenTensor &min, const topsatenTensor &max, topsStream_t stream=nullptr)

Returns the tensor after performing a lower and a higher bound truncation operation on the input tensor.

Parameters
  • output – The output tensor.

  • input – Input tensor to perform lower bound truncation operation.

  • min – Input tensor, the lower boundary.

  • max – Input tensor, the higher boundary.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenClip (topsatenTensor &output, const topsatenTensor &input, const topsatenScalar_t &min, const topsatenScalar_t &max, topsStream_t stream=nullptr)

Returns the tensor after performing a lower and a higher bound truncation operation on the input tensor. Alias for clamp.

Parameters
  • output – The output tensor.

  • input – Input tensor to perform lower bound truncation operation.

  • min – Replace elements less than the specified lower limit tensor with elements corresponding to the lower limit tensor.

  • max – Replace elements less than the specified higher limit tensor with elements corresponding to the higher limit tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenClip (topsatenTensor &output, const topsatenTensor &input, const topsatenTensor &min, const topsatenTensor &max, topsStream_t stream=nullptr)

Returns the tensor after performing a lower and a higher bound truncation operation on the input tensor. Alias for clamp.

Parameters
  • output – The output tensor.

  • input – Input tensor to perform lower bound truncation operation.

  • min – Input tensor, the lower boundary.

  • max – Input tensor, the higher boundary.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenZeros (topsatenTensor &output, const topsatenSize_t &size, const topsatenDataType_t &data_type, topsStream_t stream=nullptr)

Returns a tensor filled with the scalar value zero.

Parameters
  • output – Result tensor.

  • size – Output shape.

  • data_type – Output data type.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenZero (topsatenTensor &output, topsStream_t stream=nullptr)

Fills self tensor with zeros.

Parameters

output – Result tensor.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenZerosLike (topsatenTensor &out, const topsatenTensor &input, const topsatenDataType_t &dtype, const topsatenLayoutType_t &layout, const topsatenMemoryFormat_t &format, topsStream_t stream=nullptr)

Returns a zero tensor with the same size as input.

Parameters
  • out – The output tensor.

  • input – The tensor size will define the size of the output tensor.

  • dtype – The data type of the output tensor.

  • layout – the desired layout of returned tensor. Default: if None, defaults to the layout of input.

  • format – The memory format of the output tensor.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenProd (topsatenTensor &output, const topsatenTensor &input, const topsatenDataType_t &data_type, topsStream_t stream=nullptr)

This function returns the product of elements of all the input.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • data_type – The data type of the input and output tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenProd (topsatenTensor &output, const topsatenTensor &input, const topsatenSize_t &dims_in, bool keepdims, const topsatenDataType_t &data_type, topsStream_t stream=nullptr)

This function returns the product of elements of input in the dimension dims.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • dims_in – The dims_in to reduce, maybe a list or tuple.

  • keepdims – Whether the output tensor has dim retained or no.

  • data_type – The data type of the input and output tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenProd (topsatenTensor &output, const topsatenTensor &input, int32_t dim, bool keepdims, const topsatenDataType_t &data_type, topsStream_t stream=nullptr)

This function returns the product of elements of input in the dimension dim.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • dim – The dim to reduce.

  • keepdims – Whether the output tensor has dim retained or no.

  • data_type – The data type of the input and output tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenMin (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

This function returns the minimum value of all the input.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenMin (topsatenTensor &output, const topsatenTensor &input, int32_t dim, bool keepdims, topsStream_t stream=nullptr)

This function returns the minimum value of input in the dimension dim.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • dim – The dim to reduce.

  • keepdims – Whether the output tensor has dim retained or no.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenMin (topsatenTensor &output, const topsatenTensor &input1, const topsatenTensor &input2, topsStream_t stream=nullptr)

This function returns the minimum value of input1 and input2.

Parameters
  • output – The output tensor.

  • input1 – The input tensor.

  • input2 – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenMin (topsatenTensor &output, const topsatenTensor &input1, const topsatenScalar_t &input2, topsStream_t stream=nullptr)

This function returns the minimum value of input1 and input2.

Parameters
  • output – The output tensor.

  • input1 – The input tensor.

  • input2 – The input scalar.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenMin (topsatenTensor &output, const topsatenScalar_t &input1, const topsatenTensor &input2, topsStream_t stream=nullptr)

This function returns the minimum value of input1 and input2.

Parameters
  • output – The output tensor.

  • input1 – The input scalar.

  • input2 – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenMin (topsatenTensor &output, const topsatenTensor &input, const topsatenSize_t &dims_in, bool keepdims, topsStream_t stream=nullptr)

This function returns the minimum value of input in the dimension dims.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • dims_in – The dims_in to reduce.

  • keepdims – Whether the output tensor has dim retained or no.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenMin (topsatenTensor &output, topsatenTensor &output_idx, const topsatenTensor &input, int32_t dim, bool keepdims, topsStream_t stream=nullptr)

This function returns the minimum value of input in the dimension dim.

Parameters
  • output – The output tensor.

  • output_idx – The output tensor, index of the minimum value.

  • input – The input tensor.

  • dim – The dim to reduce.

  • keepdims – Whether the output tensor has dim retained or no.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenMin (topsatenTensor &output, topsatenTensor &output_idx, const topsatenTensor &input, const topsatenSize_t &dims_in, bool keepdims, topsStream_t stream=nullptr)

This function returns the minimum value of input in the dimension dim.

Parameters
  • output – The output tensor.

  • output_idx – The output tensor, index of the minimum value.

  • input – The input tensor.

  • dims_in – The dims to reduce.

  • keepdims – Whether the output tensor has dim retained or no.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenMinimum (topsatenTensor &output, const topsatenTensor &input1, const topsatenTensor &input2, topsStream_t stream=nullptr)

This function returns the minimum value of input1 and input2.

Parameters
  • output – The output tensor.

  • input1 – The input tensor.

  • input2 – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenMax (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

This function returns the maximum value of all the input.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenMax (topsatenTensor &output, const topsatenTensor &input, int32_t dim, bool keepdims, topsStream_t stream=nullptr)

This function returns the maximum value of input in the dimension dim.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • dim – The dim to reduce.

  • keepdims – Whether the output tensor has dim retained or no.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenMax (topsatenTensor &output, const topsatenTensor &input, const topsatenSize_t &dims_in, bool keepdims, topsStream_t stream=nullptr)

This function returns the maximum value of input in the dimension dims.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • dims_in – The dims_in to reduce.

  • keepdims – Whether the output tensor has dim retained or no.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenMax (topsatenTensor &output, const topsatenTensor &input1, const topsatenTensor &input2, topsStream_t stream=nullptr)

This function returns the maximum value of input1 and input2.

Parameters
  • output – The output tensor.

  • input1 – The input tensor.

  • input2 – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenMax (topsatenTensor &output, const topsatenTensor &input1, const topsatenScalar_t &input2, topsStream_t stream=nullptr)

This function returns the maximum value of input1 and input2.

Parameters
  • output – The output tensor.

  • input1 – The input tensor.

  • input2 – The input scalar.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenMax (topsatenTensor &output, const topsatenScalar_t &input1, const topsatenTensor &input2, topsStream_t stream=nullptr)

This function returns the maximum value of input1 and input2.

Parameters
  • output – The output tensor.

  • input1 – The input scalar.

  • input2 – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenMax (topsatenTensor &output, topsatenTensor &output_idx, const topsatenTensor &input, int32_t dim, bool keepdims, topsStream_t stream=nullptr)

This function returns the maximum value of input in the dimension dim.

Parameters
  • output – The output tensor.

  • output_idx – The output tensor, index of the maximum value.

  • input – The input tensor.

  • dim – The dim to reduce.

  • keepdims – Whether the output tensor has dim retained or no.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenMax (topsatenTensor &output, topsatenTensor &output_idx, const topsatenTensor &input, const topsatenSize_t &dims_in, bool keepdims, topsStream_t stream=nullptr)

This function returns the maximum value of input in the dimension dim.

Parameters
  • output – The output tensor.

  • output_idx – The output tensor, index of the maximum value.

  • input – The input tensor.

  • dims_in – The dims to reduce.

  • keepdims – Whether the output tensor has dim retained or no.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenMaximum (topsatenTensor &output, const topsatenTensor &input1, const topsatenTensor &input2, topsStream_t stream=nullptr)

This function returns the maximum value of input1 and input2.

Parameters
  • output – The output tensor.

  • input1 – The input tensor.

  • input2 – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenMean (topsatenTensor &output, const topsatenTensor &input, const topsatenDataType_t &data_type, topsStream_t stream=nullptr)

This function returns the mean value of all the input.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • data_type – The data type of the input and output tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenMean (topsatenTensor &output, const topsatenTensor &input, int32_t dim, bool keepdims, const topsatenDataType_t &data_type, topsStream_t stream=nullptr)

This function returns the mean value of input in the dimension dim.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • dim – The dim to reduce.

  • keepdims – Whether the output tensor has dim retained or no.

  • data_type – The data type of the input and output tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenMean (topsatenTensor &output, const topsatenTensor &input, const topsatenSize_t &dims_in, bool keepdims, const topsatenDataType_t &data_type, topsStream_t stream=nullptr)

This function returns the mean value of input in the dimension dims.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • dims_in – The dims to reduce.

  • keepdims – Whether the output tensor has dim retained or no.

  • data_type – The data type of the input and output tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenLinear (topsatenTensor &out, const topsatenTensor &lhs, const topsatenTensor &rhs, const topsatenTensor &bias, topsStream_t stream=nullptr)

Linear operator.

Parameters
  • out – The output tensor.

  • lhs – The input tensor of lhs.

  • rhs – The input tensor of rhs.

  • bias – The input tensor of bias.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenLinearQuant (topsatenTensor &out, const topsatenTensor &lhs, const topsatenTensor &rhs, const topsatenTensor &bias, const topsatenTensor &scale, topsStream_t stream=nullptr)

Linearquant operator.

Parameters
  • out – The output tensor.

  • lhs – The input tensor of lhs.

  • rhs – The input tensor of rhs.

  • bias – The input tensor of bias.

  • scale – The input tensor of scale.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenCopy (topsatenTensor &out, const topsatenTensor &input, bool non_blocking, topsStream_t stream=nullptr)

This function performs the copy function.

Parameters
  • out – The output tensor.

  • input – The source tensor.

  • non_blocking – If true and this copy is between CPU and GCU.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenToCopy (topsatenTensor &out, const topsatenTensor &input, const topsatenDataType_t &dtype, const topsatenLayoutType_t &layout, const topsatenDevice_t &device, const topsatenMemoryFormat_t &format, bool non_blocking, topsStream_t stream=nullptr)

This function performs the to_copy function.

Parameters
  • out – The output tensor.

  • input – The source tensor.

  • dtype – The data type of the output tensor.

  • layout – The layout type of the output tensor.

  • device – The device of the output tensor allocated.

  • format – The memory format of the output tensor.

  • non_blocking – If true and this copy is between CPU and GCU.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenClone (topsatenTensor &out, const topsatenTensor &input, const topsatenMemoryFormat_t &format, topsStream_t stream=nullptr)

This function performs the clone function.

Parameters
  • out – The output tensor.

  • input – The input tensor.

  • format – The format of the out tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenEmpty (topsatenTensor &out, const topsatenSize_t &size, const topsatenDataType_t &dtype, const topsatenLayoutType_t &layout, const topsatenMemoryFormat_t &format, topsStream_t stream=nullptr)

Returns a tensor filled with uninitialized data. The shape of the tensor is defined by argument ‘size’.

Parameters
  • out – The output tensor.

  • size – The shape of the output tensor.

  • dtype – The data type of the output tensor.

  • layout – The logical layout of the output tensor.

  • format – The memory format of the output tensor.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenEmptyLike (topsatenTensor &out, const topsatenTensor &input, const topsatenDataType_t &dtype, const topsatenLayoutType_t &layout, const topsatenMemoryFormat_t &format, topsStream_t stream=nullptr)

Returns an uninitialized tensor with the same size as input.

Parameters
  • out – The output tensor.

  • input – The tensor size will define the size of the output tensor.

  • dtype – The data type of the output tensor.

  • layout – The logical layout of the output tensor.

  • format – The memory format of the output tensor.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenEmptyStrided (topsatenTensor &out, const topsatenSize_t &size, const topsatenSize_t &stride, const topsatenDataType_t &dtype, const topsatenLayoutType_t &layout, topsStream_t stream=nullptr)

Creates a tensor with the specified size and stride and filled with undefined data.

Parameters
  • out – The output tensor.

  • size – The shape of the output tensor.

  • stride – The strides of the output tensor.

  • dtype – The data type of the output tensor.

  • layout – The logical layout of the output tensor.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenEmptyPermuted (topsatenTensor &out, const topsatenSize_t &size, const topsatenSize_t &physical_layout, const topsatenDataType_t &dtype, const topsatenLayoutType_t &layout, topsStream_t stream=nullptr)

Returns a tensor filled with uninitialized data. The shape of the tensor is defined by argument ‘size’. The stride of the tensor is defined by argument ‘physical_layout’.

Parameters
  • out – The output tensor.

  • size – The shape of the output tensor.

  • physical_layout – The physical layout of the output memory.

  • dtype – The data type of the output tensor.

  • layout – The logical layout of the output tensor.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenAsStrided (topsatenTensor &out, const topsatenTensor &input, const topsatenSize_t &size, const topsatenSize_t &stride, const int64_t storage_offset, topsStream_t stream=nullptr)

Create a view of an existing tensor.

Parameters
  • out – The output tensor.

  • input – The input tensor.

  • size – The shape of the output tensor.

  • stride – The stride of the output tensor.

  • storage_offset – The offset in the underlying storage of the output tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenExpand (topsatenTensor &out, const topsatenTensor &input, const topsatenSize_t &size, topsStream_t stream=nullptr)

Return a new view of the input tensor with singleton dimensions expanded to a larger size.

Parameters
  • out – The output tensor.

  • input – The input tensor.

  • size – The shape of the output tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenExpandAs (topsatenTensor &out, const topsatenTensor &input, const topsatenTensor &other, topsStream_t stream=nullptr)

Return a new view of the input tensor with singleton dimensions expanded to a larger size.

Parameters
  • out – The output tensor.

  • input – The input tensor.

  • size – The shape of the output tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenRandperm (topsatenTensor &output, const int64_t n, const topsatenDataType_t &dtype, const topsatenLayoutType_t &layout, bool pinMemory, topsStream_t stream=nullptr)

Returns a random permutation of integers from 0 to n - 1.

Parameters
  • output – Output tensor.

  • n – The upper bound.

  • dtype – The desired data type of returned tensor.

  • layout – The desired layout of returned Tensor.

  • pinMemory – If set to True, the returned tensor will be allocated in pinned memory. Works only for CPU tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenRandperm (topsatenTensor &output, const int64_t n, const topsatenDataType_t &dtype, const topsatenLayoutType_t &layout, bool pinMemory, const topsatenGenerator_t &generator, topsStream_t stream=nullptr)

Returns a random permutation of integers from 0 to n - 1.

Parameters
  • output – Output tensor.

  • n – The upper bound.

  • dtype – The desired data type of returned tensor.

  • layout – The desired layout of returned Tensor.

  • pinMemory – If set to True, the returned tensor will be allocated in pinned memory. Works only for CPU tensor.

  • generator – Generator used to initialize random number generator states.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenRandom (topsatenTensor &output, const topsatenGenerator_t &generator, topsStream_t stream=nullptr)

Fills self tensor with numbers sampled from the discrete uniform distribution only bounded by self data type.

Parameters
  • output – Output tensor.

  • generator – Generator used to initialize random number generator states.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenRandom (topsatenTensor &output, const int64_t to, const topsatenGenerator_t &generator, topsStream_t stream)

Fills self tensor with numbers sampled from the discrete uniform distribution over [0, to].

Parameters
  • output – Output tensor.

  • to – The upper bound.

  • generator – Generator used to initialize random number generator states.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenRandom (topsatenTensor &output, const int64_t from, const int64_t *to, const topsatenGenerator_t &generator, topsStream_t stream)

Fills self tensor with numbers sampled from the discrete uniform distribution over [from, to].

Parameters
  • output – Output tensor.

  • from – The lower bound.

  • to – The upper bound.

  • generator – Generator used to initialize random number generator states.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenBaddbmm (topsatenTensor &out, const topsatenTensor &self, const topsatenTensor &lhs, const topsatenTensor &rhs, const topsatenScalar_t &beta={TOPSATEN_DATA_FP32, {1.0}}, const topsatenScalar_t &alpha={TOPSATEN_DATA_FP32, {1.0}}, topsStream_t stream=nullptr)

Baddbmm operator.

Parameters
  • out – The output tensor.

  • self – The input tensor of self.

  • lhs – The input tensor of lhs.

  • rhs – The input tensor of rhs.

  • beta – Scaling factor.

  • alpha – Scaling factor used to blend the computation result.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenIsSameSize (bool &flag, const topsatenTensor &lhs, const topsatenTensor &rhs, topsStream_t stream=nullptr)

Determine if two tensor sizes are the same.

Parameters
  • flag – The output flag.

  • lhs – The input tensor of lhs.

  • rhs – The input tensor of rhs.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenRandint (topsatenTensor &output, int64_t high, const topsatenSize_t &size, const topsatenDataType_t &dtype, const topsatenLayoutType_t &layout, bool pinMemory, topsStream_t stream=nullptr)

Returns a tensor filled with random integers generated uniformly between [0, high].

Parameters
  • output – Output tensor.

  • high – The upper bound.

  • size – The shape of the output tensor.

  • dtype – The desired data type of returned tensor.

  • layout – The desired layout of returned Tensor.

  • pinMemory – If set to True, the returned tensor will be allocated in pinned memory. Works only for CPU tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenRandint (topsatenTensor &output, int64_t high, const topsatenSize_t &size, const topsatenDataType_t &dtype, const topsatenLayoutType_t &layout, bool pinMemory, const topsatenGenerator_t &generator, topsStream_t stream=nullptr)

Returns a tensor filled with random integers generated uniformly between [0, high].

Parameters
  • output – Output tensor.

  • high – The upper bound.

  • size – The shape of the output tensor.

  • dtype – The desired data type of returned tensor.

  • layout – The desired layout of returned Tensor.

  • pinMemory – If set to True, the returned tensor will be allocated in pinned memory. Works only for CPU tensor.

  • generator – Generator used to initialize random number generator states.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenRandint (topsatenTensor &output, int64_t low, int64_t high, const topsatenSize_t &size, const topsatenDataType_t &dtype, const topsatenLayoutType_t &layout, bool pinMemory, topsStream_t stream=nullptr)

Returns a tensor filled with random integers generated uniformly between [low, high].

Parameters
  • output – Output tensor.

  • low – The lower bound.

  • high – The upper bound.

  • size – The shape of the output tensor.

  • dtype – The desired data type of returned tensor.

  • layout – The desired layout of returned Tensor.

  • pinMemory – If set to True, the returned tensor will be allocated in pinned memory. Works only for CPU tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenRandint (topsatenTensor &output, int64_t low, int64_t high, const topsatenSize_t &size, const topsatenDataType_t &dtype, const topsatenLayoutType_t &layout, bool pinMemory, const topsatenGenerator_t &generator, topsStream_t stream=nullptr)

Returns a tensor filled with random integers generated uniformly between [low, high].

Parameters
  • output – Output tensor.

  • low – The lower bound.

  • high – The upper bound.

  • size – The shape of the output tensor.

  • dtype – The desired data type of returned tensor.

  • layout – The desired layout of returned Tensor.

  • pinMemory – If set to True, the returned tensor will be allocated in pinned memory. Works only for CPU tensor.

  • generator – Generator used to initialize random number generator states.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenNewEmpty (topsatenTensor &output, const topsatenTensor &input, const topsatenSize_t &size, const topsatenDataType_t &dtype, const topsatenLayoutType_t &layout, bool pinMemory, topsStream_t stream=nullptr)

Returns a tensor filled with uninitialized data. The shape of the tensor is defined by argument ‘size’.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • size – The shape of the output tensor.

  • dtype – The data type of the output tensor.

  • layout – The desired layout of returned Tensor.

  • pinMemory – If set to True, the returned tensor will be allocated in pinned memory. Works only for CPU tensor.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenSoftmaxForward (topsatenTensor &output, const topsatenTensor &input, const int64_t dims, topsStream_t stream=nullptr)

This function performs the forward softmax.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • dims – The dims of output tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenSoftmaxForward (topsatenTensor &output, const topsatenTensor &input, const int64_t dims, const bool half_to_float, topsStream_t stream=nullptr)

This function performs the forward softmax.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • dims – The dims of output tensor.

  • half_to_float – Only when a is true, it is legal for the input to be half and the output to be float.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenLogSoftmaxForward (topsatenTensor &output, const topsatenTensor &input, const int64_t dims, topsStream_t stream=nullptr)

This function performs the log_softmax.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • dims – The dims of output tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenLogSoftmaxForward (topsatenTensor &output, const topsatenTensor &input, const int64_t dims, const bool half_to_float, topsStream_t stream=nullptr)

This function performs the log_softmax.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • dims – The dims of output tensor.

  • half_to_float – Only when a is true, it is legal for the input to be half and the output to be float.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenCat (topsatenTensor &output, const std::vector< topsatenTensor > &inputs, int64_t dim, topsStream_t stream=nullptr)

Concatenate operator.

Parameters
  • output – The output tensor.

  • inputs – The input tensor.

  • dim – Concatenate dim.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenStack (topsatenTensor &output, const std::vector< topsatenTensor > &inputs, int64_t dim, topsStream_t stream=nullptr)

Stack operator.

Parameters
  • output – The output tensor.

  • inputs – The input tensor.

  • dim – Concatenate dim.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenNewEmptyStrided (topsatenTensor &output, const topsatenTensor &input, const topsatenSize_t &size, const topsatenSize_t &stride, const topsatenDataType_t &dtype, const topsatenLayoutType_t &layout, bool pinMemory, topsStream_t stream=nullptr)

Creates a tensor with the specified size and stride and filled with undefined data.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • size – The shape of the output tensor.

  • stride – The strides of the output tensor.

  • dtype – The data type of the output tensor.

  • layout – The desired layout of returned Tensor.

  • pinMemory – If set to True, the returned tensor will be allocated in pinned memory. Works only for CPU tensor.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenContiguous (topsatenTensor &output, const topsatenTensor &input, const topsatenMemoryFormat_t &format, topsStream_t stream=nullptr)

Contiguous operator.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • format – Memory format, specifying storage type.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenRepeat (topsatenTensor &output, const topsatenTensor &input, const topsatenSize_t &repeats, topsStream_t stream=nullptr)

Repeats this tensor along the specified dimensions.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • repeats – The number of times to repeat this tensor along each dimension.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenRepeatInterleave (topsatenTensor &output, const topsatenTensor &input, const topsatenTensor &repeats, int64_t dim, int64_t output_size, topsStream_t stream=nullptr)

Repeat elements of a tensor.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • repeats – The number of repetitions for each element. repeats is broadcasted to fit the shape of the given axis.

  • dim – The dimension along which to repeat values. By default, use the flattened input array, and return a flat output array.

  • output_size – Output size.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenRepeatInterleave (topsatenTensor &output, const topsatenTensor &input, int64_t repeats, int64_t dim, int64_t output_size, topsStream_t stream=nullptr)

Repeat elements of a tensor.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • repeats – The number of repetitions for each element. repeats is broadcasted to fit the shape of the given axis.

  • dim – The dimension along which to repeat values. By default, use the flattened input array, and return a flat output array.

  • output_size – Output size.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenRepeatInterleave (topsatenTensor &output, const topsatenTensor &input, const topsatenTensor &repeats, int64_t output_size, topsStream_t stream=nullptr)

Repeat elements of a tensor.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • repeats – The number of repetitions for each element. repeats is broadcasted to fit the shape of the given axis.

  • output_size – Output size.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenRepeatInterleave (topsatenTensor &output, const topsatenTensor &input, const topsatenTensor &repeats, const topsatenScalar_t &dim, const topsatenScalar_t &output_size, topsStream_t stream=nullptr)

Repeat elements of a tensor.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • repeats – The number of repetitions for each element. repeats is broadcasted to fit the shape of the given axis.

  • dim – The dimension along which to repeat values. By default, use the flattened input array, and return a flat output array.

  • output_size – Output size.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenRepeatInterleave (topsatenTensor &output, const topsatenTensor &input, const int64_t &repeats, const topsatenScalar_t &dim, const topsatenScalar_t &output_size, topsStream_t stream=nullptr)

Repeat elements of a tensor.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • repeats – The number of repetitions for each element. repeats is broadcasted to fit the shape of the given axis.

  • dim – The dimension along which to repeat values. By default, use the flattened input array, and return a flat output array.

  • output_size – Output size.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenTanh (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

This function returns a new tensor with the hyperbolic tangent of the elements of input.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenSilu (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

This function applies the Sigmoid Linear Unit (SiLU) function, element-wise.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenRsqrt (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

This function returns a new tensor with the reciprocal of the square-root of each of the elements of input.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenResolveNeg (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

This function returns a new tensor with materialized negation if input’s negative bit is set to True, else returns input. The output tensor will always have its negative bit set to False.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenResolveConj (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

This function returns a new tensor with materialized conjugation if input’s conjugate bit is set to True, else returns input. The output tensor will always have its conjugate bit set to False.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenPow (topsatenTensor &output, const topsatenScalar_t &input, const topsatenTensor &exponent, topsStream_t stream=nullptr)

This function takes the power of each element in input with exponent and returns a tensor with the result.

Parameters
  • output – The output tensor.

  • input – The input scalar.

  • exponent – The exponent tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenPow (topsatenTensor &output, const topsatenTensor &input, const topsatenScalar_t &exponent, topsStream_t stream=nullptr)

This function takes the power of each element in input with exponent and returns a tensor with the result.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • exponent – The exponent scalar.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenPow (topsatenTensor &output, const topsatenTensor &input, const topsatenTensor &exponent, topsStream_t stream=nullptr)

This function takes the power of each element in input with exponent and returns a tensor with the result.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • exponent – The exponent tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenNeg (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

This function returns a new tensor with the negative of the elements of input.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenExponential (topsatenTensor &output, double lambd, const topsatenGenerator_t &generator, topsStream_t stream=nullptr)

This function fills input tensor with elements drawn from the exponential distribution.

Parameters
  • output – The output tensor.

  • lambd – The lambda parameter in exponential distributions.

  • generator – Creates and returns a generator object that manages the state of an algorithm that generates pseudo-random numbers.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenSub (topsatenTensor &output, const topsatenScalar_t &lhs, const topsatenTensor &rhs, const topsatenScalar_t &alpha, topsStream_t stream=nullptr)

This function subtracts rhs, scaled by alpha, from lhs. output = lhs - rhs * alpha.

Parameters
  • output – The output tensor.

  • lhs – The input scalar.

  • rhs – The tensor to subtract from lhs.

  • alpha – The multiplier for rhs.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenSub (topsatenTensor &output, const topsatenTensor &lhs, const topsatenScalar_t &rhs, const topsatenScalar_t &alpha, topsStream_t stream=nullptr)

This function subtracts rhs, scaled by alpha, from lhs. output = lhs - rhs * alpha.

Parameters
  • output – The output tensor.

  • lhs – The input tensor.

  • rhs – The number to subtract from lhs.

  • alpha – The multiplier for rhs.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenSub (topsatenTensor &output, const topsatenTensor &lhs, const topsatenTensor &rhs, const topsatenScalar_t &alpha, topsStream_t stream=nullptr)

This function subtracts rhs, scaled by alpha, from lhs. output = lhs - rhs * alpha.

Parameters
  • output – The output tensor.

  • lhs – The input tensor.

  • rhs – The tensor to subtract from lhs.

  • alpha – The multiplier for rhs.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenRsub (topsatenTensor &output, const topsatenScalar_t &lhs, const topsatenTensor &rhs, const topsatenScalar_t &alpha, topsStream_t stream=nullptr)

This function subtracts lhs, scaled by alpha, from rhs. output = rhs - lhs * alpha.

Parameters
  • output – The output tensor.

  • lhs – The scalar to subtract from rhs.

  • rhs – The input tensor.

  • alpha – The multiplier for lhs.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenRsub (topsatenTensor &output, const topsatenTensor &lhs, const topsatenScalar_t &rhs, const topsatenScalar_t &alpha, topsStream_t stream=nullptr)

This function subtracts lhs, scaled by alpha, from rhs. output = rhs - lhs * alpha.

Parameters
  • output – The output tensor.

  • lhs – The number to subtract from rhs.

  • rhs – The input tensor.

  • alpha – The multiplier for lhs.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenRsub (topsatenTensor &output, const topsatenTensor &lhs, const topsatenTensor &rhs, const topsatenScalar_t &alpha, topsStream_t stream=nullptr)

This function subtracts lhs, scaled by alpha, from rhs. output = rhs - lhs * alpha.

Parameters
  • output – The output tensor.

  • lhs – The tensor to subtract from rhs.

  • rhs – The input tensor.

  • alpha – The multiplier for lhs.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenNe (topsatenTensor &output, const topsatenScalar_t &lhs, const topsatenTensor &rhs, topsStream_t stream=nullptr)

This function returns a boolean tensor that is True where lhs is not equal to rhs and False elsewhere.

Parameters
  • output – The output tensor.

  • lhs – The input scalar.

  • rhs – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenNe (topsatenTensor &output, const topsatenTensor &lhs, const topsatenScalar_t &rhs, topsStream_t stream=nullptr)

This function returns a boolean tensor that is True where lhs is not equal to rhs and False elsewhere.

Parameters
  • output – The output tensor.

  • lhs – The input tensor.

  • rhs – The input scalar.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenNe (topsatenTensor &output, const topsatenTensor &lhs, const topsatenTensor &rhs, topsStream_t stream=nullptr)

This function returns a boolean tensor that is True where lhs is not equal to rhs and False elsewhere.

Parameters
  • output – The output tensor.

  • lhs – The input tensor.

  • rhs – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenForeachMul (std::vector< topsatenTensor > &output, const std::vector< topsatenTensor > &self, const topsatenScalar_t &scalar, topsStream_t stream=nullptr)

This function multiplies lhs by rhs.

Parameters
  • output – The output tensor list.

  • lhs – The input tensor list.

  • rhs – The input scalar.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenForeachMul (std::vector< topsatenTensor > &output, const std::vector< topsatenTensor > &self, const std::vector< topsatenScalar_t > &scalars, topsStream_t stream=nullptr)

This function multiplies lhs by rhs.

Parameters
  • output – The output tensor list.

  • lhs – The input tensor list.

  • rhs – The input scalar list.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenForeachMul (std::vector< topsatenTensor > &output, const std::vector< topsatenTensor > &self, const topsatenTensor &other, topsStream_t stream=nullptr)

This function multiplies lhs by rhs.

Parameters
  • output – The output tensor list.

  • lhs – The input tensor list.

  • rhs – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenForeachMul (std::vector< topsatenTensor > &output, const std::vector< topsatenTensor > &self, const std::vector< topsatenTensor > &other, topsStream_t stream=nullptr)

This function multiplies lhs by rhs.

Parameters
  • output – The output tensor list.

  • lhs – The input tensor list.

  • rhs – The input tensor list.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenMul (topsatenTensor &output, const topsatenScalar_t &lhs, const topsatenTensor &rhs, topsStream_t stream=nullptr)

This function multiplies lhs by rhs.

Parameters
  • output – The output tensor.

  • lhs – The input scalar.

  • rhs – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenMul (topsatenTensor &output, const topsatenTensor &lhs, const topsatenScalar_t &rhs, topsStream_t stream=nullptr)

This function multiplies lhs by rhs.

Parameters
  • output – The output tensor.

  • lhs – The input tensor.

  • rhs – The input scalar.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenMul (topsatenTensor &output, const topsatenTensor &lhs, const topsatenTensor &rhs, topsStream_t stream=nullptr)

This function multiplies lhs by rhs.

Parameters
  • output – The output tensor.

  • lhs – The input tensor.

  • rhs – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenLt (topsatenTensor &output, const topsatenScalar_t &lhs, const topsatenTensor &rhs, topsStream_t stream=nullptr)

This function returns a boolean tensor that is True where lhs is less than rhs and False elsewhere.

Parameters
  • output – The output tensor.

  • lhs – The input scalar.

  • rhs – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenLt (topsatenTensor &output, const topsatenTensor &lhs, const topsatenScalar_t &rhs, topsStream_t stream=nullptr)

This function returns a boolean tensor that is True where lhs is less than rhs and False elsewhere.

Parameters
  • output – The output tensor.

  • lhs – The input tensor.

  • rhs – The input scalar.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenLt (topsatenTensor &output, const topsatenTensor &lhs, const topsatenTensor &rhs, topsStream_t stream=nullptr)

This function returns a boolean tensor that is True where lhs is less than rhs and False elsewhere.

Parameters
  • output – The output tensor.

  • lhs – The input tensor.

  • rhs – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGt (topsatenTensor &output, const topsatenScalar_t &lhs, const topsatenTensor &rhs, topsStream_t stream=nullptr)

This function returns a boolean tensor that is True where lhs is greater than rhs and False elsewhere.

Parameters
  • output – The output tensor.

  • lhs – The input scalar.

  • rhs – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGt (topsatenTensor &output, const topsatenTensor &lhs, const topsatenScalar_t &rhs, topsStream_t stream=nullptr)

This function returns a boolean tensor that is True where lhs is greater than rhs and False elsewhere.

Parameters
  • output – The output tensor.

  • lhs – The input tensor.

  • rhs – The input scalar.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGt (topsatenTensor &output, const topsatenTensor &lhs, const topsatenTensor &rhs, topsStream_t stream=nullptr)

This function returns a boolean tensor that is True where lhs is greater than rhs and False elsewhere.

Parameters
  • output – The output tensor.

  • lhs – The input tensor.

  • rhs – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGe (topsatenTensor &output, const topsatenScalar_t &lhs, const topsatenTensor &rhs, topsStream_t stream=nullptr)

This function returns a boolean tensor that is True where lhs is greater than or equal to rhs and False elsewhere.

Parameters
  • output – The output tensor.

  • lhs – The input scalar.

  • rhs – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGe (topsatenTensor &output, const topsatenTensor &lhs, const topsatenScalar_t &rhs, topsStream_t stream=nullptr)

This function returns a boolean tensor that is True where lhs is greater than or equal to rhs and False elsewhere.

Parameters
  • output – The output tensor.

  • lhs – The input tensor.

  • rhs – The input scalar.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGe (topsatenTensor &output, const topsatenTensor &lhs, const topsatenTensor &rhs, topsStream_t stream=nullptr)

This function returns a boolean tensor that is True where lhs is greater than or equal to rhs and False elsewhere.

Parameters
  • output – The output tensor.

  • lhs – The input tensor.

  • rhs – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenLe (topsatenTensor &output, const topsatenScalar_t &lhs, const topsatenTensor &rhs, topsStream_t stream=nullptr)

This function returns a boolean tensor that is True where lhs is smaller than or equal to rhs and False elsewhere.

Parameters
  • output – The output tensor.

  • lhs – The input scalar.

  • rhs – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenLe (topsatenTensor &output, const topsatenTensor &lhs, const topsatenScalar_t &rhs, topsStream_t stream=nullptr)

This function returns a boolean tensor that is True where lhs is smaller than or equal to rhs and False elsewhere.

Parameters
  • output – The output tensor.

  • lhs – The input tensor.

  • rhs – The input scalar.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenLe (topsatenTensor &output, const topsatenTensor &lhs, const topsatenTensor &rhs, topsStream_t stream=nullptr)

This function returns a boolean tensor that is True where lhs is smaller than or equal to rhs and False elsewhere.

Parameters
  • output – The output tensor.

  • lhs – The input tensor.

  • rhs – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenOr (topsatenTensor &output, const topsatenScalar_t &lhs, const topsatenTensor &rhs, topsStream_t stream=nullptr)

This function computes the bitwise or of lhs and rhs. The lhs tensor must be of integral or Boolean types. For bool tensors, it computes the logical or.

Parameters
  • output – The output tensor.

  • lhs – The input scalar.

  • rhs – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenOr (topsatenTensor &output, const topsatenTensor &lhs, const topsatenScalar_t &rhs, topsStream_t stream=nullptr)

This function computes the bitwise or of lhs and rhs. The lhs tensor must be of integral or Boolean types. For bool tensors, it computes the logical or.

Parameters
  • output – The output tensor.

  • lhs – The input tensor.

  • rhs – The input scalar.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenOr (topsatenTensor &output, const topsatenTensor &lhs, const topsatenTensor &rhs, topsStream_t stream=nullptr)

This function computes the bitwise or of lhs and rhs. The lhs tensor must be of integral or Boolean types. For bool tensors, it computes the logical or.

Parameters
  • output – The output tensor.

  • lhs – The input tensor.

  • rhs – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenBitwiseXor (topsatenTensor &output, const topsatenScalar_t &lhs, const topsatenTensor &rhs, topsStream_t stream=nullptr)

This function computes the bitwise xor of lhs and rhs.

Parameters
  • output – The output tensor.

  • lhs – The input scalar.

  • rhs – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenBitwiseXor (topsatenTensor &output, const topsatenTensor &lhs, const topsatenScalar_t &rhs, topsStream_t stream=nullptr)

This function computes the bitwise xor of lhs and rhs.

Parameters
  • output – The output tensor.

  • lhs – The input tensor.

  • rhs – The input scalar.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenBitwiseXor (topsatenTensor &output, const topsatenTensor &lhs, const topsatenTensor &rhs, topsStream_t stream=nullptr)

This function computes the bitwise xor of lhs and rhs.

Parameters
  • output – The output tensor.

  • lhs – The input tensor.

  • rhs – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenXor (topsatenTensor &output, const topsatenScalar_t &lhs, const topsatenTensor &rhs, topsStream_t stream=nullptr)

This function computes the bitwise xor of lhs and rhs.

Parameters
  • output – The output tensor.

  • lhs – The input scalar.

  • rhs – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenXor (topsatenTensor &output, const topsatenTensor &lhs, const topsatenScalar_t &rhs, topsStream_t stream=nullptr)

This function computes the bitwise xor of lhs and rhs.

Parameters
  • output – The output tensor.

  • lhs – The input tensor.

  • rhs – The input scalar.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenXor (topsatenTensor &output, const topsatenTensor &lhs, const topsatenTensor &rhs, topsStream_t stream=nullptr)

This function computes the bitwise xor of lhs and rhs.

Parameters
  • output – The output tensor.

  • lhs – The input tensor.

  • rhs – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenBitwiseLeftShift (topsatenTensor &output, const topsatenScalar_t &lhs, const topsatenTensor &rhs, topsStream_t stream=nullptr)

Shift_left.

Applies the function: dst[i] = lhs[i] << rhs.

Parameters
  • output – The output tensor.

  • lhs – The input scalar.

  • rhs – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenBitwiseLeftShift (topsatenTensor &output, const topsatenTensor &lhs, const topsatenScalar_t &rhs, topsStream_t stream=nullptr)

Shift_left.

Applies the function: dst[i] = lhs[i] << rhs.

Parameters
  • output – The output tensor.

  • lhs – The input tensor.

  • rhs – The input scalar.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenBitwiseLeftShift (topsatenTensor &output, const topsatenTensor &lhs, const topsatenTensor &rhs, topsStream_t stream=nullptr)

Shift_left.

Applies the function: dst[i] = lhs[i] << rhs[i].

Parameters
  • output – The output tensor.

  • lhs – The input tensor.

  • rhs – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenLShift (topsatenTensor &output, const topsatenScalar_t &lhs, const topsatenTensor &rhs, topsStream_t stream=nullptr)

Shift_left.

Applies the function: dst[i] = lhs[i] << rhs.

Parameters
  • output – The output tensor.

  • lhs – The input scalar.

  • rhs – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenLShift (topsatenTensor &output, const topsatenTensor &lhs, const topsatenScalar_t &rhs, topsStream_t stream=nullptr)

Shift_left.

Applies the function: dst[i] = lhs[i] << rhs.

Parameters
  • output – The output tensor.

  • lhs – The input tensor.

  • rhs – The input scalar.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenLShift (topsatenTensor &output, const topsatenTensor &lhs, const topsatenTensor &rhs, topsStream_t stream=nullptr)

Shift_left.

Applies the function: dst[i] = lhs[i] << rhs[i].

Parameters
  • output – The output tensor.

  • lhs – The input tensor.

  • rhs – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenBitwiseRightShift (topsatenTensor &output, const topsatenScalar_t &lhs, const topsatenTensor &rhs, topsStream_t stream=nullptr)

Shift_right.

Applies the function: dst[i] = lhs[i] >> rhs.

Parameters
  • output – The output tensor.

  • lhs – The input scalar.

  • rhs – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenBitwiseRightShift (topsatenTensor &output, const topsatenTensor &lhs, const topsatenScalar_t &rhs, topsStream_t stream=nullptr)

Shift_right.

Applies the function: dst[i] = lhs[i] >> rhs.

Parameters
  • output – The output tensor.

  • lhs – The input tensor.

  • rhs – The input scalar.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenBitwiseRightShift (topsatenTensor &output, const topsatenTensor &lhs, const topsatenTensor &rhs, topsStream_t stream=nullptr)

Shift_right.

Applies the function: dst[i] = lhs[i] >> rhs[i].

Parameters
  • output – The output tensor.

  • lhs – The input tensor.

  • rhs – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenRShift (topsatenTensor &output, const topsatenScalar_t &lhs, const topsatenTensor &rhs, topsStream_t stream=nullptr)

Shift_right.

Applies the function: dst[i] = lhs[i] >> rhs.

Parameters
  • output – The output tensor.

  • lhs – The input scalar.

  • rhs – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenRShift (topsatenTensor &output, const topsatenTensor &lhs, const topsatenScalar_t &rhs, topsStream_t stream=nullptr)

Shift_right.

Applies the function: dst[i] = lhs[i] >> rhs.

Parameters
  • output – The output tensor.

  • lhs – The input tensor.

  • rhs – The input scalar.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenRShift (topsatenTensor &output, const topsatenTensor &lhs, const topsatenTensor &rhs, topsStream_t stream=nullptr)

Shift_right.

Applies the function: dst[i] = lhs[i] >> rhs[i].

Parameters
  • output – The output tensor.

  • lhs – The input tensor.

  • rhs – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenEq (topsatenTensor &output, const topsatenScalar_t &lhs, const topsatenTensor &rhs, topsStream_t stream=nullptr)

This function returns a boolean tensor that is True where lhs is equal to rhs and False elsewhere.

Parameters
  • output – The output tensor.

  • lhs – The input scalar.

  • rhs – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenEq (topsatenTensor &output, const topsatenTensor &lhs, const topsatenScalar_t &rhs, topsStream_t stream=nullptr)

This function returns a boolean tensor that is True where lhs is equal to rhs and False elsewhere.

Parameters
  • output – The output tensor.

  • lhs – The input tensor.

  • rhs – The input scalar.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenEq (topsatenTensor &output, const topsatenTensor &lhs, const topsatenTensor &rhs, topsStream_t stream=nullptr)

This function returns a boolean tensor that is True where lhs is equal to rhs and False elsewhere.

Parameters
  • output – The output tensor.

  • lhs – The input tensor.

  • rhs – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenDiv (topsatenTensor &output, const topsatenScalar_t &lhs, const topsatenTensor &rhs, topsStream_t stream=nullptr)

This function divides each element of the input lhs by the corresponding element of rhs.

Parameters
  • output – The output tensor.

  • lhs – The input scalar.

  • rhs – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenDiv (topsatenTensor &output, const topsatenScalar_t &lhs, const topsatenTensor &rhs, const char *const roundingMode, topsStream_t stream=nullptr)

This function divides each element of the input lhs by the corresponding element of rhs.

Parameters
  • output – The output tensor.

  • lhs – The input scalar.

  • rhs – The input tensor.

  • roundingMode – Type of rounding applied to the result.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenDiv (topsatenTensor &output, const topsatenTensor &lhs, const topsatenScalar_t &rhs, topsStream_t stream=nullptr)

This function divides each element of the input lhs by the corresponding element of rhs.

Parameters
  • output – The output tensor.

  • lhs – The input tensor.

  • rhs – The input scalar.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenDiv (topsatenTensor &output, const topsatenTensor &lhs, const topsatenScalar_t &rhs, const char *const roundingMode, topsStream_t stream=nullptr)

This function divides each element of the input lhs by the corresponding element of rhs.

Parameters
  • output – The output tensor.

  • lhs – The input tensor.

  • rhs – The input scalar.

  • roundingMode – Type of rounding applied to the result.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenDiv (topsatenTensor &output, const topsatenTensor &lhs, const topsatenTensor &rhs, topsStream_t stream=nullptr)

This function divides each element of the input lhs by the corresponding element of rhs.

Parameters
  • output – The output tensor.

  • lhs – The input tensor.

  • rhs – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenDiv (topsatenTensor &output, const topsatenTensor &lhs, const topsatenTensor &rhs, const char *const roundingMode, topsStream_t stream=nullptr)

This function divides each element of the input lhs by the corresponding element of rhs.

Parameters
  • output – The output tensor.

  • lhs – The input tensor.

  • rhs – The input tensor.

  • roundingMode – Type of rounding applied to the result.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenFloorDivide (topsatenTensor &output, const topsatenTensor &lhs, const topsatenScalar_t &rhs, topsStream_t stream=nullptr)

Computes input divided by other, elementwise, and floors the result.

Parameters
  • output – The output tensor.

  • lhs – The input tensor.

  • rhs – The input scalar.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenFloorDivide (topsatenTensor &output, const topsatenTensor &lhs, const topsatenTensor &rhs, topsStream_t stream=nullptr)

Computes input divided by other, elementwise, and floors the result.

Parameters
  • output – The output tensor.

  • lhs – The input tensor.

  • rhs – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenBitwiseAnd (topsatenTensor &output, const topsatenScalar_t &lhs, const topsatenTensor &rhs, topsStream_t stream=nullptr)

This function computes the bitwise AND of lhs and rhs. The lhs tensor must be of integral or Boolean types. For bool tensors, it computes the logical AND.

Parameters
  • output – The output tensor.

  • lhs – The input scalar.

  • rhs – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenBitwiseAnd (topsatenTensor &output, const topsatenTensor &lhs, const topsatenScalar_t &rhs, topsStream_t stream=nullptr)

This function computes the bitwise AND of lhs and rhs. The lhs tensor must be of integral or Boolean types. For bool tensors, it computes the logical AND.

Parameters
  • output – The output tensor.

  • lhs – The input tensor.

  • rhs – The input scalar.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenBitwiseAnd (topsatenTensor &output, const topsatenTensor &lhs, const topsatenTensor &rhs, topsStream_t stream=nullptr)

This function computes the bitwise AND of lhs and rhs. The lhs tensor must be of integral or Boolean types. For bool tensors, it computes the logical AND.

Parameters
  • output – The output tensor.

  • lhs – The input tensor.

  • rhs – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenAnd (topsatenTensor &output, const topsatenScalar_t &lhs, const topsatenTensor &rhs, topsStream_t stream=nullptr)

This function computes the bitwise AND of lhs and rhs. The lhs tensor must be of integral or Boolean types. For bool tensors, it computes the logical AND.

Parameters
  • output – The output tensor.

  • lhs – The input scalar.

  • rhs – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenAnd (topsatenTensor &output, const topsatenTensor &lhs, const topsatenScalar_t &rhs, topsStream_t stream=nullptr)

This function computes the bitwise AND of lhs and rhs. The lhs tensor must be of integral or Boolean types. For bool tensors, it computes the logical AND.

Parameters
  • output – The output tensor.

  • lhs – The input tensor.

  • rhs – The input scalar.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenAnd (topsatenTensor &output, const topsatenTensor &lhs, const topsatenTensor &rhs, topsStream_t stream=nullptr)

This function computes the bitwise AND of lhs and rhs. The lhs tensor must be of integral or Boolean types. For bool tensors, it computes the logical AND.

Parameters
  • output – The output tensor.

  • lhs – The input tensor.

  • rhs – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenBitwiseOr (topsatenTensor &output, const topsatenScalar_t &lhs, const topsatenTensor &rhs, topsStream_t stream=nullptr)

This function computes the bitwise or of lhs and rhs. The lhs tensor must be of integral or Boolean types. For bool tensors, it computes the logical or.

Parameters
  • output – The output tensor.

  • lhs – The input scalar.

  • rhs – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenBitwiseOr (topsatenTensor &output, const topsatenTensor &lhs, const topsatenScalar_t &rhs, topsStream_t stream=nullptr)

This function computes the bitwise or of lhs and rhs. The lhs tensor must be of integral or Boolean types. For bool tensors, it computes the logical or.

Parameters
  • output – The output tensor.

  • lhs – The input tensor.

  • rhs – The input scalar.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenBitwiseOr (topsatenTensor &output, const topsatenTensor &lhs, const topsatenTensor &rhs, topsStream_t stream=nullptr)

This function computes the bitwise or of lhs and rhs. The lhs tensor must be of integral or Boolean types. For bool tensors, it computes the logical or.

Parameters
  • output – The output tensor.

  • lhs – The input tensor.

  • rhs – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenIndex (topsatenTensor &output, const topsatenTensor &input, const std::vector< topsatenTensor > &indices, topsStream_t stream=nullptr)

This function obtains the output tensor based on the index information of indicators of different dimensions.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • indices – Index values ​​of each dimension to be output.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenIndexGetOutputDim (std::vector< int64_t > &output_dim, const topsatenTensor &input, const std::vector< topsatenTensor > &indices, topsStream_t stream=nullptr)

This function is to provide the index output shape.

Parameters
  • output_dim – The output tensor shape.

  • input – The input tensor.

  • indices – Index values ​​of each dimension to be output.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenEmbedding (topsatenTensor &output, const topsatenTensor &weight, const topsatenTensor &indices, int64_t paddingIdx, bool scaleGradByFreq, bool sparse, topsStream_t stream=nullptr)

This function is a simple lookup table that stores embeddings of a fixed dictionary and size.

Parameters
  • output – The output tensor.

  • weight – A weight matrix that stores embedding vectors.

  • indices – Contains the tensor containing the index to be found in the weight matrix.

  • paddingIdx – If specified, the entries at padding_idx do not contribute to the gradient; therefore, the embedding vector at padding_idx is not updated during training, i.e. it remains as a fixed “pad”. For a newly constructed Embedding, the embedding vector at padding_idx will default to all zeros, but can be updated to another value to be used as the padding vector.

  • scaleGradByFreq – If given, this will scale gradients by the inverse of frequency of the words in the mini-batch. Default False.

  • sparse – If True, gradient w.r.t. weight matrix will be a sparse tensor. See Notes for more details regarding sparse gradients.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenCummin (topsatenTensor &values, topsatenTensor &indices, const topsatenTensor &input, int32_t dim, topsStream_t stream=nullptr)

This function returns the values and indices tensor, where values is the cumulative minimum of elements of input in the dimension dim. And indices is the index location of each minimum value found in the dimension dim.

Parameters
  • values – The cumulative minimum of elements of input in the dim.

  • indices – The index location of each minimum value found in the dim.

  • input – The input tensor.

  • dim – The dimension to do the operation over.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenCummax (topsatenTensor &values, topsatenTensor &indices, const topsatenTensor &input, int32_t dim, topsStream_t stream=nullptr)

This function returns the values and indices tensor, where values is the cumulative maximum of elements of input in the dimension dim. And indices is the index location of each maximum value found in the dimension dim.

Parameters
  • values – The cumulative maximum of elements of input in the dim.

  • indices – The index location of each maximum value found in the dim.

  • input – The input tensor.

  • dim – The dimension to do the operation over.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenCumsum (topsatenTensor &output, const topsatenTensor &input, int32_t dim, const topsatenDataType_t &dtype, topsStream_t stream=nullptr)

This function returns the cumulative sum of elements of input in the dimension dim.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • dim – The dimension to do the operation over.

  • dtype – The desired data type of returned tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenCumsum (topsatenTensor &output, const topsatenTensor &input, const topsatenSize_t &dims, const topsatenDataType_t &dtype, topsStream_t stream=nullptr)

This function returns the cumulative sum of elements of input in the dimension dim.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • dims – The dims to reduce, maybe a list or tuple.

  • dtype – The desired data type of returned tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenCumprod (topsatenTensor &output, const topsatenTensor &input, int32_t dim, const topsatenDataType_t &dtype, topsStream_t stream=nullptr)

This function returns the cumulative product of elements of input in the dimension dim.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • dim – The dimension to do the operation over.

  • dtype – The desired data type of returned tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenArange (topsatenTensor &output, const topsatenScalar_t &end, const topsatenDataType_t &dtype, const topsatenLayoutType_t &layout, bool pinMemory, topsStream_t stream=nullptr)

This function returns a tensor with values from the interval [start, end) taken with common difference step beginning from start, in this function start always equals to 0 and step always equals to 1.

Parameters
  • output – The output tensor.

  • end – The ending value for the set of points.

  • dtype – The desired data type of returned tensor.

  • layout – The desired layout of returned Tensor.

  • pinMemory – If set to True, the returned tensor will be allocated in pinned memory.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenArange (topsatenTensor &output, const topsatenScalar_t &start, const topsatenScalar_t &end, const topsatenDataType_t &dtype, const topsatenLayoutType_t &layout, bool pinMemory, topsStream_t stream=nullptr)

This function returns a tensor with values from the interval [start, end) taken with common difference step beginning from start, in this function step always equals to 1.

Parameters
  • output – The output tensor.

  • start – The starting value for the set of points.

  • end – The ending value for the set of points.

  • dtype – The desired data type of returned tensor.

  • layout – The desired layout of returned Tensor.

  • pinMemory – If set to True, the returned tensor will be allocated in pinned memory.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenArange (topsatenTensor &output, const topsatenScalar_t &start, const topsatenScalar_t &end, const topsatenScalar_t &step, const topsatenDataType_t &dtype, const topsatenLayoutType_t &layout, bool pinMemory, topsStream_t stream=nullptr)

This function returns a tensor with values from the interval [start, end) taken with common difference step beginning from start.

Parameters
  • output – The output tensor.

  • start – The starting value for the set of points.

  • end – The ending value for the set of points.

  • step – The gap between each pair of adjacent points.

  • dtype – The desired data type of returned tensor.

  • layout – The desired layout of returned Tensor.

  • pinMemory – If set to True, the returned tensor will be allocated in pinned memory.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenAcosh (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

This function returns a new tensor with the inverse hyperbolic cosine of the elements of input.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenArccosh (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

This function returns a new tensor with the inverse hyperbolic cosine of the elements of input.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenAsinh (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

This function returns a new tensor with the inverse hyperbolic sine of the elements of input.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenArcsinh (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

This function returns a new tensor with the inverse hyperbolic sine of the elements of input.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenAtanh (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

This function returns a new tensor with the inverse hyperbolic tangent of the elements of input.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenArctanh (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

This function returns a new tensor with the inverse hyperbolic tangent of the elements of input.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenAsin (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

This function returns a new tensor with the arcsine of the elements of input.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenArcsin (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

This function returns a new tensor with the arcsine of the elements of input.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenAtan (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

This function returns a new tensor with the arctangent of the elements of input.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenArctan (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

This function returns a new tensor with the arctangent of the elements of input.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenCopysign (topsatenTensor &output, const topsatenTensor &lhs, const topsatenScalar_t &rhs, topsStream_t stream=nullptr)

This function creates a new floating-point tensor with the magnitude of input and the sign of other, elementwise.

Parameters
  • output – The output tensor.

  • lhs – The magnitudes.

  • rhs – The number contains values whose signbits are applied to the magnitudes in input.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenCopysign (topsatenTensor &output, const topsatenTensor &lhs, const topsatenTensor &rhs, topsStream_t stream=nullptr)

This function creates a new floating-point tensor with the magnitude of input and the sign of other, elementwise.

Parameters
  • output – The output tensor.

  • lhs – The magnitudes.

  • rhs – The tensor contains values whose signbits are applied to the magnitudes in input.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenLogicalNot (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

This function computes the element-wise logical NOT of the given input tensor. If not specified, the output tensor will have the bool dtype.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenLogicalXor (topsatenTensor &output, const topsatenTensor &lhs, const topsatenTensor &rhs, topsStream_t stream=nullptr)

This function computes the element-wise logical XOR of the given input tensors. Zeros are treated as False and nonzeros are treated as True.

Parameters
  • output – The output tensor.

  • lhs – The input tensor.

  • rhs – The tensor to compute XOR with.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenLogicalAnd (topsatenTensor &output, const topsatenTensor &lhs, const topsatenTensor &rhs, topsStream_t stream=nullptr)

This function computes the element-wise logical AND of the given input tensors. Zeros are treated as False and nonzeros are treated as True.

Parameters
  • output – The output tensor.

  • lhs – The input tensor.

  • rhs – The tensor to compute AND with.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenLogicalOr (topsatenTensor &output, const topsatenTensor &lhs, const topsatenTensor &rhs, topsStream_t stream=nullptr)

This function computes the element-wise logical OR of the given input tensors. Zeros are treated as False and nonzeros are treated as True.

Parameters
  • output – The output tensor.

  • lhs – The input tensor.

  • rhs – The tensor to compute OR with.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGlu (topsatenTensor &output, const topsatenTensor &input, const int32_t dim=-1, topsStream_t stream=nullptr)

This function applies the Gated Linear Unit (GLU) activation operation on the input tensor, splitting it into two halves on a specified dimension and then multiplying one half by the sigmoid of the other half for non-linear transformation.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • dim – Dimension on which to split the input. Default: -1.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGluJvp (topsatenTensor &output, const topsatenTensor &glu, const topsatenTensor &x, const topsatenTensor &dx, const int32_t dim, topsStream_t stream=nullptr)

This function calculates the Jacobian-vector product (JVP) for the Gated Linear Unit (GLU) activation function.

Parameters
  • output – The output tensor.

  • glu – The the GLU output.

  • x – The input tensor.

  • dx – The perturbation of the input.

  • dim – The dimension along which the GLU operation.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenHardsigmoid (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

This function computes the hard sigmoid activation of the input tensor and writes the result directly into the output tensor.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenHardtanh (topsatenTensor &output, const topsatenTensor &input, const topsatenScalar_t &min_val={TOPSATEN_DATA_FP32, {.fval=-1.0}}, const topsatenScalar_t &max_val={TOPSATEN_DATA_FP32, {.fval=1.0}}, topsStream_t stream=nullptr)

This function applies the hard hyperbolic tangent activation to the input tensor self, clipping its values to be within the range specified by min_val and max_val.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • min_val – Minimum value of the linear region range. Default: -1.

  • max_val – Maximum value of the linear region range. Default: 1.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenHardswish (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

This function applies the Hard Swish activation function to the input tensor, providing a piecewise linear approximation of the Swish activation for efficient computation.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenMatmul (topsatenTensor &out, const topsatenTensor &lhs, const topsatenTensor &rhs, topsStream_t stream=nullptr)

Matmul operator.

Parameters
  • out – The output tensor.

  • lhs – The input tensor of lhs.

  • rhs – The input tensor of rhs.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenBmm (topsatenTensor &out, const topsatenTensor &lhs, const topsatenTensor &rhs, topsStream_t stream=nullptr)

Bmm operator.

Parameters
  • out – The output tensor.

  • lhs – The input tensor of lhs.

  • rhs – The input tensor of rhs.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenOuter (topsatenTensor &out, const topsatenTensor &lhs, const topsatenTensor &rhs, topsStream_t stream=nullptr)

Outer operator.

Parameters
  • out – The output tensor.

  • lhs – The input tensor of lhs.

  • rhs – The input tensor of rhs.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenAddmm (topsatenTensor &out, const topsatenTensor &self, const topsatenTensor &lhs, const topsatenTensor &rhs, const topsatenScalar_t &beta={TOPSATEN_DATA_FP32, {1.0}}, const topsatenScalar_t &alpha={TOPSATEN_DATA_FP32, {1.0}}, topsStream_t stream=nullptr)

Addmm operator.

Parameters
  • out – The output tensor.

  • self – The input tensor of self.

  • lhs – The input tensor of lhs.

  • rhs – The input tensor of rhs.

  • alpha – Scaling factor used to blend the computation result.

  • beta – Scaling factor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenScatter (topsatenTensor &output, const topsatenTensor &input, const topsatenTensor &index, const topsatenTensor &source, int32_t dim, const topsatenScatterComputationType_t &computation, topsStream_t stream=nullptr)

This function performs the scatter function.

Parameters
  • output – Scatter result.

  • input – Tensor we are scattering from.

  • index – The indices of elements to scatter.

  • source – The source element(s) to scatter.

  • dim – The axis along which to index.

  • computation – Reduction operation to apply.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenScatter (topsatenTensor &output, const topsatenTensor &input, const topsatenTensor &index, topsatenScalar_t &source, int32_t dim, const topsatenScatterComputationType_t &computation, topsStream_t stream=nullptr)

This function performs the scatter function.

Parameters
  • output – Scatter result.

  • input – Tensor we are scattering from.

  • index – The indices of elements to scatter.

  • source – The source element to scatter.

  • dim – The axis along which to index.

  • computation – Reduction operation to apply.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenRngUniform (topsatenTensor &output, double from, double to, const topsatenGenerator_t &generator, topsStream_t stream=nullptr)

This function generate random uniform data.

Parameters
  • output – Output tensor.

  • from – Scalar of type T specifying lower limit of interval.

  • to – Scalar of type T specifying upper limit of interval.

  • generator – Generator used to initialize random number generator states.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenDropout (topsatenTensor &output, const topsatenTensor &input, double p, bool train, const topsatenGenerator_t &generator, topsStream_t stream=nullptr)

This function performs forward dropout operation.

Parameters
  • output – Result tensor.

  • input – Input tensor.

  • p – The probability with which the value from input is set to zero during the dropout layer.

  • train – Indicate if it is a train process.

  • generator – Generator used to initialize random number generator states.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenNativeDropout (topsatenTensor &output, topsatenTensor &mask, const topsatenTensor &input, double p, bool train, const topsatenGenerator_t &generator, topsStream_t stream=nullptr)

This function performs forward dropout operation.

Parameters
  • output – Result tensor.

  • mask – Mask tensor.

  • input – Input tensor.

  • p – The probability with which the value from input is set to zero during the dropout layer.

  • train – Indicate if it is a train process.

  • generator – Generator used to initialize random number generator states.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenNativeDropoutBackward (topsatenTensor &output, const topsatenTensor &input, const topsatenTensor &mask, double scale, topsStream_t stream=nullptr)

This function performs backward dropout operation.

Parameters
  • output – Result tensor.

  • input – Input tensor.

  • mask – Mask tensor.

  • scale – The probability with which the value from input is set to zero during the dropout layer.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenHARDTANHBwd (topsatenTensor &output, const topsatenTensor &grad_output, const topsatenTensor &self, const topsatenScalar_t &min, const topsatenScalar_t &max, topsStream_t stream=nullptr)

This function performs the backward hardtanh.

Parameters
  • grad_output – The input tensor dy.

  • self – The input tensor x.

  • output – The output tensor.

  • min – Min_value.

  • max – Max_value.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenEluBackward (topsatenTensor &output, const topsatenTensor &grad_input, const topsatenTensor &input, const topsatenScalar_t &alpha, const topsatenScalar_t &scale, const topsatenScalar_t &input_scale, bool is_result, topsStream_t stream=nullptr)

This function performs the elu backward function. is_result = True : input > 0 : grad_input * scale : input <= 0 : grad_input * input_scale * (b_op + alpha * scale) is_result = False : input > 0 : grad_input * scale : input <= 0 : grad_input * scale * alpha * input_scale * exp(input_scale * b_op).

Parameters
  • output – Elu backward result.

  • input – The source tensor.

  • alpha – The alpha.

  • scale – The scale.

  • input_scale – The scale of input.

  • is_result – If True, input is Y, else input is X.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenTanhBackward (topsatenTensor &grad_input, const topsatenTensor &grad_output, const topsatenTensor &output, topsStream_t stream=nullptr)

Computes the backward pass for the hyperbolic tangent function.

This function calculates the gradient of the loss with respect to the input tensor using the hyperbolic tangent backward formula: grad_input = grad_output * (1 - output^2).

Parameters
  • grad_input[out] – The computed gradient of the loss with respect to the input tensor.

  • grad_output[in] – The gradient of the loss with respect to the output tensor.

  • output[in] – The output tensor from the forward pass of the hyperbolic tangent function.

  • stream[in] – The stream for asynchronous execution (if applicable).

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenSiluBackward (topsatenTensor &grad_input, const topsatenTensor &grad_output, const topsatenTensor &self, topsStream_t stream=nullptr)

This function applies the SiLU backwad function, element-wise.

Parameters
  • grad_input – The output tensor.

  • grad_output – The input tensor.

  • self – The input tensor. x of silu(x).

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenRandn (topsatenTensor &output, const topsatenSize_t &size, const topsatenDataType_t &dtype, const topsatenLayoutType_t &layout, bool pinMemory, topsStream_t stream=nullptr)

Returns a tensor filled with random numbers from a normal distribution with mean 0 and variance 1 (also called the standard normal distribution).

Parameters
  • output – The output tensor.

  • size – The shape of the output tensor.

  • dtype – The data type of the output tensor.

  • layout – The desired layout of returned Tensor.

  • pinMemory – If set to True, the returned tensor will be allocated in pinned memory. Works only for CPU tensor.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenRandn (topsatenTensor &output, const topsatenSize_t &size, const topsatenDataType_t &dtype, const topsatenLayoutType_t &layout, bool pinMemory, const topsatenGenerator_t &generator, topsStream_t stream=nullptr)

Returns a tensor filled with random numbers from a normal distribution with mean 0 and variance 1 (also called the standard normal distribution).

Parameters
  • output – The output tensor.

  • size – The shape of the output tensor.

  • dtype – The data type of the output tensor.

  • layout – The desired layout of returned Tensor.

  • pinMemory – If set to True, the returned tensor will be allocated in pinned memory. Works only for CPU tensor.

  • generator – Creates and returns a generator object that manages the state of an algorithm that generates pseudo-random numbers.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenRandnLike (topsatenTensor &output, const topsatenTensor &input, const topsatenDataType_t &dtype, const topsatenLayoutType_t &layout, bool pinMemory, const topsatenMemoryFormat_t &format, const topsatenGenerator_t &generator, topsStream_t stream=nullptr)

Returns a tensor with the same size as input that is filled with random numbers from a normal distribution with mean 0 and variance 1.

Parameters
  • output – Result tensor.

  • input – Input tensor.

  • dtype – The data type of the output tensor.

  • layout – The desired layout of returned Tensor.

  • pinMemory – If set to True, the returned tensor will be allocated in pinned memory. Works only for CPU tensor.

  • format – Memory format, specifying storage type.

  • generator – Generator used to initialize random number generator states.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenNormal (topsatenTensor &output, double mean, double std, const topsatenGenerator_t &generator, topsStream_t stream=nullptr)

This function returns a tensor of random numbers drawn from separate normal distributions whose mean and standard deviation are given.

Parameters
  • output – The output tensor.

  • mean – The mean of each output element’s normal distribution.

  • std – The standard deviation of each output element’s normal distribution.

  • generator – Creates and returns a generator object that manages the state of an algorithm that generates pseudo-random numbers.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenNormal (topsatenTensor &output, const topsatenTensor &mean, double std, const topsatenGenerator_t &generator, topsStream_t stream=nullptr)

This function returns a tensor of random numbers drawn from separate normal distributions whose mean and standard deviation are given.

Parameters
  • output – The output tensor.

  • mean – The mean of each output element’s normal distribution.

  • std – The standard deviation of each output element’s normal distribution.

  • generator – Creates and returns a generator object that manages the state of an algorithm that generates pseudo-random numbers.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenNormal (topsatenTensor &output, double mean, const topsatenTensor &std, const topsatenGenerator_t &generator, topsStream_t stream=nullptr)

This function returns a tensor of random numbers drawn from separate normal distributions whose mean and standard deviation are given.

Parameters
  • output – The output tensor.

  • mean – The mean of each output element’s normal distribution.

  • std – The standard deviation of each output element’s normal distribution.

  • generator – Creates and returns a generator object that manages the state of an algorithm that generates pseudo-random numbers.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenNormal (topsatenTensor &output, const topsatenTensor &mean, const topsatenTensor &std, const topsatenGenerator_t &generator, topsStream_t stream=nullptr)

This function returns a tensor of random numbers drawn from separate normal distributions whose mean and standard deviation are given.

Parameters
  • output – The output tensor.

  • mean – The mean of each output element’s normal distribution.

  • std – The standard deviation of each output element’s normal distribution.

  • generator – Creates and returns a generator object that manages the state of an algorithm that generates pseudo-random numbers.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenResultType (topsatenDataType_t &dtype, const topsatenTensor &lhs, const topsatenTensor &rhs, topsStream_t stream=nullptr)

Returns the type that would result from performing an arithmetic operation on the provided input tensors.

Parameters
  • dtype – The output data type.

  • lhs – Input lhs tensor.

  • rhs – Input rhs tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenResultType (topsatenDataType_t &dtype, const topsatenScalar_t &lhs, const topsatenTensor &rhs, topsStream_t stream=nullptr)

Returns the type that would result from performing an arithmetic operation on the provided input tensors.

Parameters
  • dtype – The output data type.

  • lhs – Input lhs scalar.

  • rhs – Input rhs tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenResultType (topsatenDataType_t &dtype, const topsatenTensor &lhs, const topsatenScalar_t &rhs, topsStream_t stream=nullptr)

Returns the type that would result from performing an arithmetic operation on the provided input tensors.

Parameters
  • dtype – The output data type.

  • lhs – Input lhs tensor.

  • rhs – Input rhs scalar.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenResultType (topsatenDataType_t &dtype, const topsatenScalar_t &lhs, const topsatenScalar_t &rhs, topsStream_t stream=nullptr)

Returns the type that would result from performing an arithmetic operation on the provided input tensors.

Parameters
  • dtype – The output data type.

  • lhs – Input lhs scalar.

  • rhs – Input rhs scalar.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenTile (topsatenTensor &output, const topsatenTensor &input, const topsatenSize_t &dims, topsStream_t stream=nullptr)

Constructs a tensor by repeating the elements of input. The dims argument specifies the number of repetitions in each dimension.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • dims – The number of repetitions per dimension.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenNewOnes (topsatenTensor &output, const topsatenTensor &input, const topsatenSize_t &size, const topsatenDataType_t &data_type, topsStream_t stream=nullptr)

Returns a Tensor of size size filled with 1.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • size – The shape of the output tensor.

  • data_type – Output data type.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenIsNonzero (bool &flag, const topsatenTensor &input, topsStream_t stream=nullptr)

Returns True if the input is a single element tensor which is not equal to zero after type conversions.

Parameters
  • flag – The flag to indicate if the input is a single element tensor which is not equal to zero after type conversions.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenNLLLossForward (topsatenTensor &output, topsatenTensor &total_weight, const topsatenTensor &input, const topsatenTensor &target, const topsatenTensor &weight, const int64_t reduction, const int64_t ignore_index, topsStream_t stream=nullptr)

This function computes the negative log likelihood loss. It is useful to train a classification problem with C classes.

Parameters
  • output – The output tensor.

  • total_weight – The sum of the weights of the loss values for each sample.

  • input – The input tensor.

  • target – The target that this loss expects should be a class index in the range [0, C-1] where C = number of classes.

  • weight – The weight tensor shouled be 1D tensor, assigning weight to each of the classes.

  • reduction – Specifies the reduction to apply to the output: ‘none’ | ‘mean’ | ‘sum’. ‘none’: no reduction will be applied, ‘mean’: the weighted mean of the output is taken, ‘sum’: the output will be summed.

  • ignore_index – Specifies a target value that is ignored and does not contribute to the input gradient.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenNLLLoss2DForward (topsatenTensor &output, topsatenTensor &total_weight, const topsatenTensor &input, const topsatenTensor &target, const topsatenTensor &weight, const int64_t reduction, const int64_t ignore_index, topsStream_t stream=nullptr)

This function computes the negative log likelihood loss. It is useful to train a classification problem with C classes.

Parameters
  • output – The output tensor.

  • total_weight – The sum of the weights of the loss values for each sample.

  • input – The input tensor.

  • target – The target that this loss expects should be a class index in the range [0, C-1] where C = number of classes.

  • weight – The weight tensor shouled be 1D tensor, assigning weight to each of the classes.

  • reduction – Specifies the reduction to apply to the output: ‘none’ | ‘mean’ | ‘sum’. ‘none’: no reduction will be applied, ‘mean’: the weighted mean of the output is taken, ‘sum’: the output will be summed.

  • ignore_index – Specifies a target value that is ignored and does not contribute to the input gradient.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenCrossEntropyLoss (topsatenTensor &output, const topsatenTensor &input, const topsatenTensor &target, const topsatenTensor &weight, const int64_t reduction, const int64_t ignore_index, const double label_smoothing, topsStream_t stream=nullptr)

This function computes the cross entropy loss between input logits and target.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • target – The target that this loss expects should be a class index in the range [0, C-1] where C = number of classes.

  • weight – The weight tensor shouled be 1D tensor, assigning weight to each of the classes.

  • reduction – Specifies the reduction to apply to the output: ‘none’ | ‘mean’ | ‘sum’. ‘none’: no reduction will be applied, ‘mean’: the weighted mean of the output is taken, ‘sum’: the output will be summed.

  • ignore_index – Specifies a target value that is ignored and does not contribute to the input gradient.

  • stream – Tops stream.

  • label_smoothing – A float in [0.0, 1.0]. Specifies the amount of smoothing when computing the loss, where 0.0 means no smoothing.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenScaledDotProductAttention (topsatenTensor &output, const topsatenTensor &query, const topsatenTensor &key, const topsatenTensor &value, const topsatenTensor &attn_mask, const double dropout_p, const bool is_causal, const topsatenScalar_t &scale, topsStream_t stream=nullptr)

Multi query kv attention operator.

Parameters
  • output – The output tensor.

  • query – Input tensor query.

  • key – Input tensor key.

  • value – Input tensor value.

  • attn_mask – Attention mask.

  • dropout_p – Dropout probability.

  • is_causal – If true, assumes causal attention masking.

  • scale – Scale value.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenScaledDotProductEfficientAttention (std::tuple< topsatenTensor, topsatenTensor, topsatenTensor, topsatenTensor > &output, const topsatenTensor &query, const topsatenTensor &key, const topsatenTensor &value, const topsatenTensor &attn_mask, bool compute_log_sumexp, const double dropout_p, bool is_causal, const topsatenScalar_t &scale, topsStream_t stream=nullptr)

Scaled dot product efficient attention operator.

Parameters
  • output – The output tuple, below is details.

  • out – The first output tensor in output tuple.

  • logsumexp – The output tensor.

  • seed – The output tensor.

  • offset – The last output tensor in output tuple.

  • query – Input tensor query.

  • key – Input tensor key.

  • value – Input tensor value.

  • attn_mask – Attention mask.

  • compute_log_sumexp – Whether compute log mask.

  • dropout_p – Dropout probability.

  • is_causal – If true, assumes causal attention masking.

  • scale – Scale value.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenScaledDotProductFlashAttention (std::tuple< topsatenTensor, topsatenTensor, topsatenTensor, topsatenTensor, int64_t, int64_t, topsatenTensor, topsatenTensor, topsatenTensor > &output, const topsatenTensor &query, const topsatenTensor &key, const topsatenTensor &value, const double dropout_p, bool is_causal, bool return_debug_mask, const topsatenScalar_t &scale, topsStream_t stream=nullptr)

Scaled dot product flash attention operator.

Parameters
  • output – The output tuple, below is details.

  • out – The first output tensor in output tuple.

  • logsumexp – The output tensor.

  • cum_seq_q – The output tensor.

  • cum_seq_k – The output tensor.

  • max_q – The max q.

  • max_k – The max k.

  • philox_seed – The output tensor.

  • philox_offset – The output tensor.

  • debug_attn_mask – The last output tensor in output tuple.

  • query – Input tensor query.

  • key – Input tensor key.

  • value – Input tensor value.

  • dropout_p – Dropout probability.

  • is_causal – If true, assumes causal attention masking.

  • return_debug_mask – Whether return debug mask.

  • scale – Scale value.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenWhere (topsatenTensor &output, const topsatenTensor &condition, const topsatenTensor &input, const topsatenTensor &other, topsStream_t stream=nullptr)

Return a tensor of elements selected from either input or other, depending on condition.

Parameters
  • out – The output tensor.

  • condition – Bool tensor used to select values from input and other.

  • input – Values selected at indices where condition is true.

  • other – Values selected at indices where condition is false.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenWhere (topsatenTensor &output, const topsatenTensor &condition, const topsatenScalar_t &input, const topsatenTensor &other, topsStream_t stream=nullptr)

Return a tensor of elements selected from either input or other, depending on condition.

Parameters
  • output – The output tensor.

  • condition – Bool tensor used to select values from input and other.

  • input – Value selected at indices where condition is true.

  • other – Values selected at indices where condition is false.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenWhere (topsatenTensor &output, const topsatenTensor &condition, const topsatenTensor &input, const topsatenScalar_t &other, topsStream_t stream=nullptr)

Return a tensor of elements selected from either input or other, depending on condition.

Parameters
  • output – The output tensor.

  • condition – Bool tensor used to select values from input and other.

  • input – Values selected at indices where condition is true.

  • other – Value selected at indices where condition is false.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenWhere (topsatenTensor &output, const topsatenTensor &condition, const topsatenScalar_t &input, const topsatenScalar_t &other, topsStream_t stream=nullptr)

Return a tensor of elements selected from either input or other, depending on condition.

Parameters
  • output – The output tensor.

  • condition – Bool tensor used to select values from input and other.

  • input – Value selected at indices where condition is true.

  • other – Value selected at indices where condition is false.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenWhere (std::vector< topsatenTensor > &output, const topsatenTensor &input, topsStream_t stream=nullptr)

Return the indices of the elements that are non-zero.

Parameters
  • output – The output tensors.

  • input – Input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenLerp (topsatenTensor &output, const topsatenTensor &start, const topsatenTensor &end, const topsatenTensor &weight, topsStream_t stream=nullptr)

Does a linear interpolation of start and end based on weight.

Out[i] = start[i] + weight[i]*(end[i] - start[i]).

Parameters
  • out – The output tensor.

  • start – The tensor with the starting points.

  • end – The tensor with the ending points.

  • weight – The weight for the interpolation formula.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenLerp (topsatenTensor &output, const topsatenTensor &start, const topsatenTensor &end, const topsatenScalar_t &weight, topsStream_t stream=nullptr)

Does a linear interpolation of start and end based on weight.

Out[i] = start[i] + weight*(end[i] - start[i]).

Parameters
  • out – The output tensor.

  • start – The tensor with the starting points.

  • end – The tensor with the ending points.

  • weight – The weight for the interpolation formula.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenFlip (topsatenTensor &output, const topsatenTensor &input, const topsatenSize_t &dimensions, topsStream_t stream=nullptr)

Reverse the order of an n-D tensor along given axis in dims.

Parameters
  • out – The output tensor.

  • input – The input tensor.

  • dimensions – Given axies.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenClampMin (topsatenTensor &output, const topsatenTensor &input, const topsatenTensor &min, topsStream_t stream=nullptr)

Returns the tensor after performing a lower bound truncation operation on the input tensor.

Parameters
  • output – The output tensor.

  • input – Input tensor to perform lower bound truncation operation.

  • min – Replace elements less than the specified lower limit tensor with elements corresponding to the lower limit tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenClampMin (topsatenTensor &output, const topsatenTensor &input, const topsatenScalar_t &min, topsStream_t stream=nullptr)

Returns the tensor after performing a lower bound truncation operation on the input tensor.

Parameters
  • output – The output tensor.

  • input – Input tensor to perform lower bound truncation operation.

  • min – Replace elements less than the specified lower limit value with this value.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenClampMax (topsatenTensor &output, const topsatenTensor &input, const topsatenTensor &max, topsStream_t stream=nullptr)

Returns the tensor after performing a upper bound truncation operation on the input tensor.

Parameters
  • output – The output tensor.

  • input – Input tensor to perform upper bound truncation operation.

  • max – Replace elements greater than the specified upper limit tensor with elements corresponding to the upper limit tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenClampMax (topsatenTensor &output, const topsatenTensor &input, const topsatenScalar_t &max, topsStream_t stream=nullptr)

Returns the tensor after performing a upper bound truncation operation on the input tensor.

Parameters
  • output – The output tensor.

  • input – Input tensor to perform upper bound truncation operation.

  • max – Replace elements greater than the specified upper limit value with this value.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenArgmax (topsatenTensor &output, const topsatenTensor &input, const topsatenScalar_t &dimensions, const bool keepdims, topsStream_t stream=nullptr)

This function gets the relative indices of maximum value for the dimensions being reduced.

Parameters
  • output_idx – The output tensor of indices.

  • input – The input tensor.

  • dimensions – The dimensions to reduce.

  • keepdims – Whether the output tensor has dim retained or not.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenAmax (topsatenTensor &output, const topsatenTensor &input, const topsatenSize_t &dims, bool keepdim, topsStream_t stream=nullptr)

This function performs a max computation.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • dimensions – The dimensions to reduce max.

  • keepdims – Whether the output tensor has dim retained or not.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenSum (topsatenTensor &output, const topsatenTensor &input, const topsatenDataType_t &data_type, topsStream_t stream=nullptr)

This function performs a addition computation.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • data_type – Data type.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenSum (topsatenTensor &output, const topsatenTensor &input, const topsatenSize_t &dimensions, const bool keepdims, const topsatenDataType_t &data_type, topsStream_t stream=nullptr)

This function performs a addition computation.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • dimensions – The dimensions to reduce sum.

  • keepdims – Whether the output tensor has dim retained or not.

  • data_type – Data type.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenTo (topsatenTensor &output, const topsatenTensor &input, topsatenDataType_t &dtype, const bool non_blocking, const bool copy, const topsatenMemoryFormat_t &format, topsStream_t stream=nullptr)

This function performs the convert function.

Parameters
  • output – The output tensor.

  • input – The source tensor.

  • dtype – The data type of the output tensor.

  • non_blocking – If true and this copy is between CPU and GCU.

  • copy – Whether to create a new tensor.

  • format – The memory format of the output tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenNonzero (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

This function performs the nonzero function.

Parameters
  • out – The output tensor, output_num must be input_rank * input_num.

  • input – The source tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenCountNonzero (int32_t *count_nonzero, const topsatenTensor &input, topsStream_t stream=nullptr)

This function performs the nonzero function.

Parameters
  • count_nonzero – The number of nonzero elements in the input tensor.

  • input – The source tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenTopk (topsatenTensor &output_value, topsatenTensor &output_index, const topsatenTensor &input, int64_t k, int64_t axis, bool is_largest, bool is_sorted, topsStream_t stream=nullptr)

This function performs the topk function.

Parameters
  • output_value – Output value tensor.

  • output_index – Output index tensor.

  • input – Input tensort.

  • k – The K value is used to take the largest first k value or the smallest first k value, k should be less than or equal to dim_input[axis].

  • axis – Take the dimensions of the first k values.

  • is_largest – The select of topk computation( true: Get the top k largest values false: Get the top k smallest values.

  • is_sorted – Whether the results are sorted or not.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenTopk2 (topsatenTensor &output_value, topsatenTensor &output_index, const topsatenTensor &input, int64_t k, int64_t axis, bool is_largest, bool is_sorted, topsStream_t stream=nullptr)

This function performs the topk function.

Parameters
  • output_value – Output value tensor.

  • output_index – Output index tensor.

  • input – Input tensort.

  • k – The K value is used to take the largest first k value or the smallest first k value, k should be less than or equal to dim_input[axis].

  • axis – Take the dimensions of the first k values.

  • is_largest – The select of topk computation( true: Get the top k largest values false: Get the top k smallest values.

  • is_sorted – Whether the results are sorted or not.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenMultinomial (topsatenTensor &output, const topsatenTensor &input, const int64_t num_samples, const bool replacement, const topsatenGenerator_t &generator, topsStream_t stream=nullptr)

Returns a tensor where each row contains num_samples indices sampled from the multinomial probability distribution located in the corresponding row of tensor input.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • num_samples – Samples nums per Categories.

  • replacement – Sample with replacement or not.

  • generator – Generator used to initialize random number generator states.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenMasked_fill (topsatenTensor &output, const topsatenTensor &input, const topsatenTensor &mask, const topsatenScalar_t &value, topsStream_t stream=nullptr)

Fills elements of new tensor with value where mask is True. The shape of mask must be broadcastable with the shape of the underlying tensor.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • mask – The mask tensor.

  • value – The filled value.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenMasked_fill (topsatenTensor &output, const topsatenTensor &input, const topsatenTensor &mask, const topsatenTensor &value_tensor, topsStream_t stream=nullptr)

Fills elements of new tensor with value where mask is True. The shape of mask must be broadcastable with the shape of the underlying tensor.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • mask – The mask tensor.

  • value_tensor – The filled value tensor, it is scalar tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenFill_ (topsatenTensor &filled_tensor, const topsatenScalar_t &value, topsStream_t stream=nullptr)

Fills self tensor with the specified value.

Parameters
  • filled_tensor – The filled tensor.

  • value – The filled value.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenFill_ (topsatenTensor &filled_tensor, const topsatenTensor &value, topsStream_t stream=nullptr)

Fills self tensor with the specified value.

Parameters
  • filled_tensor – The filled tensor.

  • value – The filled value tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenFull (topsatenTensor &output, const topsatenSize_t &size, const topsatenScalar_t &value, topsStream_t stream=nullptr)

Fills self tensor with the specified value.

Parameters
  • output – The output tensor.

  • size – Dimension of output.

  • value – The value to fill the output tensor with.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenMm (topsatenTensor &out, const topsatenTensor &lhs, const topsatenTensor &rhs, topsStream_t stream=nullptr)

Mm operator.

Parameters
  • out – The output tensor.

  • lhs – The input tensor of lhs.

  • rhs – The input tensor of rhs.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenNegConj (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

Negate the real part of the input.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenConj (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

Negate the imaginary part of the input.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenBitwiseNot (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

Computes the bitwise NOT of the given input tensor.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenAbs (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

Computes the absolute value of each element in input.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenExp (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

Returns a new tensor with the exponential of the elements of the input tensor.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenExp2 (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

Computes the base two exponential function of input.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenExpm1 (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

Computes the exponential of the elements minus 1 of input.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenSigmoid (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

Computes the expit of the elements of input.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenSqrt (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

Returns a new tensor with the square-root of the elements of input.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenCeil (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

Returns a new tensor with the ceil of the elements of input.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenFloor (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

Returns a new tensor with the floor of the elements of input.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGelu (topsatenTensor &output, const topsatenTensor &input, const char *const approximate="none", topsStream_t stream=nullptr)

Applies the Gaussian Error Linear Units function of the elements of input.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • approximate – The gelu approximation algorithm to use.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenElu (topsatenTensor &output, const topsatenTensor &input, const topsatenScalar_t &alpha={TOPSATEN_DATA_FP32, {.fval=1.0}}, const topsatenScalar_t &scale={TOPSATEN_DATA_FP32, {.fval=1.0}}, const topsatenScalar_t &input_scale={TOPSATEN_DATA_FP32, {.fval=1.0}}, topsStream_t stream=nullptr)

Applies the Exponential Linear Unit (ELU) function.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • alpha – Value for the ELU formulation. Default: 1.0.

  • scale – Value for the ELU formulation. Default: 1.0.

  • input_scale – Value for the ELU formulation. Default: 1.0.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenRelu (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

Applies the rectified linear unit function element-wise.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenRrelu (topsatenTensor &output, const topsatenTensor &input, const topsatenScalar_t &lower={TOPSATEN_DATA_FP32, {.fval=0.125}}, const topsatenScalar_t &upper={TOPSATEN_DATA_FP32, {.fval=0.3333333333333333}}, const bool &training=false, const topsatenGenerator_t &generator={}, topsStream_t stream=nullptr)

Applies the randomized leaky rectified linear unit function, element-wise.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • lower – Lower bound of the uniform distribution. Default: 1 / 8.

  • upper – Upper bound of the uniform distribution. Default: 1 / 3.

  • training – Training mode or evaluation mode.

  • generator – Generator of the uniform distribution.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenRreluWithNoise (topsatenTensor &output, const topsatenTensor &input, const topsatenTensor &noise, const topsatenScalar_t &lower={TOPSATEN_DATA_FP32, {.fval=0.125}}, const topsatenScalar_t &upper={TOPSATEN_DATA_FP32, {.fval=0.3333333333333333}}, const bool &training=false, const topsatenGenerator_t &generator={}, topsStream_t stream=nullptr)

Applies the randomized leaky rectified linear unit function, element-wise.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • noise – The noise tensor.

  • lower – Lower bound of the uniform distribution. Default: 1 / 8.

  • upper – Upper bound of the uniform distribution. Default: 1 / 3.

  • training – Training mode or evaluation mode.

  • generator – Generator of the uniform distribution.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenRelu6 (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

Applies the element-wise function: ReLU6(x) = min(max(x0, x), q(6)), where x0 is the zero_point, and q(6) is the quantized representation of number 6.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenHardshrink (topsatenTensor &output, const topsatenTensor &input, const topsatenScalar_t &lambd={TOPSATEN_DATA_FP32, {.fval=0.5}}, topsStream_t stream=nullptr)

Applies the Hard Shrinkage (Hardshrink) function element-wise.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • lambd – The λ value for the Hardshrink formulation. Default: 0.5.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenSelu (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

Applies the SELU function element-wise. SELU(x) = scale * (max(0, x) + min(0, α * (exp(x) − 1))) with α = 1.6732632423543772848170429916717 and scale = 1.0507009873554804934193349852946.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenCelu (topsatenTensor &output, const topsatenTensor &input, const topsatenScalar_t &alpha={TOPSATEN_DATA_FP32, {.fval=1.}}, topsStream_t stream=nullptr)

Applies the rectified linear unit function element-wise.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • alpha – The α value for the CELU formulation. Default: 1.0.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenMish (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

Applies the Mish function, element-wise. Mish: A Self Regularized Non-Monotonic Neural Activation Function. Mish(x) = x * Tanh(Softplus(x)).

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenLogit (topsatenTensor &output, const topsatenTensor &input, const topsatenScalar_t &eps={TOPSATEN_DATA_NONE, {}}, topsStream_t stream=nullptr)

Applies the rectified linear unit function element-wise.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • eps – The epsilon for input clamp bound. Default: None.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenSinh (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

Returns a new tensor with the hyperbolic sine of the elements of input.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenTan (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

Returns a new tensor with the tangent of the elements of input.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenLeakyRelu (topsatenTensor &output, const topsatenTensor &input, const topsatenScalar_t &negative_slope={TOPSATEN_DATA_FP32, {.fval=0.01}}, topsStream_t stream=nullptr)

Applies the function: leaky_relu(x) = x >= 0 ? x : negative_slope * x.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • negative_slope – Controls the angle of the negative slope (which is used for negative input values). Default: 1e-2.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenSoftplus (topsatenTensor &output, const topsatenTensor &input, const topsatenScalar_t &beta={TOPSATEN_DATA_FP32, {.fval=1}}, const topsatenScalar_t &threshold={TOPSATEN_DATA_FP32, {.fval=20}}, topsStream_t stream=nullptr)

Applies the Softplus function element-wise.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • beta – The β value for the Softplus formulation. Default: 1.

  • threshold – Values above this revert to a linear function. Default: 20.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenSoftshrink (topsatenTensor &output, const topsatenTensor &input, const topsatenScalar_t &lambd={TOPSATEN_DATA_FP32, {.fval=0.5}}, topsStream_t stream=nullptr)

Applies the soft shrinkage function element-wise.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • lambd – The λ (must be no less than zero) value for the Softshrink formulation. Default: 0.5.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenPrelu (topsatenTensor &output, const topsatenTensor &input, const topsatenTensor &weight, topsStream_t stream=nullptr)

Applies the element-wise function: PReLU(x) = max(0, x) + a * min(0, x).

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • weight – The learnable weights.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenPreluKernel (topsatenTensor &output, const topsatenTensor &input, const topsatenTensor &weight, topsStream_t stream=nullptr)

Applies the element-wise function: PReLU(x) = max(0, x) + a * min(0, x).

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • weight – The learnable weights.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenTypeAs (topsatenTensor &out_to, const topsatenTensor &out_from, const topsatenTensor &input, topsStream_t stream=nullptr)

Returns this tensor cast to the type of the given tensor.

Parameters
  • out_to – The output tensor.

  • out_from – The tensor to be convert.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenForeachLerp (std::vector< topsatenTensor > &out, const std::vector< topsatenTensor > &input, const std::vector< topsatenTensor > &end, const std::vector< topsatenTensor > &weight, topsStream_t stream=nullptr)

Does a linear interpolation of start and end based on weight.

Out[i] = input[i] + weight * (end[i] - input[i]).

Parameters
  • out – The output tensor.

  • input – The tensor with the starting points.

  • end – The tensor with the ending points.

  • weight – The weight for the interpolation formula.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenForeachLerp (std::vector< topsatenTensor > &out, const std::vector< topsatenTensor > &input, const std::vector< topsatenTensor > &end, const topsatenScalar_t &weight, topsStream_t stream=nullptr)

Does a linear interpolation of start and end based on weight.

Out[i] = input[i] + weight * (end[i] - input[i]).

Parameters
  • out – The output tensor.

  • input – The tensor with the starting points.

  • end – The tensor with the ending points.

  • weight – The weight for the interpolation formula.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenForeachAdd (std::vector< topsatenTensor > &out, const std::vector< topsatenTensor > &lhs, const topsatenScalar_t &rhs, topsStream_t stream=nullptr)

Foreach add operator.

Parameters
  • out – The output tensor.

  • lhs – Input lhs tensor.

  • rhs – Input rhs scalar.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenForeachAdd (std::vector< topsatenTensor > &out, const std::vector< topsatenTensor > &lhs, const std::vector< topsatenTensor > &rhs, const topsatenScalar_t &alpha={TOPSATEN_DATA_FP32, {.fval=1.0}}, topsStream_t stream=nullptr)

Foreach add operator.

Parameters
  • out – The output tensor.

  • lhs – Input lhs tensor.

  • rhs – Input rhs tensor.

  • alpha – The multiplier for lhs tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenForeachAdd (std::vector< topsatenTensor > &out, const std::vector< topsatenTensor > &lhs, const std::vector< topsatenScalar_t > &rhs, topsStream_t stream=nullptr)

Foreach add operator.

Parameters
  • out – The output tensor.

  • lhs – Input lhs tensor.

  • rhs – Input rhs scalar.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenForeachAdd (std::vector< topsatenTensor > &out, const std::vector< topsatenTensor > &lhs, const topsatenTensor &rhs, const topsatenScalar_t &alpha={TOPSATEN_DATA_FP32, {.fval=1.0}}, topsStream_t stream=nullptr)

Foreach add operator.

Parameters
  • out – The output tensor.

  • lhs – Input lhs tensor.

  • rhs – Input rhs tensor.

  • alpha – The multiplier for lhs tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenForeachSub (std::vector< topsatenTensor > &out, const std::vector< topsatenTensor > &lhs, const topsatenScalar_t &rhs, topsStream_t stream=nullptr)

Foreach sub operator.

Parameters
  • out – The output tensor.

  • lhs – Input lhs tensor.

  • rhs – Input rhs scalar.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenForeachSub (std::vector< topsatenTensor > &out, const std::vector< topsatenTensor > &lhs, const std::vector< topsatenTensor > &rhs, const topsatenScalar_t &alpha={TOPSATEN_DATA_FP32, {.fval=1.0}}, topsStream_t stream=nullptr)

Foreach sub operator.

Parameters
  • out – The output tensor.

  • lhs – Input lhs tensor.

  • rhs – Input rhs tensor.

  • alpha – The multiplier for lhs tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenForeachSub (std::vector< topsatenTensor > &out, const std::vector< topsatenTensor > &lhs, const std::vector< topsatenScalar_t > &rhs, topsStream_t stream=nullptr)

Foreach sub operator.

Parameters
  • out – The output tensor.

  • lhs – Input lhs tensor.

  • rhs – Input rhs scalar.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenForeachClampMin (std::vector< topsatenTensor > &out, const std::vector< topsatenTensor > &lhs, const topsatenScalar_t &rhs, topsStream_t stream=nullptr)

Foreach clamp_min operator.

Parameters
  • out – The output tensor.

  • lhs – Input lhs tensor.

  • rhs – Input rhs scalar.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenForeachClampMin (std::vector< topsatenTensor > &out, const std::vector< topsatenTensor > &lhs, const std::vector< topsatenTensor > &rhs, topsStream_t stream=nullptr)

Foreach clamp_min operator.

Parameters
  • out – The output tensor.

  • lhs – Input lhs tensor.

  • rhs – Input rhs tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenForeachClampMin (std::vector< topsatenTensor > &out, const std::vector< topsatenTensor > &lhs, const std::vector< topsatenScalar_t > &rhs, topsStream_t stream=nullptr)

Foreach clamp_min operator.

Parameters
  • out – The output tensor.

  • lhs – Input lhs tensor.

  • rhs – Input rhs scalar.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenForeachClampMax (std::vector< topsatenTensor > &out, const std::vector< topsatenTensor > &lhs, const topsatenScalar_t &rhs, topsStream_t stream=nullptr)

Foreach clamp_max operator.

Parameters
  • out – The output tensor.

  • lhs – Input lhs tensor.

  • rhs – Input rhs scalar.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenForeachClampMax (std::vector< topsatenTensor > &out, const std::vector< topsatenTensor > &lhs, const std::vector< topsatenTensor > &rhs, topsStream_t stream=nullptr)

Foreach clamp_max operator.

Parameters
  • out – The output tensor.

  • lhs – Input lhs tensor.

  • rhs – Input rhs tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenForeachClampMax (std::vector< topsatenTensor > &out, const std::vector< topsatenTensor > &lhs, const std::vector< topsatenScalar_t > &rhs, topsStream_t stream=nullptr)

Foreach clamp_max operator.

Parameters
  • out – The output tensor.

  • lhs – Input lhs tensor.

  • rhs – Input rhs scalar.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenForeachMaximum (std::vector< topsatenTensor > &out, const std::vector< topsatenTensor > &lhs, const topsatenScalar_t &rhs, topsStream_t stream=nullptr)

Foreach maximum operator.

Parameters
  • out – The output tensor.

  • lhs – Input lhs tensor.

  • rhs – Input rhs scalar.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenForeachMaximum (std::vector< topsatenTensor > &out, const std::vector< topsatenTensor > &lhs, const std::vector< topsatenTensor > &rhs, topsStream_t stream=nullptr)

Foreach maximum operator.

Parameters
  • out – The output tensor.

  • lhs – Input lhs tensor.

  • rhs – Input rhs tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenForeachMaximum (std::vector< topsatenTensor > &out, const std::vector< topsatenTensor > &lhs, const std::vector< topsatenScalar_t > &rhs, topsStream_t stream=nullptr)

Foreach maximum operator.

Parameters
  • out – The output tensor.

  • lhs – Input lhs tensor.

  • rhs – Input rhs scalar.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenForeachMinimum (std::vector< topsatenTensor > &out, const std::vector< topsatenTensor > &lhs, const topsatenScalar_t &rhs, topsStream_t stream=nullptr)

Foreach minmimum operator.

Parameters
  • out – The output tensor.

  • lhs – Input lhs tensor.

  • rhs – Input rhs scalar.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenForeachMinimum (std::vector< topsatenTensor > &out, const std::vector< topsatenTensor > &lhs, const std::vector< topsatenTensor > &rhs, topsStream_t stream=nullptr)

Foreach minmimum operator.

Parameters
  • out – The output tensor.

  • lhs – Input lhs tensor.

  • rhs – Input rhs tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenForeachMinimum (std::vector< topsatenTensor > &out, const std::vector< topsatenTensor > &lhs, const std::vector< topsatenScalar_t > &rhs, topsStream_t stream=nullptr)

Foreach minmimum operator.

Parameters
  • out – The output tensor.

  • lhs – Input lhs tensor.

  • rhs – Input rhs scalar.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenForeachSqrt (std::vector< topsatenTensor > &output, const std::vector< topsatenTensor > &input, topsStream_t stream=nullptr)

Returns a new tensor with the square-root of the elements of input.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenForeachDiv (std::vector< topsatenTensor > &out, const std::vector< topsatenTensor > &lhs, const topsatenScalar_t &rhs, topsStream_t stream=nullptr)

Foreach div operator.

Parameters
  • out – The output tensor.

  • lhs – Input lhs tensor.

  • rhs – Input rhs scalar.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenForeachDiv (std::vector< topsatenTensor > &out, const std::vector< topsatenTensor > &lhs, const std::vector< topsatenTensor > &rhs, topsStream_t stream=nullptr)

Foreach div operator.

Parameters
  • out – The output tensor.

  • lhs – Input lhs tensor.

  • rhs – Input rhs tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenForeachDiv (std::vector< topsatenTensor > &out, const std::vector< topsatenTensor > &lhs, const std::vector< topsatenScalar_t > &rhs, topsStream_t stream=nullptr)

Foreach div operator.

Parameters
  • out – The output tensor.

  • lhs – Input lhs tensor.

  • rhs – Input rhs scalar.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenForeachDiv (std::vector< topsatenTensor > &out, const std::vector< topsatenTensor > &lhs, const topsatenTensor &rhs, topsStream_t stream=nullptr)

Foreach div operator.

Parameters
  • out – The output tensor.

  • lhs – Input lhs tensor.

  • rhs – Input rhs tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenForeachAddcdiv (std::vector< topsatenTensor > &out, const std::vector< topsatenTensor > &input, const std::vector< topsatenTensor > &tensor1, const std::vector< topsatenTensor > &tensor2, const topsatenScalar_t &value={TOPSATEN_DATA_FP32, {.fval=1.0}}, topsStream_t stream=nullptr)

Foreach addcdiv operator.

Out[i] = input[i] + value * (tensor1[i] / tensor2[i]).

Parameters
  • out – The output tensor.

  • input – The tensor to be added.

  • tensor1 – The numerator tensor.

  • tensor2 – The denominator tensor.

  • value – Multiplier for tensor1 / tensor2.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenForeachAddcdiv (std::vector< topsatenTensor > &out, const std::vector< topsatenTensor > &input, const std::vector< topsatenTensor > &tensor1, const std::vector< topsatenTensor > &tensor2, const std::vector< topsatenScalar_t > &value, topsStream_t stream=nullptr)

Foreach addcdiv operator.

Out[i] = input[i] + value * (tensor1[i] / tensor2[i]).

Parameters
  • out – The output tensor.

  • input – The tensor to be added.

  • tensor1 – The numerator tensor.

  • tensor2 – The denominator tensor.

  • value – Multiplier for tensor1 / tensor2.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenForeachAddcdiv (std::vector< topsatenTensor > &out, const std::vector< topsatenTensor > &input, const std::vector< topsatenTensor > &tensor1, const std::vector< topsatenTensor > &tensor2, const topsatenTensor &value, topsStream_t stream=nullptr)

Foreach addcdiv operator.

Out[i] = input[i] + value[i] * (tensor1[i] / tensor2[i]).

Parameters
  • out – The output tensor.

  • input – The tensor to be added.

  • tensor1 – The numerator tensor.

  • tensor2 – The denominator tensor.

  • value – Multiplier for tensor1 / tensor2.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenForeachAddcmul (std::vector< topsatenTensor > &out, const std::vector< topsatenTensor > &input, const std::vector< topsatenTensor > &tensor1, const std::vector< topsatenTensor > &tensor2, const topsatenScalar_t &value={TOPSATEN_DATA_FP32, {.fval=1.0}}, topsStream_t stream=nullptr)

Foreach addcmul operator.

Out[i] = input[i] + value * (tensor1[i] * tensor2[i]).

Parameters
  • out – The output tensor.

  • input – The tensor to be added.

  • tensor1 – The numerator tensor.

  • tensor2 – The denominator tensor.

  • value – Multiplier for tensor1 / tensor2.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenForeachAddcmul (std::vector< topsatenTensor > &out, const std::vector< topsatenTensor > &input, const std::vector< topsatenTensor > &tensor1, const std::vector< topsatenTensor > &tensor2, const std::vector< topsatenScalar_t > &value, topsStream_t stream=nullptr)

Foreach addcmul operator.

Out[i] = input[i] + value * (tensor1[i] * tensor2[i]).

Parameters
  • out – The output tensor.

  • input – The tensor to be added.

  • tensor1 – The numerator tensor.

  • tensor2 – The denominator tensor.

  • value – Multiplier for tensor1 / tensor2.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenForeachAddcmul (std::vector< topsatenTensor > &out, const std::vector< topsatenTensor > &input, const std::vector< topsatenTensor > &tensor1, const std::vector< topsatenTensor > &tensor2, const topsatenTensor &value, topsStream_t stream=nullptr)

Foreach addcmul operator.

Out[i] = input[i] + value[i] * (tensor1[i] * tensor2[i]).

Parameters
  • out – The output tensor.

  • input – The tensor to be added.

  • tensor1 – The numerator tensor.

  • tensor2 – The denominator tensor.

  • value – Multiplier for tensor1 / tensor2.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenAddcdiv (topsatenTensor &out, const topsatenTensor &input, const topsatenTensor &tensor1, const topsatenTensor &tensor2, const topsatenScalar_t &value={TOPSATEN_DATA_FP32, {.fval=1.0}}, topsStream_t stream=nullptr)

Addcdiv operator.

Out[i] = input[i] + value * (tensor1[i] / tensor2[i]).

Parameters
  • out – The output tensor.

  • input – The tensor to be added.

  • tensor1 – The numerator tensor.

  • tensor2 – The denominator tensor.

  • value – Multiplier for tensor1 / tensor2.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenAddcmul (topsatenTensor &out, const topsatenTensor &input, const topsatenTensor &tensor1, const topsatenTensor &tensor2, const topsatenScalar_t &value={TOPSATEN_DATA_FP32, {.fval=1.0}}, topsStream_t stream=nullptr)

Addcmul operator.

Out[i] = input[i] + value * (tensor1[i] * tensor2[i]).

Parameters
  • out – The output tensor.

  • input – The tensor to be added.

  • tensor1 – The numerator tensor.

  • tensor2 – The denominator tensor.

  • value – Multiplier for tensor1 * tensor2.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenConjPhysical (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

Computes the element-wise conjugate of the given input tensor. If input has a non-complex dtype, this function just returns input.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenAcos (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

Computes the inverse cosine of each element in input.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenArccos (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

Computes the inverse cosine of each element in input. Alias for topsatenAcos.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenAddRelu (topsatenTensor &output, const topsatenTensor &lhs, const topsatenTensor &rhs, const topsatenScalar_t &alpha={TOPSATEN_DATA_FP32, {.fval=1.0}}, topsStream_t stream=nullptr)

AddRelu(x, y) = alpha * max(x + y, 0).

Parameters
  • output – The output tensor.

  • lhs – The input tensor.

  • rhs – The input tensor.

  • alpha – Multiplier for max(x + y, 0).

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenAddRelu (topsatenTensor &output, const topsatenTensor &lhs, const topsatenScalar_t &rhs, const topsatenScalar_t &alpha={TOPSATEN_DATA_FP32, {.fval=1.0}}, topsStream_t stream=nullptr)

AddRelu(x, y) = alpha * max(x + y, 0).

Parameters
  • output – The output tensor.

  • lhs – The input tensor.

  • rhs – The input scalar.

  • alpha – Multiplier for max(x + y, 0).

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenAddmv (topsatenTensor &out, const topsatenTensor &input, const topsatenTensor &mat, const topsatenTensor &vec, const topsatenScalar_t &beta={TOPSATEN_DATA_FP32, {.fval=1.0}}, const topsatenScalar_t &alpha={TOPSATEN_DATA_FP32, {.fval=1.0}}, topsStream_t stream=nullptr)

Performs a matrix-vector product of the matrix mat and the vector vec. The vector input is added to the final result.

Parameters
  • output – The output tensor.

  • lhs – The input tensor.

  • rhs – The input scalar.

  • beta – Multiplier for input.

  • alpha – Multiplier for mat @ vec.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenAddr (topsatenTensor &out, const topsatenTensor &input, const topsatenTensor &mat, const topsatenTensor &vec, const topsatenScalar_t &beta={TOPSATEN_DATA_FP32, {.fval=1.0}}, const topsatenScalar_t &alpha={TOPSATEN_DATA_FP32, {.fval=1.0}}, topsStream_t stream=nullptr)

Performs a outer-product product of the matrix mat and the vector vec. The vector input is added to the final result.

Parameters
  • output – The output tensor.

  • lhs – The input tensor.

  • rhs – The input scalar.

  • beta – Multiplier for input.

  • alpha – Multiplier for mat ⊗ vec.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenIsAllTrue (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

This function returns True if all element in the input evaluate to True and False otherwise.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenIsAnyTrue (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

This function returns True if any element in the input evaluate to True and False otherwise.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenAllclose (bool &output, const topsatenTensor &input, const topsatenTensor &other, const double &rtol=1e-05, const double &atol=1e-08, const bool &equal_nan=false, topsStream_t stream=nullptr)

This function checks if input and other satisfy the condition: |input − other| ≤ atol + rtol × |other|.

Parameters
  • output – The output.

  • input – First tensor to compare.

  • other – Second tensor to compare.

  • rtol – Relative tolerance. Default: 1e-05.

  • atol – Absolute tolerance. Default: 1e-08.

  • equal_nan – If True, then two NaN s will be considered equal. Default: False.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenIsclose (topsatenTensor &output, const topsatenTensor &input, const topsatenTensor &other, const double &rtol=1e-05, const double &atol=1e-08, const bool &equal_nan=false, topsStream_t stream=nullptr)

This function checks if each element of input and other satisfy the condition: |input − other| ≤ atol + rtol × |other|.

Parameters
  • output – The output tensor.

  • input – First tensor to compare.

  • other – Second tensor to compare.

  • rtol – Relative tolerance. Default: 1e-05.

  • atol – Absolute tolerance. Default: 1e-08.

  • equal_nan – If True, then two NaN s will be considered equal. Default: False.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenEqual (bool &output, const topsatenTensor &input, const topsatenTensor &other, topsStream_t stream=nullptr)

True if two tensors have the same size and elements, False otherwise.

Parameters
  • output – The output.

  • input – First tensor to compare.

  • other – Second tensor to compare.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenSign (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

Returns a new tensor with the signs of the elements of input.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenIsfinite (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

Returns a new tensor with boolean elements representing if each element is finite or not.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenThreshold (topsatenTensor &output, const topsatenTensor &input, const topsatenScalar_t &threshold, const topsatenScalar_t &value, topsStream_t stream=nullptr)

Thresholds each element of the input Tensor.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • threshold – The value to threshold at.

  • value – The value to replace with.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenArgmin (topsatenTensor &output, const topsatenTensor &input, const topsatenScalar_t &dim={TOPSATEN_DATA_NONE, {}}, const bool &keepdim=false, topsStream_t stream=nullptr)

This function gets the relative indices of minimum value for the dimensions being reduced.

Parameters
  • output – The output tensor of indices.

  • input – The input tensor.

  • dim – The dimensions to reduce.

  • keepdim – Whether the output tensor has dim retained or not.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenIsNan (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

Returns a new tensor with boolean elements representing if each element of input is nan or not.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenIsInf (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

Returns a new tensor with boolean elements representing if each element of input is infinite or not.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenSin (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

This function returns a new tensor with the sine of the elements of input.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenCos (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

This function returns a new tensor with the cosine of the elements of input.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenCosh (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

This function returns a new tensor with the hyperbolic cosine of the elements of input.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenLog (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

This function returns a new tensor with the ln() of the elements of input.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenLog10 (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

Returns a new tensor with the logarithm to the base 10 of the elements of input.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenLog1p (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

Returns a new tensor with the natural logarithm of (1 + input).

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenLog2 (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

Returns a new tensor with the logarithm to the base 2 of the elements of input.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenLogSigmoid (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

Applies the Logsigmoid function element-wise.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenReciprocal (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

This function returns a new tensor with the reciprocal of the elements of input.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenIndexPut (topsatenTensor &self, const std::vector< topsatenTensor > &indices, const topsatenTensor &value, const bool accumulate, topsStream_t stream=nullptr)

This function performs the function that put values from the tensor values into the tensor self using the indices specified in indices.

Parameters
  • self – Index put input and result.

  • indices – Tensors array used to index into self.

  • value – Tensor of same dtype as self.

  • accumulate – If accumulate is True, the elements in values are added to self. If accumulate is False, the behavior is undefined if indices contain duplicate elements.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenIndexPutImpl (topsatenTensor &self, const std::vector< topsatenTensor > &indices, const topsatenTensor &value, const bool accumulate, const bool unsafe, topsStream_t stream=nullptr)

This function performs the function that put values from the tensor values into the tensor self using the indices specified in indices.

Parameters
  • self – Index put input and result.

  • indices – Tensors array used to index into self.

  • value – Tensor of same dtype as self.

  • accumulate – If accumulate is True, the elements in values are added to self. If accumulate is False, the behavior is undefined if indices contain duplicate elements.

  • unsafe – The unsafe parameter in the index_put_impl function determines whether to skip safety checks during the indexing assignment operation, improving performance when set to True but potentially risking unsafe behavior.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenIndexPut (topsatenTensor &self, const std::vector< topsatenTensor > &indices, const topsatenScalar_t &value, const bool accumulate, topsStream_t stream=nullptr)

This function performs the function that put values from the tensor values into the tensor self using the indices specified in indices.

Parameters
  • self – Index put input and result.

  • indices – Tensors array used to index into self.

  • value – Scalar value.

  • accumulate – If accumulate is True, the elements in values are added to self. If accumulate is False, the behavior is undefined if indices contain duplicate elements.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenIndexPutImpl (topsatenTensor &self, const std::vector< topsatenTensor > &indices, const topsatenScalar_t &value, const bool accumulate, const bool unsafe, topsStream_t stream=nullptr)

This function performs the function that put values from the tensor values into the tensor self using the indices specified in indices.

Parameters
  • self – Index put input and result.

  • indices – Tensors array used to index into self.

  • value – Scalar value.

  • accumulate – If accumulate is True, the elements in values are added to self. If accumulate is False, the behavior is undefined if indices contain duplicate elements.

  • unsafe – When set to true, typically indicates that the function may bypass certain safety checks or validations.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenIndexPut (topsatenTensor &output, const topsatenTensor &input, const std::vector< topsatenTensor > &indices, const topsatenTensor &value, const bool accumulate, topsStream_t stream=nullptr)

This function performs the function that put values from the tensor values into the tensor self using the indices specified in indices.

Parameters
  • output – Index put result.

  • input – Index put input.

  • indices – Tensors array used to index into self.

  • value – Tensor of same dtype as self.

  • accumulate – If accumulate is True, the elements in values are added to self. If accumulate is False, the behavior is undefined if indices contain duplicate elements.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenIndexPutImpl (topsatenTensor &output, const topsatenTensor &input, const std::vector< topsatenTensor > &indices, const topsatenTensor &value, const bool accumulate, const bool unsafe, topsStream_t stream=nullptr)

This function performs the function that put values from the tensor values into the tensor self using the indices specified in indices.

Parameters
  • output – Index put result.

  • input – Index put input.

  • indices – Tensors array used to index into self.

  • value – Tensor of same dtype as self.

  • accumulate – If accumulate is True, the elements in values are added to self. If accumulate is False, the behavior is undefined if indices contain duplicate elements.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenIndexPut (topsatenTensor &output, const topsatenTensor &input, const std::vector< topsatenTensor > &indices, const topsatenScalar_t &value, const bool accumulate, topsStream_t stream=nullptr)

This function performs the function that put values from the tensor values into the tensor self using the indices specified in indices.

Parameters
  • output – Index put result.

  • input – Index put input.

  • indices – Tensors array used to index into self.

  • value – Scalar value.

  • accumulate – If accumulate is True, the elements in values are added to self. If accumulate is False, the behavior is undefined if indices contain duplicate elements.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenIndexPutImpl (topsatenTensor &output, const topsatenTensor &input, const std::vector< topsatenTensor > &indices, const topsatenScalar_t &value, const bool accumulate, const bool unsafe, topsStream_t stream=nullptr)

This function performs the function that put values from the tensor values into the tensor self using the indices specified in indices.

Parameters
  • output – Index put result.

  • input – Index put input.

  • indices – Tensors array used to index into self.

  • value – Scalar value.

  • accumulate – If accumulate is True, the elements in values are added to self. If accumulate is False, the behavior is undefined if indices contain duplicate elements.

  • unsafe – When set to true, typically indicates that the function may bypass certain safety checks or validations.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenLayerNorm (topsatenTensor &output, const topsatenTensor &input, const topsatenSize_t &normalized_shape, const topsatenTensor &weight, const topsatenTensor &bias, const topsatenScalar_t &epsilon, topsStream_t stream=nullptr)

This function performs the forward layer normalization.

Parameters
  • output – Normalized tensor.

  • input – Tensor to be normalized.

  • normalized_shape – The shape of the normalization dimension.

  • weight – Weight tensor.

  • bias – Bias tensor.

  • epsilon – The epsilon value to use to avoid division by zero.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenNativeLayerNorm (topsatenTensor &output, topsatenTensor &mean, topsatenTensor &rstd, const topsatenTensor &input, const topsatenSize_t &normalized_shape, const topsatenTensor &weight, const topsatenTensor &bias, const topsatenScalar_t &epsilon, topsStream_t stream=nullptr)

This function performs the forward layer normalization.

Parameters
  • output – Normalized tensor.

  • mean – Mean of input along dimensions [axis,…,r-1].

  • rstd – Reciprocal of standard deviation of input along dimensions [axis,…,r-1].

  • input – Tensor to be normalized.

  • normalized_shape – The shape of the normalization dimension.

  • weight – Weight tensor.

  • bias – Bias tensor.

  • epsilon – The epsilon value to use to avoid division by zero.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGroupNorm (topsatenTensor &output, const topsatenTensor &input, const int64_t group, const topsatenTensor &weight, const topsatenTensor &bias, const double eps=1e-05, topsStream_t stream=nullptr)

This function performs the forward group normalization.

Parameters
  • output – Normalized tensor.

  • input – Tensor to be normalized.

  • group – Number of groups to separate the channels into.

  • weight – Weight tensor.

  • bias – Bias tensor.

  • eps – A value added to the denominator for numerical stability.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenNativeGroupNorm (topsatenTensor &output, topsatenTensor &mean, topsatenTensor &rstd, const topsatenTensor &input, const topsatenTensor &weight, const topsatenTensor &bias, const int64_t N, const int64_t C, const int64_t HxW, const int64_t group, const double eps, topsStream_t stream=nullptr)

This function performs the forward native group normalization.

Parameters
  • output – Normalized tensor.

  • mean – Mean of input computed separately over each group.

  • rstd – Reciprocal of standard deviation of input computed separately over each group.

  • input – Tensor to be normalized.

  • weight – Weight tensor.

  • bias – Bias tensor.

  • N – Number of batchs expected in input.

  • C – Number of channels expected in input.

  • HxW – Product of other dimensions except N/C in input.

  • group – Number of groups to separate the channels into.

  • eps – A value added to the denominator for numerical stability.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenNativeBatchNorm (topsatenTensor &output, topsatenTensor &save_mean, topsatenTensor &save_var, const topsatenTensor &input, const topsatenTensor &weight, const topsatenTensor &bias, topsatenTensor &running_mean, topsatenTensor &running_var, const bool training, const double momentum, const double eps, topsStream_t stream=nullptr)

This function performs the forward batch normalization.

Parameters
  • output – Normalized tensor.

  • save_mean – Save mean tensor.

  • save_var – Save var tensor.

  • input – Tensor to be normalized.

  • weight – An optional parameter used to scale the normalized tensor.

  • bias – An optional parameter used to shift the normalized tensor.

  • running_mean – An optional parameter used to specify the running mean used for normalization.

  • running_var – An optional parameter used to specify the running variance used for normalization.

  • training – Is training or not.

  • momentum – An parameter specifying the momentum for the running mean and variance.

  • eps – A value added to the denominator for numerical stability.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenInstanceNorm (topsatenTensor &output, const topsatenTensor &input, const topsatenTensor &weight, const topsatenTensor &bias, topsatenTensor &running_mean, topsatenTensor &running_var, const bool use_input_stats, const double momentum, const double eps, topsStream_t stream=nullptr)

This function performs the forward instance normalization.

Parameters
  • output – Normalized tensor.

  • input – Tensor to be normalized.

  • weight – An optional parameter used to scale the normalized tensor.

  • bias – An optional parameter used to shift the normalized tensor.

  • running_mean – An optional parameter used to specify the running mean used for normalization.

  • running_var – An optional parameter used to specify the running variance used for normalization.

  • use_input_stats – Is use_input_stats or not.

  • momentum – An parameter specifying the momentum for the running mean and variance.

  • eps – A value added to the denominator for numerical stability.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenWeightNormInterface (topsatenTensor &w, topsatenTensor &norm, const topsatenTensor &v, const topsatenTensor &g, int dim, topsStream_t stream=nullptr)

This function performs the forward weight normalization.

Parameters
  • w – Normalized magnitude.

  • norm – Normalized direction.

  • v – Parameters specify the magnitude.

  • g – Parameters specify the direction.

  • dim – Dimension over which to compute the norm.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenLinalgVectorNorm (topsatenTensor &output, const topsatenTensor &input, const topsatenScalar_t &ord, const topsatenSize_t &reduce_dim, const bool keepdim=false, const topsatenDataType_t &dtype=TOPSATEN_DATA_NONE, topsStream_t stream=nullptr)

This function computes a vector norm.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • ord – The order of vector norm.

  • reduce_dim – The dimension or dimensions to reduce. None is equivalent to input_dims.

  • keepdim – Whether the output tensor has dim retained or not.

  • dtype – The data type of the output tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenForeachNorm (std::vector< topsatenTensor > &output, const std::vector< topsatenTensor > &input, const topsatenScalar_t &ord, topsStream_t stream=nullptr)

This function computes a norm list.

Parameters
  • output – The output tensor list.

  • input – The input tensor list.

  • ord – The order of norm.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenRoll (topsatenTensor &output, const topsatenTensor &input, const topsatenSize_t &shifts, const topsatenSize_t &dims, topsStream_t stream=nullptr)

The function is used to perform a circular shift of a tensor along a specified dimension. It can roll the elements of the tensor forward or backward along the specified dimension, and elements beyond the boundary will be moved to the other side.

Parameters
  • output – The output tensor.

  • inputs – The input tensors.

  • shifts – The number of positions to scroll. Can be a positive number (scrolling left) or a negative number (scrolling right).

  • dims – The dimension to scroll. The default is None, which means scrolling through all dimensions.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenSort (topsatenTensor &sorted, topsatenTensor &indices, const topsatenTensor &input, bool stable, int64_t dim, bool descending, topsStream_t stream=nullptr)

This function returns sorted tensor of input tensor and corresponding indices.

Parameters
  • sorted – The output sorted tensor.

  • indices – The output indices tensor.

  • input – The input tensor.

  • stable – If True, the sorting algorithm will be stable.

  • dim – The dimension to sort along.

  • descending – Controls the sorting order (ascending or descending).

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenArgSort (topsatenTensor &indices, const topsatenTensor &input, bool stable, int64_t dim, bool descending, topsStream_t stream=nullptr)

This function returns the indices of the elements that are sorted.

Parameters
  • indices – The output indices tensor.

  • input – The input tensor.

  • stable – If True, the sorting algorithm will be stable.

  • dim – The dimension to sort along.

  • descending – Controls the sorting order (ascending or descending).

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGather (topsatenTensor &output, const topsatenTensor &input, int64_t dim, const topsatenTensor &index, bool sparse_grad, topsStream_t stream=nullptr)

This function performs the gather function.

Parameters
  • output – Gather result.

  • input – The source tensor.

  • dim – The axis along which to index.

  • index – The indices of elements to gather.

  • sparse_grad – If True, gradient w.r.t. input will be a sparse tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGather (topsatenTensor &output, const topsatenTensor &input, const topsatenTensor &index, int64_t dim, bool sparse_grad, topsStream_t stream=nullptr)

This function performs the gather function.

Parameters
  • output – Gather result.

  • input – The source tensor.

  • index – The indices of elements to gather.

  • dim – The axis along which to index.

  • sparse_grad – If True, gradient w.r.t. input will be a sparse tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenEinSum (topsatenTensor &output, const char *equation, const std::vector< topsatenTensor > &inputs, topsatenSize_t &path, topsStream_t stream=nullptr)

This function computes Einstein summation convention on the inputs.

Parameters
  • output – The output tensor.

  • inputs – The input tensors.

  • equation – The syntax to be computed.

  • path – Parameter that specifies a contraction path.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenPad (topsatenTensor &output, const topsatenTensor &input, const topsatenSize_t &pads, const topsatenPadMode_t &mode, const topsatenScalar_t &value, topsStream_t stream=nullptr)

This function performs the pad function.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • pads – M-elements tuple, where m/2 <= input dimensions and m is even.

  • modeconstant, reflect, replicate or circular. Default: constant.

  • value – A scalar value to be used if the mode chosen is constant (by default it is 0).

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenReflectionPad1d (topsatenTensor &output, const topsatenTensor &input, const topsatenSize_t &pads, topsStream_t stream=nullptr)

This function performs the reflect pad function.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • pads – M-elements tuple, where m/2 <= input dimensions and m is even.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenReflectionPad2d (topsatenTensor &output, const topsatenTensor &input, const topsatenSize_t &pads, topsStream_t stream=nullptr)

This function performs the reflect pad function.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • pads – M-elements tuple, where m/2 <= input dimensions and m is even.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenReflectionPad3d (topsatenTensor &output, const topsatenTensor &input, const topsatenSize_t &pads, topsStream_t stream=nullptr)

This function performs the reflect pad function.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • pads – M-elements tuple, where m/2 <= input dimensions and m is even.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenUpsampleNearest2d (topsatenTensor &output, const topsatenTensor &input, const topsatenSize_t &output_size, const topsatenScalar_t &scales_h, const topsatenScalar_t &scales_w, topsStream_t stream=nullptr)

This function performs the upsample nearest2d function.

Parameters
  • out – The output tensor.

  • input – The source tensor.

  • scales_h – The topsatenScalar_t of scales_h.

  • scales_w – The topsatenScalar_t of scales_w.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenUpsampleNearest3d (topsatenTensor &output, const topsatenTensor &input, const topsatenSize_t &output_size, const topsatenScalar_t &scales_d, const topsatenScalar_t &scales_h, const topsatenScalar_t &scales_w, topsStream_t stream=nullptr)

This function performs the upsample nearest3d function.

Parameters
  • output – The output tensor.

  • input – The source tensor.

  • output_size – The size of the output tensor.

  • scales_d – The topsatenScalar_t of scales_d.

  • scales_h – The topsatenScalar_t of scales_h.

  • scales_w – The topsatenScalar_t of scales_w.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenDenseDim (int &dim, const topsatenTensor &self, topsStream_t stream=nullptr)

This function return the number of dense dimensions in a sparse tensor ‘self’. For a normal tensor, this function simply returns the rank of the tensor.

Parameters
  • dim – The output result.

  • self – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenSparseDim (int &dim, const topsatenTensor &self, topsStream_t stream=nullptr)

This function return the number of sparse dimensions in a sparse tensor ‘self’. For a normal tensor, this function simply returns 0.

Parameters
  • dim – The output result.

  • self – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenVar (topsatenTensor &output, const topsatenTensor &input, const topsatenSize_t &dim, const topsatenScalar_t &correction, bool keepdim, topsStream_t stream=nullptr)

This function return the variance over the dimensions specified by dim.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • dim – The dimension or dimensions to reduce.

  • correction – Difference between the sample size and sample degrees of freedom.

  • keepdim – Whether the output tensor has dim retained or not.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenTriu (topsatenTensor &result, const topsatenTensor &self, int64_t k, topsStream_t stream=nullptr)

This function returns the upper triangular part of a matrix (2-D tensor) or batch of matrices input, the other elements of the result tensor out are set to 0.

Parameters
  • result – The output tensor.

  • self – The input tensor.

  • k – The diagonal to consider.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenReshapeAlias (topsatenTensor &output, const topsatenTensor &input, const topsatenSize_t &size, const topsatenSize_t &strides, topsStream_t stream=nullptr)

This function is meant to be used in the implementation of reshape.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • size – The size of output tensor.

  • strides – Strides to use if operation can be just a view.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenTril (topsatenTensor &result, const topsatenTensor &self, int64_t k, topsStream_t stream=nullptr)

This function returns the lower triangular part of the matrix (2-D tensor) or batch of matrices input, the other elements of the result tensor out are set to 0.

Parameters
  • result – The output tensor.

  • self – The input tensor.

  • k – The diagonal to consider.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenDiag (topsatenTensor &output, const topsatenTensor &input, int64_t diagonal, topsStream_t stream=nullptr)

This function returnsthen returns a 2-D square tensor. with the elements of input as the diagonal.

Parameters
  • result – The output tensor.

  • self – The input tensor.

  • diagonal – The diagonal to consider.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenUpsampleBilinear2d (topsatenTensor &output, const topsatenTensor &input, const topsatenSize_t &size, bool align_corners, const topsatenScalar_t &scale_h, const topsatenScalar_t &scale_w, topsStream_t stream=nullptr)

This function performs 2D bilinear upsampling on a multi-channel input signal. You can define the scale using either the output size (h, w) or a scaling factor (scale_factor).

Parameters
  • output – The out tensor.

  • input – The input tensor.

  • size – Output spatial sizes.

  • align_corners – If True, the corner pixels of the input and output tensors are aligned.

  • scale_h – Multiplier for spatial size.

  • scale_w – Multiplier for spatial size.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenUpsampleBicubic2d (topsatenTensor &output, const topsatenTensor &input, const topsatenSize_t &size, bool align_corners, const topsatenScalar_t &scale_h, const topsatenScalar_t &scale_w, topsStream_t stream=nullptr)

This function performs 2D bicubic upsampling on a multi-channel input signal. You can define the scale using either the output size (h, w) or a scaling factor (scale_factor).

Parameters
  • output – The out tensor.

  • input – The input tensor.

  • size – Output spatial sizes.

  • align_corners – If True, the corner pixels of the input and output tensors are aligned.

  • scale_h – Multiplier for spatial size.

  • scale_w – Multiplier for spatial size.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenPolar (topsatenTensor &result, const topsatenTensor &abs, const topsatenTensor &angle, topsStream_t stream=nullptr)

This function constructs a complex tensor whose elements are Cartesian coordinates corresponding to the polar coordinates with absolute value and angle.

Parameters
  • result – The output tensor.

  • abs – The input tensor containing absolute values.

  • angle – The input tensor containing angle values.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenAmpUpdateScale (topsatenTensor &output, const topsatenTensor &input, topsatenTensor &growth_tracker, const topsatenTensor &found_inf, double scale_growth_factor, double scale_backoff_factor, int64_t growth_interval, topsStream_t stream=nullptr)

This function computes the output based on the input tensor.

Parameters
  • output – The output tensor.

  • input – A one-element float tensor containing the scale value.

  • growth_tracker – A one-element int tensor containing the number of recent consecutive unskipped steps.

  • found_inf – A one-element float tensor. If > 0, indicates infs/nans and 0 if no infs/nans were found.

  • scale_growth_factor – Multiplier if no infs/NaNs were found.

  • scale_backoff_factor – Multiplier if infs/NaNs were found.

  • growth_interval – Number of consecutive unskipped steps that must occur for current_scale to be multiplied by growth_factor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenSquare (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

This function returns a new tensor with the square of the elements of input.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenMeshgrid (std::vector< topsatenTensor > &output, const std::vector< topsatenTensor > &input, const char *index="ij", topsStream_t stream=nullptr)

This function create the grids of coordinate specified by input.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • index – Mode to be specify, default - ‘ij’.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenLocalScalarDense (topsatenScalar_t &result, const topsatenTensor &self, topsStream_t stream=nullptr)

The operator returns the first element from the input tensor.

Parameters
  • result – The scalar output.

  • self – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenDiagEmbed (topsatenTensor &output, const topsatenTensor &input, int64_t offset, int64_t dim1, int64_t dim2, topsStream_t stream=nullptr)

This function returns a tensor whose diagonals of certain 2D planes are filled by input tensor.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • offset – The offset scalar.

  • dim1 – The dim1 scalar.

  • dim2 – The dim2 scalar.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenDiagonal (topsatenTensor &output, const topsatenTensor &input, int64_t offset, int64_t dim1, int64_t dim2, topsStream_t stream=nullptr)

This function return the partial view of diagonal elements of the given tensor with respect to dim1 and dim2.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • offset – The offset scalar.

  • dim1 – The dim1 scalar.

  • dim2 – The dim2 scalar.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenEye (topsatenTensor &output, const int32_t n, topsStream_t stream=nullptr)

Returns a 2-D tensor with ones on the diagonal and zeros elsewhere.

Parameters
  • output – The output tensor.

  • n – The number of rows.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenEye (topsatenTensor &output, const int32_t n, const int32_t m, topsStream_t stream=nullptr)

Returns a 2-D tensor with ones on the diagonal and zeros elsewhere.

Parameters
  • output – The output tensor.

  • n – The number of rows.

  • m – The number of columns, default is n.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenLinalgCheckErrors (const topsatenTensor &info, const char *api_name, bool is_matrix, topsStream_t stream=nullptr)

This function throws an error based on the info tensor and API name for Linear Algebra Ops.

Parameters
  • info – The input tensor.

  • api_name – Specify the api name.

  • is_matrix – Set true if input is matrix.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenLinalgSolveEx_ (topsatenTensor &output, topsatenTensor &LU, topsatenTensor &pivots, topsatenTensor &info, const topsatenTensor &lhs, const topsatenTensor &rhs, bool left, bool check_errors, topsStream_t stream=nullptr)

A version of linalg solve() : Computes the solution of a square system of linear equations with a unique solution, that does not perform error checks unless check_errors=True. Return tensors of result, LU, pivots, info.

Parameters
  • output – The output tuple of tensors.

  • LU – The LU tensor.

  • pivots – The pivots tensor.

  • info – The info tensor.

  • lhs – The lhs tensor, tensor of shape (*, n, n) where * is zero or more batch dimensions.

  • rhs – The right-hand side tensor of shape (*, n) or (*, n, k) or (n,) or (n, k) according to the rules described above.

  • left – Whether to solve the system AX=B or XA=B. Default: True.

  • check_errors – Controls whether to check the content of infos and raise an error if it is non-zero. Default: False.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenLinalgSolveEx (topsatenTensor &output, topsatenTensor &info, const topsatenTensor &lhs, const topsatenTensor &rhs, bool left, bool check_errors, topsStream_t stream=nullptr)

A version of linalg solve() : Computes the solution of a square system of linear equations with a unique solution, that does not perform error checks unless check_errors=True. Returns - result, info.

Parameters
  • output – The output tuple of tensors.

  • info – The info tensor.

  • lhs – The lhs tensor, tensor of shape (*, n, n) where * is zero or more batch dimensions.

  • rhs – The right-hand side tensor of shape (*, n) or (*, n, k) or (n,) or (n, k) according to the rules described above.

  • left – Whether to solve the system AX=B or XA=B. Default: True.

  • check_errors – Controls whether to check the content of infos and raise an error if it is non-zero. Default: False.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenLinalgSolve (topsatenTensor &output, const topsatenTensor &lhs, const topsatenTensor &rhs, bool left, topsStream_t stream=nullptr)

Computes the solution of a square system of linear equations with a unique solution.

Parameters
  • output – The output tensor.

  • lhs – The input tensor, tensor of shape (*, n, n) where * is zero or more batch dimensions.

  • rhs – The right-hand side tensor of shape (*, n) or (*, n, k) or (n,) or (n, k) according to the rules described above.

  • left – Whether to solve the system AX=B or XA=B. Default: True.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenConstant_Pad_Nd (topsatenTensor &output, const topsatenTensor &input, const topsatenSize_t &pad, const topsatenScalar_t &value, topsStream_t stream=nullptr)

Pads the input tensor boundaries with a constant value.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • pad – M-elements tuple.

  • value – Fill value for padding, Default is 0.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenLinalgLuFactorEx (topsatenTensor &LU, topsatenTensor &pivots, topsatenTensor &info, const topsatenTensor &input, bool pivot, bool check_errors, topsStream_t stream=nullptr)

A version of linalg () : Computes the solution of a square system of linear equations with a unique solution, that does not perform error checks unless check_errors=True. Return tensors of result, LU, pivots, info.

Parameters
  • LU – The LU tensor.

  • pivots – The pivots tensor.

  • info – The info tensor.

  • lhs – The lhs tensor, tensor of shape (*, n, n) where * is zero or more batch dimensions.

  • pivot – Whether to solve the system AX=B or XA=B. Default: True.

  • check_errors – Controls whether to check the content of infos and raise an error if it is non-zero. Default: False.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenCholesky (topsatenTensor &output, const topsatenTensor &input, bool upper, topsStream_t stream=nullptr)

Computes the Cholesky decomposition of a symmetric positive-definite matrix A or for batches of symmetric positive-definite matrices.

Parameters
  • input – The input tensor A of size (bs, n, n) where * is zero or more batch dimensions consisting of symmetric positive-definite matrices.

  • output – The output tensor.

  • upper – Bool, optional, flag that indicates whether to return a upper or lower triangular matrix. Default: False.

  • check_errors – Controls whether to check the content of infos and raise an error if it is non-zero. Default: False.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenLinalgLuSolve (topsatenTensor &output, topsatenTensor &LU, topsatenTensor &pivots, topsatenTensor &B, bool left, bool adjoint, topsStream_t stream=nullptr)

A version of linalg solve() : Computes the solution of a square system of linear equations with a unique solution, that does not perform error checks unless check_errors=True. Return tensors of result, LU, pivots, info.

Parameters
  • output – The output tuple of tensors.

  • LU – The LU tensor.

  • pivots – The pivots tensor.

  • B – The right-hand side tensor of shape (*, n) or (*, n, k) or (n,) or (n, k) according to the rules described above.

  • left – Whether to solve the system AX=B or XA=B. Default: True.

  • check_errors – Controls whether to check the content of infos and raise an error if it is non-zero. Default: False.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenAffineGridGenerator (topsatenTensor &output, const topsatenTensor &theta, const topsatenSize_t &size, bool align_corners, topsStream_t stream=nullptr)

Generates a 2D or 3D flow field (sampling grid), given a batch of affine matrices theta.

Parameters
  • output – The output tensor.

  • theta – The theta tensor.

  • size – The size of output tensor.

  • align_corners – If True, consider -1 and 1 to refer to the centers of the corner pixels rather than the image corners. Default: False.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenMaxPool2d (topsatenTensor &output, const topsatenTensor &input, const topsatenSize_t &kernel_size, const topsatenSize_t &stride, const topsatenSize_t &padding, const topsatenSize_t &dilation, bool ceil_mode, topsStream_t stream=nullptr)
Parameters
  • output – : The output tensor.

  • input – : The input tensor.

  • kernel_size – : size of the pooling region. Can be a single number or a tuple (kH, kW).

  • stride – : stride of the pooling operation. Can be a single number or a tuple (sH, sW).

  • padding – : Implicit negative infinity padding to be added on both sides, must be >= 0 and <= kernel_size / 2.

  • dilation – : The stride between elements within a sliding window, must be > 0.

  • ceil_mode – : If True, will use ceil instead of floor to compute the output shape.

  • stream – : tops stream.

Returns

topsatenStatus_t

topsatenStatus_t TOPSATEN_EXPORT topsatenMaxPool2dIndices (topsatenTensor &output, topsatenTensor &indices, const topsatenTensor &input, const topsatenSize_t &kernel_size, const topsatenSize_t &stride, const topsatenSize_t &padding, const topsatenSize_t &dilation, bool ceil_mode, topsStream_t stream=nullptr)

Applies a 2D max pooling over an input with several input planes.

Parameters
  • output – The output tensor.

  • indices – The tensor to store indices.

  • input – The input tensor.

  • kernel_size – Size of the pooling region. Can be a single number or a tuple (kH, kW).

  • stride – Stride of the pooling operation. Can be a single number or a tuple (sH, sW).

  • padding – Implicit negative infinity padding to be added on both sides, must be >= 0 and <= kernel_size / 2.

  • dilation – The stride between elements within a sliding window, must be > 0.

  • ceil_mode – If True, will use ceil instead of floor to compute the output shape.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenAvgPool2d (topsatenTensor &output, const topsatenTensor &input, const topsatenSize_t &kernel_size, const topsatenSize_t &stride, const topsatenSize_t &padding, bool ceil_mode, bool count_include_pad, const topsatenScalar_t &divisor_override, topsStream_t stream=nullptr)
Parameters
  • output – : The output tensor.

  • input – : The input tensor.

  • kernel_size – : size of the pooling region. Can be a single number or a tuple (kH, kW).

  • stride – : stride of the pooling operation. Can be a single number or a tuple (sH, sW).

  • padding – : Implicit negative infinity padding to be added on both sides, must be >= 0 and <= kernel_size / 2.

  • ceil_mode – : If True, will use ceil instead of floor to compute the output shape.

  • count_include_pad – : when True, will include the zero-padding in the averaging calculation.

  • divisor_override – : optional(int) if specified, it will be used as divisor, otherwise size of the pooling region will be used.

  • stream – : tops stream.

Returns

topsatenStatus_t

topsatenStatus_t TOPSATEN_EXPORT topsatenUnique2 (topsatenTensor &output, topsatenTensor &indices, topsatenTensor &counts, const topsatenTensor &input, bool sorted, bool return_inverse, bool return_counts, topsStream_t stream=nullptr)

Returns unique elements from the input tensor along with optional additional information.

Parameters
  • output – The output tensor with unique elements.

  • indices – If return_indices is true, it will contain indexes to map elements in the original input to the output. Same shape as input.

  • counts – The number of occurrences for each unique value. Same shape as output.

  • input – The input tensor.

  • sorted – If true, the unique elements are returned in sorted order.

  • return_inverse – If true, returns the indices of the unique elements in the original tensor.

  • return_counts – If true, returns the counts of each unique element.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenBlackmanWindow (topsatenTensor &output, int64_t window_length, topsStream_t stream=nullptr)

Returns a 1-D blackman window of same length as input window_length parameter.

Parameters
  • output – The output tensor.

  • window_length – The window length.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenBlackmanWindow (topsatenTensor &output, int64_t window_length, bool periodic, topsStream_t stream=nullptr)

Returns a 1-D blackman window of same length as input window_length parameter.

Parameters
  • output – The output tensor.

  • window_length – The window length.

  • periodic – The boolean parameter for periodic.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenFrac (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

Returns a new tensor with fractional portion of each element in input.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenNanToNum (topsatenTensor &output, const topsatenTensor &input, double nan, double posinf, double neginf, topsStream_t stream=nullptr)

Replaces nan, posinf and neginf in the input with the values specified by nan, posinf and neginf.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • nan – The replacement for nan.

  • posinf – The replacement for positive infinity.

  • neginf – The replacement for negative infinity.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenNanToNum (topsatenTensor &output, const topsatenTensor &input, topsatenScalar_t nan, topsatenScalar_t posinf, topsatenScalar_t neginf, topsStream_t stream=nullptr)

Replaces nan, posinf and neginf in the input with the values specified by nan, posinf and neginf.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • nan – The replacement for nan.

  • posinf – The replacement for positive infinity.

  • neginf – The replacement for negative infinity.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenErf (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

This function returns a new tensor with the erf of the elements of input.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenBinaryCrossEntropy (topsatenTensor &output, const topsatenTensor &inputs, const topsatenTensor &targets, const topsatenTensor &weights, const int64_t reduction, topsStream_t stream=nullptr)

This function computes the binary cross entropy.

Parameters
  • output – The output tensor.

  • inputs – The input tensors.

  • targets – The target tensors.

  • weight – Optional weight tensors.

  • reduction – Parameter to specify which reduction operation should be performed.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenSgn (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

It computes a new tensor whose elements have the same angles as the corresponding elements of input and absolute values (i.e. magnitudes) of one for complex tensors.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenHammingWindow (topsatenTensor &out, int64_t window_length, bool periodic, double alpha, double beta, topsStream_t stream=nullptr)

The Hamming window is a mathematical function used in signal processing.

Parameters
  • out – The output tensor.

  • window_length – The size of returned window.

  • periodic – If True, returns a window to be used as periodic function. If False, return a symmetric window.

  • alpha – The coefficient alpha in the equation above.

  • beta – The coefficient beta in the equation above.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenHammingWindow (topsatenTensor &out, int64_t window_length, topsStream_t stream=nullptr)

The Hamming window is a mathematical function used in signal processing.

Parameters
  • out – The output tensor.

  • window_length – The size of returned window.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenHammingWindow (topsatenTensor &out, int64_t window_length, bool periodic, topsStream_t stream=nullptr)

The Hamming window is a mathematical function used in signal processing.

Parameters
  • out – The output tensor.

  • window_length – The size of returned window.

  • periodic – If True, returns a window to be used as periodic function. If False, return a symmetric window.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenHammingWindow (topsatenTensor &out, int64_t window_length, bool periodic, double alpha, topsStream_t stream=nullptr)

The Hamming window is a mathematical function used in signal processing.

Parameters
  • out – The output tensor.

  • window_length – The size of returned window.

  • periodic – If True, returns a window to be used as periodic function. If False, return a symmetric window.

  • alpha – The coefficient alpha in the equation above.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenHingeEmbeddingLoss (topsatenTensor &output, const topsatenTensor &input, const topsatenTensor &target, double margin, int64_t reduction, topsStream_t stream=nullptr)

This function computes the hinge embedding loss between input and target.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • target – The target that this loss expects.

  • reduction – Specifies the reduction to apply to the output: ‘none’ | ‘mean’ | ‘sum’. ‘none’: no reduction will be applied, ‘mean’: the weighted mean of the output is taken, ‘sum’: the output will be summed.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenHannWindow (topsatenTensor &output, int64_t window_length, topsStream_t stream=nullptr)

Returns a 1-D Hann window of same length as input window_length parameter.

Parameters
  • output – The output tensor.

  • window_length – The window length.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenHannWindow (topsatenTensor &output, int64_t window_length, bool periodic, topsStream_t stream=nullptr)

Returns a 1-D Hann window of same length as input window_length parameter.

Parameters
  • output – The output tensor.

  • window_length – The window length.

  • periodic – The boolean parameter for periodic.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenBinaryCrossEntropyWithLogits (topsatenTensor &output, const topsatenTensor &inputs, const topsatenTensor &targets, const topsatenTensor &weights, const topsatenTensor &pos_weights, const int64_t reduction, topsStream_t stream=nullptr)

This function computes the binary cross entropy with logits loss.

Parameters
  • inputs – The input tensors.

  • targets – The target tensors.

  • weight – Optional weight tensors.

  • pos_weight – Optional pos_weight tensors.

  • reduction – Parameter to specify which reduction operation should be performed.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGcd (topsatenTensor &output, const topsatenTensor &lhs, const topsatenTensor &rhs, topsStream_t stream=nullptr)

Returns a new tensor with gcd of the two input tensor elements.

Parameters
  • out – The output tensor.

  • lhs – The lhs tensor.

  • rhs – The rhs tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenLcm (topsatenTensor &output, const topsatenTensor &lhs, const topsatenTensor &rhs, topsStream_t stream=nullptr)

Returns a new tensor with lcm of the two input tensor elements.

Parameters
  • out – The output tensor.

  • lhs – The lhs tensor.

  • rhs – The rhs tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenMarginRankingLoss (topsatenTensor &output, const topsatenTensor &input1, const topsatenTensor &input2, const topsatenTensor &target, double margin, int64_t reduction, topsStream_t stream=nullptr)

This function computes the loss based on relative distances between pairs of inputs and target.

Parameters
  • output – The output tensor.

  • input1 – The input1 tensor.

  • input2 – The input2 tensor.

  • target – The target tesnsor (containing 1 or -1).

  • margin – A double value. Specifies the minimum difference needed for the loss.

  • reduction – Specifies the reduction to apply to the output: ‘none’ | ‘mean’ | ‘sum’. ‘none’: no reduction will be applied, ‘mean’: the mean of the output is taken, ‘sum’: the output will be summed.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenKaiserWindow (topsatenTensor &out, int64_t window_length, bool periodic, double beta, topsStream_t stream=nullptr)

The Kaiser window is a mathematical function used in digital signal processing.

Parameters
  • out – The output tensor.

  • window_length – The size of returned window.

  • periodic – If True, returns a window to be used as periodic function. If False, return a symmetric window.

  • beta – The coefficient β in the equation above.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenKaiserWindow (topsatenTensor &out, int64_t window_length, topsStream_t stream=nullptr)

The Kaisar window is a mathematical function used in digital signal processing.

Parameters
  • out – The output tensor.

  • window_length – The size of returned window.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenKaiserWindow (topsatenTensor &out, int64_t window_length, bool periodic, topsStream_t stream=nullptr)

The Kaiser window is a mathematical function used in digital signal processing.

Parameters
  • out – The output tensor.

  • window_length – The size of returned window.

  • periodic – If True, returns a window to be used as periodic function. If False, return a symmetric window.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenAngle (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

Returns a new tensor with the element-wise angle (in radians) of the given input tensor.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenCov (topsatenTensor &output, const topsatenTensor &input, int64_t correction, const topsatenTensor &fweight, const topsatenTensor &aweight, topsStream_t stream=nullptr)

This function calculates covariance tensor of the variables given by the input tensor.

Parameters
  • output – The covariance tensor of the variables.

  • input – A 2D tensor matrix containing multiple variables and observations, or 1D tensor representing a single variable.

  • correction – Correction value.

  • fweights – Fweights tensor.

  • aweights – Aweights tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenBartlettWindow (topsatenTensor &output, int64_t window_length, topsStream_t stream=nullptr)

Returns a 1-D bartlett window of same length as input window_length parameter.

Parameters
  • output – The output tensor.

  • window_length – The window length.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenBartlettWindow (topsatenTensor &output, int64_t window_length, bool periodic, topsStream_t stream=nullptr)

Returns a 1-D bartlett window of same length as input window_length parameter.

Parameters
  • output – The output tensor.

  • window_length – The window length.

  • periodic – The boolean parameter for periodic.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenCosineEmbeddingLoss (topsatenTensor &output, const topsatenTensor &input1, const topsatenTensor &input2, const topsatenTensor &target, double margin, int64_t reduction, topsStream_t stream=nullptr)
topsatenStatus_t TOPSATEN_EXPORT topsatenSplit (std::vector< topsatenTensor > &out, const topsatenTensor input, const int64_t size, const int64_t dim, topsStream_t stream=nullptr)

Splits the tensor into chunks. Each chunk is a view of the original tensor.

Parameters
  • out – The output chunks.

  • input – The input tensor.

  • size – The size of a single chunk or list of sizes for each chunk.

  • dim – The dimension along which to split the input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenSplit (std::vector< topsatenTensor > &out, const topsatenTensor input, const topsatenSize_t size, const int64_t dim, topsStream_t stream=nullptr)

Splits the tensor into chunks. Each chunk is a view of the original tensor.

Parameters
  • out – The output chunks.

  • input – The input tensor.

  • size – The size of a single chunk or list of sizes for each chunk.

  • dim – The dimension along which to split the input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenTensorSplit (std::vector< topsatenTensor > &out, const topsatenTensor input, const int64_t size, const int64_t dim=0, topsStream_t stream=nullptr)

Splits the tensor into chunks. Each chunk is a view of the original tensor.

Parameters
  • out – The output chunks.

  • input – The input tensor.

  • size – The size of a single chunk or list of sizes for each chunk.

  • dim – The dimension along which to split the input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenTensorSplit (std::vector< topsatenTensor > &out, const topsatenTensor input, const topsatenSize_t offsets, const int64_t dim=0, topsStream_t stream=nullptr)

Splits the tensor into chunks. Each chunk is a view of the original tensor.

Parameters
  • out – The output chunks.

  • input – The input tensor.

  • size – The size of a single chunk or list of sizes for each chunk.

  • dim – The dimension along which to split the input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenVSplit (std::vector< topsatenTensor > &out, const topsatenTensor input, const int64_t size, topsStream_t stream=nullptr)

Split an array into multiple sub-arrays vertically (row-wise).

Parameters
  • out – The output chunks.

  • input – The input tensor.

  • size – The size of a single chunk or list of sizes for each chunk.

  • dim – The dimension along which to split the input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenVSplit (std::vector< topsatenTensor > &out, const topsatenTensor input, const topsatenSize_t offsets, topsStream_t stream=nullptr)

Split an array into multiple sub-arrays vertically (row-wise).

Parameters
  • out – The output chunks.

  • input – The input tensor.

  • size – The size of a single chunk or list of sizes for each chunk.

  • dim – The dimension along which to split the input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenHSplit (std::vector< topsatenTensor > &out, const topsatenTensor input, const int64_t size, topsStream_t stream=nullptr)

Split an array into multiple sub-arrays horizontally (column-wise).

Parameters
  • out – The output chunks.

  • input – The input tensor.

  • size – The size of a single chunk or list of sizes for each chunk.

  • dim – The dimension along which to split the input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenHSplit (std::vector< topsatenTensor > &out, const topsatenTensor input, const topsatenSize_t offsets, topsStream_t stream=nullptr)

Split an array into multiple sub-arrays horizontally (column-wise).

Parameters
  • out – The output chunks.

  • input – The input tensor.

  • size – The size of a single chunk or list of sizes for each chunk.

  • dim – The dimension along which to split the input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenLogspace (topsatenTensor &output, const topsatenScalar_t &start, const topsatenScalar_t &end, int64_t step, double base, topsStream_t stream=nullptr)

This function returns the Logarithmically spaced elements based of input in inputs and steps.

Parameters
  • output – The output tensor.

  • start – The starting value for the set of points.

  • end – The ending value for the set of points.

  • step – The total number of elements between start and end.

  • base – The base of the logarithm function. Default: 10.0.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenAmpForeachNonFiniteCheckAndUnscale (std::vector< topsatenTensor > &output, topsatenTensor &found_inf, const std::vector< topsatenTensor > &input, const topsatenTensor &inv_scale, topsStream_t stream=nullptr)

Return a new tensor list which contains input tensors multiplied.

   by the scalar value in inv_scale and a changes the value in found.
   found_inf to one if 'inf' or 'NAN' value is found in any tensor.

Parameters
  • output – The output tensor list.

  • found_inf – The output tensor.

  • input – The input tensor list.

  • inv_scale – The input tensor.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenCosineSimilarity (topsatenTensor &output, const topsatenTensor &input1, const topsatenTensor &input2, int64_t dim, double eps, topsStream_t stream=nullptr)

Returns cosine similarity between input1 and input2 computed along specified dim.

Parameters
  • output – The output tensor.

  • input1 – The input1 tensor.

  • input2 – The input2 tensor.

  • dim – The dimension where cosine similarity is computed.

  • eps – A small value to avoid division by zero.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenDiff (topsatenTensor &output, const topsatenTensor &inputs, int64_t n, int64_t dim, const topsatenTensor &prepend, const topsatenTensor &append, topsStream_t stream=nullptr)

This function computes the n-th forward difference along the given dimension.

Parameters
  • output – The output tensor.

  • inputs – The input tensors.

  • n – N times to recursively compute the difference.

  • dim – The dimension to compute the difference along.

  • prepend – Optional prepend tensors.

  • append – Optional append tensors.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenBilinear (topsatenTensor &out, const topsatenTensor &input1, const topsatenTensor &input2, const topsatenTensor &weight, const topsatenTensor &bias, topsStream_t stream=nullptr)

Computes the bilinear operation.

Parameters
  • out – The output tensor where the result of the bilinear operation will be stored.

  • input1 – The first input tensor.

  • input2 – The second input tensor.

  • weight – The weight tensor representing weight in the bilinear operation.

  • bias – The bias tensor representing the bias in the bilinear operation.

  • stream – TOPS stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenTrunc (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

Returns a new tensor with the truncated integer values of the elements of input.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenRavel (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

This function returns a contiguous flattened tensor.

Parameters
  • output – The output tensor.

  • inputs – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenRad2Deg (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

This function returns a new tensor with each of the elements of input converted from angles in radians to degrees.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenRound (topsatenTensor &out, const topsatenTensor &input, int64_t decimal, topsStream_t stream=nullptr)

Computes the round operation.

Parameters
  • out – The output tensor where the result of the round operation will be stored.

  • input – The input tensor.

  • decimal – Number of decimal places to round to.

  • stream – TOPS stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenRound (topsatenTensor &out, const topsatenTensor &input, topsStream_t stream=nullptr)

Computes the round operation.

Parameters
  • out – The output tensor where the result of the round operation will be stored.

  • input – The input tensor.

  • stream – TOPS stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenSumToSize (topsatenTensor &output, const topsatenTensor &input, const topsatenSize_t size, topsStream_t stream=nullptr)

This function computes sum on the input tensor based on the size param. Size must be broadcastable to the input tensor shape.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • size – Size.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenFix (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

Returns a new tensor with the truncated integer values of the elements of input.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenDeg2rad (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

This function returns a new tensor with each of the elements of input converted from angles in degree to radian.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenCartesianProd (topsatenTensor &output, const std::vector< topsatenTensor > &inputs, topsStream_t stream=nullptr)

This function finds the cartesian product specified by input.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenPositive (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

This function returns the same input tensor and is not supported for Boolean datatype.

Parameters
  • output – The output tensor.

  • inputs – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenPixelShuffle (topsatenTensor &output, const topsatenTensor &input, int64_t upscale_factor, topsStream_t stream=nullptr)

Rearrange elements in a tensor according to an upscaling factor.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • upscale_factor – The factor to increase spatial resolution by.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenNansum (topsatenTensor &output, const topsatenTensor &input, const topsatenSize_t &dim, bool keepdim, topsatenDataType_t data_type, topsStream_t stream=nullptr)

Performs the addition computation also ignoring nan values.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • dim – The dimensions to reduce sum.

  • keepdim – Whether the output tensor has dim retained or not.

  • data_type – Output data_type.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenChannelShuffle (topsatenTensor &output, const topsatenTensor &input, int64_t groups, topsStream_t stream=nullptr)

This function Divides and rearranges the channels in a tensor.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • group – The number of groups to divide channels in.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenNativeChannelShuffle (topsatenTensor &output, const topsatenTensor &input, int64_t groups, topsStream_t stream=nullptr)

This function Divides and rearranges the channels in a tensor.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • group – The number of groups to divide channels in.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenPermute (topsatenTensor &output, const topsatenTensor &input, const topsatenSize_t &dims, topsStream_t stream=nullptr)

Returns a view of the original tensor input with its dimensions permuted.

Parameters
  • out – The output tensor.

  • input – The input tensor.

  • dims – The desired ordering of dimensions.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenPixelUnshuffle (topsatenTensor &output, const topsatenTensor &input, int64_t downscale_factor, topsStream_t stream=nullptr)

Rearrange elements in a tensor according to a downscaling factor.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • downscale_factor – The factor to decrease spatial resolution by.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenPoissonNllLoss (topsatenTensor &output, const topsatenTensor &input, const topsatenTensor &target, bool log_input, bool full, double eps, int64_t reduction, topsStream_t stream=nullptr)

This function computes Negative log likelihood loss with Poisson distribution of target.

Parameters
  • output – - The output tensor.

  • input – - The input tensor.

  • target – - The target tensor.

  • log_input – - Whether the input is logarithmized. Default is false.

  • full – - Whether to compute full loss. Default is false.

  • eps – - Small value to avoid evaluation of log(0). Default is 1e-8.

  • reduction – - Specifies the reduction to apply to the output: ‘none’ | ‘mean’ | ‘sum’. ‘none’: no reduction will be applied, ‘mean’: the mean of the output is taken, ‘sum’: the output will be summed.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenFrexp (topsatenTensor &mantissa, topsatenTensor &exponent, const topsatenTensor &input, topsStream_t stream=nullptr)

This function decomposes input into mantissa and exponent tensors.

Parameters
  • mantissa – The mantissa tensor.

  • exponent – The exponent tensor.

  • inputs – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenStd (topsatenTensor &output, const topsatenTensor &input, const topsatenSize_t &dim, const topsatenScalar_t &correction, bool keepdim, topsStream_t stream=nullptr)

This function return the standard deviation over the dimensions specified by dim.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • dim – The dimension or dimensions to reduce.

  • correction – Difference between the sample size and sample degrees of freedom.

  • keepdim – Whether the output tensor has dim retained or not.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenTripletMarginLoss (topsatenTensor &output, const topsatenTensor &anchor, const topsatenTensor &positive, const topsatenTensor &negative, double margin, double p, double eps, bool swap, int64_t reduction, topsStream_t stream=nullptr)

This function computes the triplet margin loss between anchor, positive and negative.

Parameters
  • output – The output tensor.

  • anchor – The input anchor tensor.

  • positive – The input positive tensor.

  • negative – The input negative tensor.

  • margin – Default: 1.

  • p – The norm degree for pairwise distance. Default: 2.

  • eps – Input epsilon.

  • swap – The distance swap is described in detail in the paper Learning shallow convolutional feature descriptors with triplet losses by V. Balntas, E. Riba et al. Default: False.

  • reduction – Specifies the reduction to apply to the output: ‘none’ | ‘mean’ | ‘sum’. ‘none’: no reduction will be applied, ‘mean’: the weighted mean of the output is taken, ‘sum’: the output will be summed.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenBinomial (topsatenTensor &output, const topsatenTensor &count, const topsatenTensor &prob, const topsatenGenerator_t &generator, topsStream_t stream=nullptr)

Creates a Binomial distribution according to given prob.

Parameters
  • output – The output tensor.

  • count – The number of Bernoulli trials.

  • prob – Event probabilities.

  • generator – Generator used to initialize random number generator states.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenPairwiseDistance (topsatenTensor &output, const topsatenTensor &input1, const topsatenTensor &input2, double p, double eps, bool keepdim, topsStream_t stream=nullptr)

This function Computes the pairwise distance between input vectors, or between columns of input matrices.

Parameters
  • output – The output tensor.

  • input1 – The input tensor X.

  • input2 – The input tensor Y.

  • p – The norm degree.

  • eps – The Small value to avoid division by zero.

  • keepdim – Determines whether or not to keep the vector dimension.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenPdist (topsatenTensor &out, const topsatenTensor &input, double p, topsStream_t stream=nullptr)

Computes the pdist operation.

Parameters
  • out – The output tensor where the result of the operation will be stored.

  • input – The input tensor.

  • p – Value for the p-norm distance.

  • stream – TOPS stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenVander (topsatenTensor &out, const topsatenTensor &input, topsatenScalar_t &N, bool increasing=false, topsStream_t stream=nullptr)

Generates a Vandermonde matrix.

Parameters
  • out – The output tensor where the result of the vander operation will be stored.

  • x – The input tensor.

  • N – Number of columns in the output. If N is not specified, a square array is returned

  • increasing – Order of the powers of the columns. If True, the powers increase from left to right, if False (the default) they are reversed.

  • stream – TOPS stream.

Returns

Returns a topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenRange (topsatenTensor &output, const topsatenScalar_t &start, const topsatenScalar_t &end, const topsatenScalar_t &steps, topsStream_t stream=nullptr)

This function returns the Linearly spaced elements based of input in inputs and steps.

Parameters
  • output – The output tensor.

  • start – The starting value for the set of points.

  • end – The ending value for the set of points.

  • steps – The gap between each pair of adjacent points.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenTranspose (topsatenTensor &output, const topsatenTensor &input, const int64_t &dim0, const int64_t &dim1, topsStream_t stream=nullptr)

Returns a tensor that is a transposed version of input. The given dimensions dim0 and dim1 are swapped.

Parameters
  • out – The output tensor.

  • input – The input tensor.

  • dim0 – The first dimension to be transposed.

  • dim1 – The second dimension to be transposed.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenSwapAxes (topsatenTensor &output, const topsatenTensor &input, const int64_t &dim0, const int64_t &dim1, topsStream_t stream=nullptr)

Alias for topsatenTranspose.

Parameters
  • out – The output tensor.

  • input – The input tensor.

  • dim0 – The first dimension to be transposed.

  • dim1 – The second dimension to be transposed.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenSwapDims (topsatenTensor &output, const topsatenTensor &input, const int64_t &dim0, const int64_t &dim1, topsStream_t stream=nullptr)

Alias for topsatenTranspose.

Parameters
  • out – The output tensor.

  • input – The input tensor.

  • dim0 – The first dimension to be transposed.

  • dim1 – The second dimension to be transposed.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenSelect (topsatenTensor &output, const topsatenTensor &input, const int64_t &dim, const int64_t &index, topsStream_t stream=nullptr)

Slices the input tensor along the selected dimension at the given index. This function returns a view of the original tensor with the given dimension removed.

Parameters
  • out – The output tensor.

  • input – The input tensor.

  • dim – The dimension to slice.

  • index – The index to select with.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenSqueeze (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

Returns a tensor with all specified dimensions of input of size 1 removed.

Parameters
  • out – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenSqueeze (topsatenTensor &output, const topsatenTensor &input, const int64_t dim, topsStream_t stream=nullptr)

Returns a tensor with all specified dimensions of input of size 1 removed.

Parameters
  • out – The output tensor.

  • input – The input tensor.

  • dim – Now accepts tuples of dimensions.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenSqueeze (topsatenTensor &output, const topsatenTensor &input, const topsatenSize_t &dims, topsStream_t stream=nullptr)

Returns a tensor with all specified dimensions of input of size 1 removed.

Parameters
  • out – The output tensor.

  • input – The input tensor.

  • dims – Now accepts tuples of dimensions.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenUnSqueeze (topsatenTensor &output, const topsatenTensor &input, const int64_t &dim, topsStream_t stream=nullptr)

Returns a new tensor with a dimension of size one inserted at the specified position.

Parameters
  • out – The output tensor.

  • input – The input tensor.

  • dim – The index at which to insert the singleton dimension.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenNarrow (topsatenTensor &output, const topsatenTensor &input, const int64_t &dim, const int64_t &start, const int64_t &length, topsStream_t stream=nullptr)

Returns a new tensor that is a narrowed version of input tensor. The dimension dim is input from start to start + length. The returned tensor and input tensor share the same underlying storage.

Parameters
  • out – The output tensor.

  • in – The input tensor.

  • dim – The dimension along which to narrow.

  • start – The index of the element to start the narrowed dimension from. Can be negative, which means indexing from the end of dim. If Tensor, it must be an 0-dim integral Tensor (bools not allowed).

  • length – The length of the narrowed dimension, must be weakly positive.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenUnFold (topsatenTensor &output, const topsatenTensor &input, const int64_t &dim, const int64_t &size, const int64_t &step, topsStream_t stream=nullptr)

Returns a view of the original tensor which contains all slices of size size from self tensor in the dimension dimension.

Parameters
  • out – The output tensor.

  • in – The input tensor.

  • dim – The dimension in which unfolding happens.

  • size – The size of each slice that is unfolded.

  • step – The step between each slice.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenUnFlatten (topsatenTensor &output, const topsatenTensor &input, const int64_t &dim, const topsatenSize_t &sizes, topsStream_t stream=nullptr)

Expands a dimension of the input tensor over multiple dimensions.

Parameters
  • out – The output tensor.

  • in – The input tensor.

  • dim – Dimension to be unflattened, specified as an index into input.shape.

  • sizes – New shape of the unflattened dimension.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenUnBind (std::vector< topsatenTensor > &out, const topsatenTensor input, const int64_t dim, topsStream_t stream=nullptr)

Removes a tensor dimension. Returns a tuple of all slices along a given dimension, already without it.

Parameters
  • out – The output tensor.

  • in – The input tensor.

  • dim – The dimension to remove.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenChunk (std::vector< topsatenTensor > &out, const topsatenTensor input, const int64_t chunks, const int64_t dim=0, topsStream_t stream=nullptr)

Attempts to split a tensor into the specified number of chunks. Each chunk is a view of the input tensor.

Parameters
  • out – The output tensor.

  • in – The input tensor.

  • chunks – The number of chunks to return.

  • dim – The dimension along which to split the tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenView (topsatenTensor &output, const topsatenTensor &input, const topsatenSize_t &shape, topsStream_t stream=nullptr)

Returns a new tensor with the same data as the self tensor but of a different shape.

Parameters
  • out – The output tensor.

  • input – The input tensor.

  • shape – The desired size.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenView (topsatenTensor &output, const topsatenTensor &input, const topsatenDataType_t &dtype, topsStream_t stream=nullptr)

Returns a new tensor with the same data as the self tensor but of a different shape.

Parameters
  • out – The output tensor.

  • input – The input tensor.

  • dtype – The desired size.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenViewAs (topsatenTensor &output, const topsatenTensor &input, const topsatenTensor &other, topsStream_t stream=nullptr)

View this tensor as the same size as other. self.view_as(other) is equivalent to self.view(other.size()).

Parameters
  • out – The output tensor.

  • input – The input tensor.

  • other – The result tensor has the same size as other.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenMoveDim (topsatenTensor &output, const topsatenTensor &input, const topsatenSize_t &src, const topsatenSize_t &dst, topsStream_t stream=nullptr)

Moves the dimension(s) of input at the position(s) in source to the position(s) in destination. Other dimensions of input that are not explicitly moved remain in their original order and appear at the positions not specified in destination.

Parameters
  • out – The output tensor.

  • input – The input tensor.

  • src – Original positions of the dims to move. These must be unique.

  • dst – Destination positions for each of the original dims. These must also be unique.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenMoveDim (topsatenTensor &output, const topsatenTensor &input, const int64_t &src, const int64_t &dst, topsStream_t stream=nullptr)

Moves the dimension(s) of input at the position(s) in source to the position(s) in destination. Other dimensions of input that are not explicitly moved remain in their original order and appear at the positions not specified in destination.

Parameters
  • out – The output tensor.

  • input – The input tensor.

  • src – Original positions of the dims to move. These must be unique.

  • dst – Destination positions for each of the original dims. These must also be unique.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenStdMean (topsatenTensor &output0, topsatenTensor &output1, const topsatenTensor &input, const topsatenSize_t &dim, const topsatenScalar_t &correction, bool keepdim, topsStream_t stream=nullptr)

This function return the standard deviation and mean over the dimensions specified by dim.

Parameters
  • output – The std tensor.

  • output – The output tensor.

  • input – The input tensor.

  • dim – The dimension or dimensions to reduce.

  • correction – Difference between the sample size and sample degrees of freedom.

  • keepdim – Whether the output tensor has dim retained or not.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenMode (topsatenTensor &output, topsatenTensor &indices, const topsatenTensor &input, int64_t dim, bool keepdim, topsStream_t stream=nullptr)

Computes the mode(element having highest frequency) value of each row.

Parameters
  • out – The output is a tuple of tensors containing mode value of each row and their index respectively.

  • input – The input tensor.

  • dim – Int.

  • keepdim – Bool.

  • stream – TOPS stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenTrapezoid (topsatenTensor &output, const topsatenTensor &y, const topsatenTensor &x, int64_t dim, topsStream_t stream=nullptr)

This function computes the trapezoidal rule along dim.

Parameters
  • output – The output tensor.

  • Y – The input tensor - contains values to use when computing the trapezoidal rule.

  • X – The input tensor - defines spacing between values.

  • dim – The dimension along which to compute the trapezoidal rule.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenTrapz (topsatenTensor &output, const topsatenTensor &y, const topsatenTensor &x, int64_t dim, topsStream_t stream=nullptr)

This function computes the trapezoidal rule along dim. (Alias for topsatenTrapezoid).

Parameters
  • output – The output tensor.

  • Y – The input tensor - contains values to use when computing the trapezoidal rule.

  • X – The input tensor - defines spacing between values.

  • dim – The dimension along which to compute the trapezoidal rule.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenTrapezoid (topsatenTensor &output, const topsatenTensor &y, const topsatenScalar_t &dx, int64_t dim, topsStream_t stream=nullptr)

This function computes the trapezoidal rule along dim.

Parameters
  • output – The output tensor.

  • Y – The input tensor - contains values to use when computing the trapezoidal rule.

  • dx – Float - defines constant spacing between values.

  • dim – The dimension along which to compute the trapezoidal rule.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenTrapz (topsatenTensor &output, const topsatenTensor &y, double dx, int64_t dim, topsStream_t stream=nullptr)

This function computes the trapezoidal rule along dim. (Alias for topsatenTrapezoid.dx).

Parameters
  • output – The output tensor.

  • Y – The input tensor - contains values to use when computing the trapezoidal rule.

  • dx – Float - defines constant spacing between values.

  • dim – The dimension along which to compute the trapezoidal rule.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenEuclideanDist (topsatenTensor &output, const topsatenTensor &x1, const topsatenTensor &x2, topsStream_t stream=nullptr)

Returns distance between each pair of the two collections of row vectors.

Parameters
  • output – The output tensor.

  • x1 – The x1 tensor.

  • x2 – The x2 tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenPoisson (topsatenTensor &output, const topsatenTensor &rates, const topsatenGenerator_t &generator, topsStream_t stream=nullptr)

Returns a tensor of the same size as input with each element sampled from a Poisson distribution with rate parameter given by the corresponding element in input.

Parameters
  • output – The output tensor.

  • rates – Tensor containing the rates of the Poisson distribution.

  • generator – Generator used to initialize random number generator states.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenCdist (topsatenTensor &output, const topsatenTensor &x1, const topsatenTensor &x2, double p, const topsatenScalar_t compute_mode, topsStream_t stream=nullptr)

Computes batched the p-norm distance between each pair of the two collections of row vectors.

Parameters
  • out – The output tensor.

  • x1 – The first input tensor.

  • x2 – The second input tensor.

  • p – The value for the p-norm distance to calculate between each vector pair in [0, infinity].

  • compute_modeuse_mm_for_euclid_dist_if_necessary - will use matrix multiplication approach to calculate euclidean distance (p = 2) if P > 25 or R > 25 use_mm_for_euclid_dist - will always use matrix multiplication approach to calculate euclidean distance (p = 2) ‘donot_use_mm_for_euclid_dist’ - will never use matrix multiplication approach to calculate euclidean distance (p = 2) Default: use_mm_for_euclid_dist_if_necessary.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenRnnTanhCell (topsatenTensor &output, const topsatenTensor &input, const topsatenTensor &hidden, const topsatenTensor &weight_ih, const topsatenTensor &weight_hh, const topsatenTensor &bias_ih, const topsatenTensor &bias_hh, topsStream_t stream=nullptr)

This function Computes an Elman RNN cell with tanh non-linearity..

Parameters
  • output – The tensor containing the next hidden state for each element in the batch.

  • input – The tensor containing input features X.

  • hidden – The tensor containing the initial hidden state h.

  • weight_ih – The learnable input-hidden weights.

  • weight_hh – The learnable hidden-hidden weights.

  • bias_ih – The learnable input-hidden bias.

  • bias_hh – The learnable hidden-hidden bias.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenRnnReluCell (topsatenTensor &output, const topsatenTensor &input, const topsatenTensor &hidden, const topsatenTensor &weight_ih, const topsatenTensor &weight_hh, const topsatenTensor &bias_ih, const topsatenTensor &bias_hh, topsStream_t stream=nullptr)

Function used for creating a single cell in an RNN that uses the ReLU (Rectified Linear Unit) activation function.

Parameters
  • output – The tensor containing the next hidden state for each element in the batch.

  • input – The tensor containing input features X.

  • hidden – The tensor containing the initial hidden state h.

  • weight_ih – The learnable input-hidden weights.

  • weight_hh – The learnable hidden-hidden weights.

  • bias_ih – The learnable input-hidden bias.

  • bias_hh – The learnable hidden-hidden bias.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenErfinv (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

Computes the inverse error function of input. The inverse error function is defined in the range (-1,1).

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenIndexFill (topsatenTensor &output, const topsatenTensor &input, int64_t dim, const topsatenTensor &index, const topsatenScalar_t &value, topsStream_t stream=nullptr)

Fills the elements of the input tensor with value by selecting the indices in the order given in index.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • dim – Dimension along which to index.

  • index – Indices of input tensor to fill in.

  • value – The value to fill with.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenIndexFill (topsatenTensor &output, const topsatenTensor &input, int64_t dim, const topsatenTensor &index, const topsatenTensor &value, topsStream_t stream=nullptr)

Fills the elements of the input tensor with value by selecting the indices in the order given in index.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • dim – Dimension along which to index.

  • index – Indices of input tensor to fill in.

  • value – The value tensor to fill with.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenMSELoss (topsatenTensor &output, const topsatenTensor &input, const topsatenTensor &target, int64_t reduction, topsStream_t stream=nullptr)

This function measures the mean squared error (squared L2 norm) between each element of inputs and target.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • target – The target tesnsor.

  • reduction – Specifies the reduction to apply to the output: ‘none’ | ‘mean’ | ‘sum’. ‘none’: no reduction will be applied, ‘mean’: the mean of the output is taken, ‘sum’: the output will be summed.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenLgamma (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

Computes the natural logarithm of the absolute value of the gamma function on input.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenHistc (topsatenTensor &output, const topsatenTensor &input, int64_t bins, topsatenScalar_t &min, topsatenScalar_t &max, topsStream_t stream=nullptr)

Computes the histogram of a tensor.

Parameters
  • out – Histogram represented as a tensor.

  • input – The input tensor.

  • bins – Int64_t.

  • min – Float.

  • max – Float.

  • stream – TOPS stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenKron (topsatenTensor &output, const topsatenTensor &self, const topsatenTensor &other, topsStream_t stream=nullptr)

Computes the Kronecker product of self and other.

Parameters
  • output – The output tensor.

  • self – The input tensor.

  • other – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenDigamma (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

Computes the logarithmic derivative of the gamma function on input.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenLstmCell (std::vector< topsatenTensor > &output, const topsatenTensor &input, const std::vector< topsatenTensor > &hidden, const topsatenTensor &weight_ih, const topsatenTensor &weight_hh, const topsatenTensor &bias_ih, const topsatenTensor &bias_hh, topsStream_t stream=nullptr)

Function representing a single Long Short-Term Memory (LSTM) cell.

Parameters
  • output – The tensor containing the next hidden state for each element in the batch.

  • input – The tensor containing input features X.

  • hidden – The tensors containing the initial hidden state h.

  • weight_ih – The learnable input-hidden weights.

  • weight_hh – The learnable hidden-hidden weights.

  • bias_ih – The learnable input-hidden bias.

  • bias_hh – The learnable hidden-hidden bias.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenIndexAdd (topsatenTensor &output, const topsatenTensor &input, int64_t dim, const topsatenTensor &index, const topsatenTensor &source, const topsatenScalar_t alpha, topsStream_t stream=nullptr)

Accumulate the elements of alpha times source into the input tensor by adding to the indices in the order given in index.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • dim – Dimension along which to index.

  • index – Indices of source to select from.

  • src – The tensor containing values to add.

  • alpha – The scalar multiplier for source.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenMultiMarginLoss (topsatenTensor &output, const topsatenTensor &input, const topsatenTensor &target, const topsatenScalar_t &p, const topsatenScalar_t &margin, const topsatenTensor &weight, int64_t reduction, topsStream_t stream=nullptr)

Computes the mode(element having highest frequency) value of each row.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • target – The target tensor.

  • weight – The weight tensor.

  • p – default value of 1.

  • margin – A double value .

  • reduction – Specifies the reduction to apply to the output: ‘none’ | ‘mean’ | ‘sum’. ‘none’: no reduction will be applied, ‘mean’: the weighted mean of the output is taken, ‘sum’: the output will be summed.

  • stream – Tops stream

Returns

topsatenStatus_t

topsatenStatus_t TOPSATEN_EXPORT topsatenTrace (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

Computes the sum of diagnol elements of input.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsateni0 (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

Computes the zeroth order modified Bessel function of the first kind for each element of Input.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGruCell (topsatenTensor &output, const topsatenTensor &input, const topsatenTensor &hidden, const topsatenTensor &weight_ih, const topsatenTensor &weight_hh, const topsatenTensor &bias_ih, const topsatenTensor &bias_hh, topsStream_t stream=nullptr)

This function Computes gated recurrent unit (GRU) cell.

Parameters
  • output – The tensor containing the next hidden state for each element in the batch.

  • input – The tensor containing input features X.

  • hidden – The tensor containing the initial hidden state h.

  • weight_ih – The learnable input-hidden weights.

  • weight_hh – The learnable hidden-hidden weights.

  • bias_ih – The learnable input-hidden bias.

  • bias_hh – The learnable hidden-hidden bias.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenCross (topsatenTensor &output, const topsatenTensor &input, const topsatenTensor &other, const topsatenScalar_t &dim, topsStream_t stream=nullptr)

Returns the cross product of vectors in dimension dim of input and other.

Parameters
  • output – The output tensor.

  • input – The first input tensor.

  • other – The second input tensor.

  • dim – The dimension to take the cross-product in.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenL1Loss (topsatenTensor &output, const topsatenTensor &input, const topsatenTensor &target, int64_t reduction, topsStream_t stream=nullptr)

This function measures the mean absolute error (MAE) between each element of inputs and target.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • target – The target tesnsor.

  • reduction – Specifies the reduction to apply to the output: ‘none’ | ‘mean’ | ‘sum’. ‘none’: no reduction will be applied, ‘mean’: the mean of the output is taken, ‘sum’: the output will be summed.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenMultiLabelMarginLoss (topsatenTensor &output, const topsatenTensor &input, const topsatenTensor &target, int64_t reduction, topsStream_t stream=nullptr)

This function Creates a criterion that optimizes a multi-class multi-classification hinge loss between input x and output y.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • target – The target tensor.

  • reduction – Specifies the reduction to apply to the output: ‘none’ | ‘mean’ | ‘sum’. ‘none’: no reduction will be applied, ‘mean’: the weighted mean of the output is taken, ‘sum’: the output will be summed.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenBucketize (topsatenTensor &output, const topsatenTensor &input, const topsatenTensor &boundaries, bool out_int32, bool right, topsStream_t stream=nullptr)

Returns the indices of the buckets to which each value in the input belongs, where the boundaries of the buckets are set by boundaries.

Parameters
  • output – The output tensor.

  • input – The N-D tensor containing the search values.

  • boundaries – 1-D tensor, must contain a strictly increasing sequence.

  • out_int32 – Indicate the output data type. Int32 if True, Int64 otherwise.

  • right – If False, return the first suitable location that is found. If True, return the last such index.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenPolygamma (topsatenTensor &output, int64_t n, const topsatenTensor &input, topsStream_t stream=nullptr)

Computes the nth derivative of the digamma function on input.

Parameters
  • output – The output tensor.

  • n – The order of the polygamma function.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenIndexReduce (topsatenTensor &output, const topsatenTensor &input, int64_t dim, const topsatenTensor &index, const topsatenTensor &source, const char *reduce, bool include_self, topsStream_t stream=nullptr)

Accumulate the elements of source into the input tensor by accumulating to the indices in the order given in index using the reduction given by the reduce argument.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • dim – Dimension along which to index.

  • index – Indices of source to select from.

  • src – The tensor containing values to accumulate.

  • reduce – The reduction operation to apply (“prod”, “mean”, “amax”, “amin”).

  • include_self – Whether the elements from the input tensor are included in the reduction.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenSVD (topsatenTensor &U, topsatenTensor &S, topsatenTensor &Vh, const topsatenTensor &A, bool full_matrices, bool compute_uv, const char *driver, topsStream_t stream=nullptr)

Computes the singular value decomposition (SVD) of a matrix.

Parameters
  • U – The output tensor.

  • S – The output tensor.

  • Vh – The output tensor.

  • A – The input tensor.

  • full_matrices – Controls whether to compute the full or reduced SVD, and consequently, the shape of the returned tensors U and Vh. Default: True.

  • compute_uv – Controls whether to compute U and V. Default: True.

  • driver – To specify which method to use, defaults to “gesvdj” for Jacobi Method.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenPinverse (topsatenTensor &output, const topsatenTensor &input, double rcond, topsStream_t stream=nullptr)

Computes Pinverse of elements of input.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • rcond – The rcond refers to the cutoff parameter.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenHistogram (topsatenTensor &hist, topsatenTensor &bin_edges, const topsatenTensor &self, const topsatenTensor &bins, const topsatenTensor &weight, bool density, topsStream_t stream=nullptr)

Computes a histogram of the values in a tensor.

Parameters
  • hist – Output tensor containing the values of the histogram.

  • bin_edges – Output tensor containing the edges of the histogram bins.

  • self – The input tensor.

  • bins – Defines the sequence of bin edges including the rightmost edge.

  • weight – Should have the same shape as input. Each value in input contributes its associated weight towards its bins result.

  • density – If False, the result will contain the count (or total weight) in each bin. If True, the result is the value of the probability density function over the bins, normalized such that the integral over the range of the bins is 1.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenHistogram (topsatenTensor &hist, topsatenTensor &bin_edges, const topsatenTensor &self, const int64_t bins, const std::vector< double > &range, const topsatenTensor &weight, bool density, topsStream_t stream=nullptr)

Computes a histogram of the values in a tensor.

Parameters
  • hist – Output tensor containing the values of the histogram.

  • bin_edges – Output tensor containing the edges of the histogram bins.

  • self – The input tensor.

  • bins – Defines the number of equal-width bins.

  • range – Defines the range of the bins.

  • weight – Should have the same shape as input. Each value in input contributes its associated weight towards its bins result.

  • density – If False, the result will contain the count (or total weight) in each bin. If True, the result is the value of the probability density function over the bins, normalized such that the integral over the range of the bins is 1.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenLdexp (topsatenTensor &output, const topsatenTensor &self, const topsatenTensor &other, topsStream_t stream=nullptr)

This function multiples each element of the self tensor by 2 raised to the power of the corresponding element in the other tensor.

Parameters
  • output – The output tensor.

  • self – The mantissa tensor.

  • other – The exponent tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenSplitWithSizes (std::vector< topsatenTensor > &out, const topsatenTensor input, const topsatenSize_t size, const int64_t dim, topsStream_t stream=nullptr)

Splits the tensor into chunks. Each chunk is a view of the original tensor.

Parameters
  • out – The output chunks.

  • input – The input tensor.

  • size – The size of a single chunk or list of sizes for each chunk.

  • dim – The dimension along which to split the input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenFliplr (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

Flip tensor in the left/right direction, returning a new tensor.

Parameters
  • out – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

2.2. Aten cnn ops

This section describes topsaten cnn ops api definitions.

topsatenStatus_t TOPSATEN_EXPORT topsatenConvolution (topsatenTensor &output, const topsatenTensor &input, const topsatenTensor &filter, const topsatenTensor &bias, const topsatenSize_t &stride, const topsatenSize_t &padding, const topsatenSize_t &dilation, bool transposed, const topsatenSize_t &output_padding, int64_t groups, topsStream_t stream=nullptr)

Convolution operator.

Parameters
  • output – The output tensor.

  • input – The input tensor of feature.

  • filter – The input tensor of reduce window.

  • bias – The input tensor of bias, disabled if tensor datatype is TOPSATEN_DATA_NONE.

  • stride – The stride of the convolving kernel.

  • padding – The amount of padding applied to the input shape, can be either a conv-rank list of ints giving the amount of padding applied on both sides (eg. [pad_h, pad_w] for conv2d), or a 2x conv-rank list of ints giving the amount of padding applied on each side (eg. [pad_h_low, pad_h_high, pad_w_low, pad_w_high] for conv2d).

  • dilation – The spacing between kernel elements.

  • transposed – A bool value indicates whether perform ConvTranspose Op.

  • output_padding – Padding added to output shape, not currently enabled.

  • groups – Controls the connections between inputs and outputs, in_channels and out_channels must both be divisible by groups.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenConvTranspose2d (topsatenTensor &output, const topsatenTensor &input, const topsatenTensor &filter, const topsatenTensor &bias, const topsatenSize_t &stride, const topsatenSize_t &padding, const topsatenSize_t &output_padding, int64_t groups, const topsatenSize_t &dilation, topsStream_t stream=nullptr)

ConvTranspose2d operator.

Parameters
  • output – The output tensor.

  • input – The input tensor of feature.

  • filter – The input tensor of reduce window.

  • bias – The input tensor of bias, disabled if tensor datatype is TOPSATEN_DATA_NONE.

  • stride – The stride of the convolving kernel.

  • padding – The amount of padding applied to the input shape, can be either a conv-rank list of ints giving the amount of padding applied on both sides (eg. [pad_h, pad_w] for conv2d), or a 2x conv-rank list of ints giving the amount of padding applied on each side (eg. [pad_h_low, pad_h_high, pad_w_low, pad_w_high] for conv2d).

  • output_padding – Padding added to output shape, not currently enabled.

  • groups – Controls the connections between inputs and outputs, in_channels and out_channels must both be divisible by groups.

  • dilation – The spacing between kernel elements.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenConvDepthwise2d (topsatenTensor &output, const topsatenTensor &input, const topsatenTensor &filter, const topsatenTensor &bias, const topsatenSize_t &stride, const topsatenSize_t &padding, const topsatenSize_t &dilation, topsStream_t stream=nullptr)

ConvDepthwise2d operator.

Parameters
  • output – The output tensor.

  • input – The input tensor of feature.

  • filter – The input tensor of reduce window.

  • bias – The input tensor of bias, disabled if tensor datatype is TOPSATEN_DATA_NONE.

  • stride – The stride of the convolving kernel.

  • padding – The amount of padding applied to the input shape, can be either a conv-rank list of ints giving the amount of padding applied on both sides (eg. [pad_h, pad_w] for conv2d), or a 2x conv-rank list of ints giving the amount of padding applied on each side (eg. [pad_h_low, pad_h_high, pad_w_low, pad_w_high] for conv2d)pe.

  • dilation – The spacing between kernel elements.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenConv2d (topsatenTensor &output, const topsatenTensor &input, const topsatenTensor &filter, const topsatenTensor &bias, const topsatenSize_t &stride, const topsatenSize_t &padding, const topsatenSize_t &dilation, int64_t groups, topsStream_t stream=nullptr)

Conv2d operator.

Parameters
  • output – The output tensor.

  • input – The input tensor of feature.

  • filter – The input tensor of reduce window.

  • bias – The input tensor of bias, disabled if tensor datatype is TOPSATEN_DATA_NONE.

  • stride – The stride of the convolving kernel.

  • padding – The amount of padding applied to the input shape, can be either a conv-rank list of ints giving the amount of padding applied on both sides (eg. [pad_h, pad_w] for conv2d), or a 2x conv-rank list of ints giving the amount of padding applied on each side (eg. [pad_h_low, pad_h_high, pad_w_low, pad_w_high] for conv2d).

  • dilation – The spacing between kernel elements.

  • groups – Controls the connections between inputs and outputs, in_channels and out_channels must both be divisible by groups.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenConvBiasActivation (topsatenTensor &output, const topsatenTensor &input, const topsatenTensor &filter, const topsatenTensor &bias, const topsatenSize_t &stride, const topsatenSize_t &padding, const topsatenSize_t &dilation, int64_t groups, const topsatenActivationMode_t activation_mode, const topsatenScalar_t &coef={TOPSATEN_DATA_FP32, {.fval=1.0f}}, topsStream_t stream=nullptr)

ConvBiasActivation operator.

Parameters
  • output – The output tensor.

  • input – The input tensor of feature.

  • filter – The input tensor of reduce window.

  • bias – The input tensor of bias, disabled if tensor datatype is TOPSATEN_DATA_NONE.

  • stride – The stride of the convolving kernel.

  • padding – The amount of padding applied to the input shape, can be either a conv-rank list of ints giving the amount of padding applied on both sides (eg. [pad_h, pad_w] for conv2d), or a 2x conv-rank list of ints giving the amount of padding applied on each side (eg. [pad_h_low, pad_h_high, pad_w_low, pad_w_high] for conv2d).

  • dilation – The spacing between kernel elements.

  • groups – Controls the connections between inputs and outputs, in_channels and out_channels must both be divisible by groups.

  • activation_mode – An enumerant to specify the activation mode.

  • coef – A floating point scalar only applicable to CLIPPED_RELU, ELU and LEAKY_RELU, specifies the clipping threshold, the alpha and the negative slope respectively, otherwise set whatever, default 1.0f.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT _topsatenConvolution (topsatenTensor &output, const topsatenTensor &input, const topsatenTensor &filter, const topsatenTensor &bias, const topsatenSize_t &stride, const topsatenSize_t &padding, const topsatenSize_t &dilation, bool transposed, const topsatenSize_t &output_padding, int64_t groups, bool benchmark, bool deterministic, bool cudnn_enabled, bool allow_tf32, topsStream_t stream=nullptr)

_Convolution operator.

Parameters
  • output – The output tensor.

  • input – The input tensor of feature.

  • filter – The input tensor of reduce window.

  • bias – The input tensor of bias, disabled if tensor datatype is TOPSATEN_DATA_NONE.

  • stride – The stride of the convolving kernel.

  • padding – The amount of padding applied to the input shape, can be either a conv-rank list of ints giving the amount of padding applied on both sides (eg. [pad_h, pad_w] for conv2d), or a 2x conv-rank list of ints giving the amount of padding applied on each side (eg. [pad_h_low, pad_h_high, pad_w_low, pad_w_high] for conv2d).

  • dilation – The spacing between kernel elements.

  • transposed – A bool value indicates whether perform ConvTranspose Op.

  • output_padding – Padding added to output shape, not currently enabled.

  • groups – Controls the connections between inputs and outputs, in_channels and out_channels must both be divisible by groups.

  • benchmark – A bool value, not currently enabled.

  • deterministic – A bool value, not currently enabled.

  • cudnn_enabled – A bool value, not currently enabled.

  • allow_tf32 – A bool value, not currently enabled.

  • stream – Tops stream.

Returns

topsatenStatus_t.

2.3. Aten vllm ops

This section describes topsaten aten vllm ops api definitions.

topsatenStatus_t TOPSATEN_EXPORT topsvllmRotaryEmbedding (topsatenTensor &query, topsatenTensor &key, const topsatenTensor &positions, const topsatenTensor &cos_sin_cache, int head_size, bool is_neox, topsStream_t stream=nullptr)

Rotary_embedding.

Parameters
  • query – The output/input tensor [num_tokens, num_heads * head_size] float32 float16.

  • key – The output/input tensor [num_tokens, num_kv_heads * head_size] float32 float16.

  • positions – Input tensor [num_tokens] int64.

  • cos_sin_cache – Input tensor [max_position, rot_dim] float32 float16.

  • head_size – Input scalar.

  • is_neox – Input scalar.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsvllmMemoryEfficientAttention (topsatenTensor &output, const topsatenTensor &query, const topsatenTensor &key, const topsatenTensor &value, const topsatenTensor &attn_bias, const topsatenScalar_t &dropout_p, const topsatenScalar_t &scale, topsStream_t stream=nullptr)

Multi query kv attention operator.

Parameters
  • output – The output tensor.

  • query – Input tensor query.

  • key – Input tensor key.

  • value – Input tensor value.

  • attn_bias – Attention mask.

  • dropout_p – Dropout probability.

  • scale – Input scale.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsvllmMemEfficientAttention (topsatenTensor &output, const topsatenTensor &query, const topsatenTensor &key, const topsatenTensor &value, const topsatenTensor &attn_bias, const topsatenScalar_t &dropout_p, const topsatenScalar_t &scale, const std::vector< int32_t > &seqlens, topsStream_t stream=nullptr)

Multi query kv attention operator.

Parameters
  • output – The output tensor.

  • query – Input tensor query.

  • key – Input tensor key.

  • value – Input tensor value.

  • attn_bias – Attention mask.

  • dropout_p – Dropout probability.

  • scale – Input scale.

  • seqlens – Input seqlens.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsvllmSiluAndMul (topsatenTensor &out, const topsatenTensor &in, topsStream_t stream=nullptr)

Silu and mul operator.

Parameters
  • out – The output tensor.

  • in – Input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsvllmGeluAndMul (topsatenTensor &out, const topsatenTensor &in, topsStream_t stream=nullptr)

Gelu and mul operator.

Parameters
  • out – The output tensor.

  • in – Input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsvllmGeluTanhAndMul (topsatenTensor &out, const topsatenTensor &in, topsStream_t stream=nullptr)

Gelu tanh and mul operator.

Parameters
  • out – The output tensor.

  • in – Input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsvllmGeluNew (topsatenTensor &out, const topsatenTensor &in, topsStream_t stream=nullptr)

Gelu new operator.

Parameters
  • out – The output tensor.

  • in – Input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsvllmGeluFast (topsatenTensor &out, const topsatenTensor &in, topsStream_t stream=nullptr)

Gelu fast operator.

Parameters
  • out – The output tensor.

  • in – Input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsvllmReshapeAndCache (topsatenTensor &key_cache, topsatenTensor &value_cache, const topsatenTensor &key, const topsatenTensor &value, const topsatenTensor &slot_mapping, topsStream_t stream=nullptr)

Reshape and cache operator.

Parameters
  • key_cache – The key cache tensor.

  • value_cache – The value cache tensor.

  • key – Key tensor.

  • value – Value tensor.

  • slot_mapping – Slot mapping tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsvllmPagedAttentionV1 (topsatenTensor &output, const topsatenTensor &query, const topsatenTensor &key_cache, const topsatenTensor &value_cache, const topsatenTensor &head_mapping, const topsatenScalar_t &scale, const topsatenTensor &block_tables, const topsatenTensor &context_lens, const topsatenScalar_t &block_size, const topsatenScalar_t &max_context_len, const topsatenTensor &alibi_slopes, topsStream_t stream=nullptr)

Paged attention v1 operator.

Parameters
  • output – The output tensor.

  • query – Input tensor query.

  • key_cache – Input tensor cached key.

  • value_cache – Input tensor cached value.

  • scale – Scale.

  • block_tables – Input tensor block table.

  • context_lens – Input tensor context len.

  • block_size – Block size.

  • max_context_len – Max length of context.

  • alibi_slopes – Input tensor alibi slopes.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsvllmContextAttentionForward (topsatenTensor &output, const topsatenTensor &query, const topsatenTensor &key, const topsatenTensor &value, const topsatenTensor &key_cache, const topsatenTensor &value_cache, const topsatenTensor &block_tables, const topsatenTensor &start_loc, const topsatenTensor &prompt_lens, const topsatenTensor &context_lens, const topsatenScalar_t &max_seq_len, const topsatenTensor &alibi_slopes, const topsatenScalar_t &sliding_window, topsStream_t stream=nullptr)

Context attention forward operator.

Parameters
  • output – The output tensor.

  • query – Input tensor query.

  • key – Input tensor key.

  • value – Input tensor value.

  • key_cache – Input tensor cached key.

  • value_cache – Input tensor cached value.

  • block_tables – Input tensor block tables.

  • start_loc – Input tensor start loc.

  • prompt_lens – Input tensor prompt lens.

  • context_lens – Input tensor context lens.

  • max_seq_len – Max length of sequence.

  • alibi_slopes – Input tensor alibi slopes.

  • sliding_window – Input tensor sliding window.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsvllmRmsNorm (topsatenTensor &output, const topsatenTensor &input, const topsatenTensor &weight, const topsatenScalar_t &epsilon, topsStream_t stream=nullptr)

Compute RMSNorm on the input.

Parameters
  • output – Output tensor of shape […, hidden_size].

  • input – Input tensor of shape […, hidden_size].

  • gamma – Gamma tensor of shape [hidden_size].

  • epsilon – Value added to denominator for numerical stability.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsvllmFusedAddRmsNorm (topsatenTensor &input, topsatenTensor &residual, const topsatenTensor &weight, float epsilon, topsStream_t stream=nullptr)

In-place fused Add and RMS Normalization.

Parameters
  • input – Input tensor of shape […, hidden_size].

  • residual – Residual tensor of shape […, hidden_size].

  • weight – Weight tensor of shape [hidden_size].

  • epsilon – Value added to denominator for numerical stability.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsvllmFusedAddRmsNorm (topsatenTensor &output, topsatenTensor &residual_update, const topsatenTensor &input, const topsatenTensor &residual, const topsatenTensor &weight, float epsilon, topsStream_t stream=nullptr)

Fused Add and RMS Normalization.

Parameters
  • output – Output tensor of shape […, hidden_size].

  • residual_update – Update residual tensor of shape […, hidden_size].

  • input – Input tensor of shape […, hidden_size].

  • residual – Residual tensor of shape […, hidden_size].

  • weight – Weight tensor of shape [hidden_size].

  • epsilon – Value added to denominator for numerical stability.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsvllmBgmv (topsatenTensor &output, const topsatenTensor &y, const topsatenTensor &x, const topsatenTensor &w, const topsatenTensor &indices, int layer_idx, float scale, topsStream_t stream=nullptr)

Bgmv.

Parameters
  • output – Shape: [B, H2]. Output vectors. Can be the same as y.

  • y – Shape: [B, H2]. Input y vectors.

  • x – Shape: [B, H1]. Input x vectors.

  • w – Shape: [None, L, H2, H1]. All of the transposed weight matrices.

  • indices – Shape: [B]. Indices of the weight matrices.

  • layer_idx – Layer index of the weight matrices.

  • scale – Scaling factor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsvllmBgmvLowLevel (topsatenTensor &output, const topsatenTensor &y, const topsatenTensor &x, const topsatenTensor &w, const topsatenTensor &indices, int layer_idx, float scale, int h_in, int h_out, int y_offset, topsStream_t stream=nullptr)

Bgmv low level.

Parameters
  • output – Shape: [B, H2]. Output vectors. Can be the same as y.

  • y – Shape: [B, H2]. Input y vectors.

  • x – Shape: [B, H1]. Input x vectors.

  • w – Shape: [None, L, H2, H1]. All of the transposed weight matrices.

  • indices – Shape: [B]. Indices of the weight matrices.

  • layer_idx – Layer index of the weight matrices.

  • scale – Scaling factor.

  • h_in – Size of the x column slice.

  • h_out – Size of the y column slice.

  • y_offset – Offset to apply to the starting column of y.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsvllmTopkSoftmax (topsatenTensor &topk_weights, topsatenTensor &topk_indices, topsatenTensor &token_expert_indices, const topsatenTensor &gating_output, topsStream_t stream=nullptr)

Topk softmax operator.

Parameters
  • topk_weights – The first K maximum weights for each sample. shape:[num_tokens, topk].

  • topk_indices – Index of the first K maximum weights corresponding to each sample. shape:[num_tokens, topk].

  • token_expert_indices – Expert index for each token in each sample shape:[num_tokens, topk].

  • gating_output – The output of the gating operation (before softmax), used to control the gate value of each expert output. shape: [num_tokens, num_experts].

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsvllmMoeAlignBlockSize (topsatenTensor &sorted_token_ids, topsatenTensor &experts_ids, topsatenTensor &num_tokens_post_pad, const topsatenTensor &topk_ids, int num_experts, int block_size, topsStream_t stream=nullptr)

Moe align block size.

Parameters
  • sorted_token_ids – Sorted token ndices according to their allocated expert. Max shape: [total_token*topk + topk*(block_size - 1)].

  • experts_ids – The assigned expert index for each block. Max shape: [total_token*topk + expert].

  • num_tokens_post_pad – Shape: [1]. Number of tokens after padding.

  • topk_ids – Shape: [total_tokens, topsk]. The top-k expert indices for each token.

  • num_experts – Number of experts.

  • block_size – Block size.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsvllmInvokeFusedMoeKernel (topsatenTensor &C, const topsatenTensor &A, const topsatenTensor &B, const topsatenTensor &topk_weights, const topsatenTensor &topk_ids, const topsatenTensor &sorted_token_ids, const topsatenTensor &experts_ids, const topsatenTensor &num_tokens_post_pad, bool mul_routed_weight, int topk, int block_size, topsStream_t stream=nullptr)

Invoke fused moe kernel.

Parameters
  • C – The output cache tensor with shape (M, topk, N), where M is the total number of tokens post padding, topk is the number of times each token is repeated, and N is the output feature dimension.

  • A – The input tensor representing tokens with shape (*, K), where ‘*’ can be any shape representing batches and K is the feature dimension of each token.

  • B – The stacked MOE weight tensor with shape (E, N, K), where E is the number of experts, K is the input feature dimension, and N is the output feature dimension.

  • topk_weights – The top-k expert weights for each token.

  • topk_ids – The top-k expert indices for each token.

  • sorted_token_ids – Sorted token indices according to their allocated expert.

  • experts_ids – The assigned expert index for each block.

  • num_tokens_post_pad – Shape: [1]. Number of tokens after padding.

  • mul_routed_weight – The flag used to indicate whether topk_weights participates in the calculation.

  • topk – Number of experts for each token.

  • block_size – Block size.

  • stream – Tops stream.

Returns

topsatenStatus_t.

2.4. Aten te ops

This section describes topsaten aten transform engine ops api definitions.

topsatenStatus_t TOPSATEN_EXPORT topsteScaledSoftmaxForward (topsatenTensor &out, const topsatenTensor &in, const topsatenScalar_t &scale, topsStream_t stream=nullptr)

Scaled softmax forward operator.

Parameters
  • out – The output tensor.

  • in – Input tensor.

  • scale – The multiplier for input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsteScaledMaskedSoftmaxForward (topsatenTensor &out, const topsatenTensor &in, const topsatenTensor &mask, const topsatenScalar_t &scale, topsStream_t stream=nullptr)

Scaled masked softmax forward operator.

Parameters
  • out – The output tensor.

  • in – Input tensor.

  • mask – Mask tensor.

  • scale – The multiplier for input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsteScaledUpperTriangMaskedSoftmaxForward (topsatenTensor &out, const topsatenTensor &in, const topsatenScalar_t &scale, topsStream_t stream=nullptr)

Scaled upper triang masked softmax forward operator.

Parameters
  • out – The output tensor.

  • in – Input tensor.

  • scale – The multiplier for input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsteLayerNormFwd (topsatenTensor &output, topsatenTensor &mean, topsatenTensor &rstd, const topsatenTensor &input, const topsatenTensor &gamma, const topsatenTensor &beta, const topsatenScalar_t &epsilon, topsStream_t stream=nullptr)

Compute LayerNorm on the input.

Parameters
  • output – Output tensor of shape [N, H].

  • mean – Mean of the input calculated over the last dimension. Shape: [N].

  • rstd – Inverse of the variance of the input calculated over the last dimension. Shape: [N].

  • input – Input tensor of shape [N, H].

  • gamma – Gamma tensor of shape [H].

  • beta – Beta tensor of shape [H].

  • epsilon – Value added to denominator for numerical stability.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsteBlasGemm (topsatenTensor &out, topsatenTensor &pre_gelu_out, const topsatenTensor &lhs, const topsatenTensor &rhs, const topsatenTensor &bias, const topsatenBlasOperation_t &transa, const topsatenBlasOperation_t &transb, const bool accumulate, const topsStream_t stream=nullptr)

Gemm operator.

Parameters
  • out – The output tensor.

  • pre_gelu_out – Output matrix before GELU activation.

  • lhs – The input tensor of lhs.

  • rhs – The input tensor of rhs.

  • bias – The input tensor of bias.

  • transa – Lhs transpose info.

  • transb – Rhs transpose info.

  • accumulate – Whether to accumulate the result.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsteRmsNormFwd (topsatenTensor &output, topsatenTensor &rstd, const topsatenTensor &input, const topsatenTensor &gamma, const topsatenScalar_t &epsilon, topsStream_t stream=nullptr)

Compute RMSNorm on the input.

Parameters
  • output – Output tensor of shape [N, H].

  • rstd – Reciprocal of the root mean square of the input calculated over the last dimension. Shape: [N].

  • input – Input tensor of shape [N, H].

  • gamma – Gamma tensor of shape [H].

  • epsilon – Value added to denominator for numerical stability.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsteGelu (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

Gelu operator.

Parameters
  • output – The output tensor.

  • input – The input tensor of lhs.

  • stream – Tops stream.

Returns

topsatenStatus_t.

2.5. Aten tf ops

This section describes topsaten aten tf ops api definitions.

topsatenStatus_t TOPSATEN_EXPORT topstfNorm (topsatenTensor &output, const topsatenTensor &input, const topsatenScalar_t &ord, const topsatenSize_t &axis, topsStream_t stream=nullptr)

This function computes the norm of vectors, matrices, and tensors.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • ord – Order of the norm.

  • axis – Determines the axis in tensor over which to compute the norm.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topstfNorm (topsatenTensor &output, const topsatenTensor &input, const char *ord, const topsatenSize_t &axis, topsStream_t stream=nullptr)

This function computes the norm of vectors, matrices, and tensors.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • ord – Order of the norm.

  • axis – Determines the axis in tensor over which to compute the norm.

  • stream – Tops stream.

Returns

topsatenStatus_t.

2.6. Aten xla ops

This section describes topsaten aten xla ops api definitions.

topsatenStatus_t TOPSATEN_EXPORT topsxlaGather (topsatenTensor &output, const topsatenTensor &operand, const topsatenTensor &start_indices, const topsatenSize_t &offset_dims, const topsatenSize_t &slice_sizes, const topsatenSize_t &collapsed_slice_dims, const topsatenSize_t &start_index_map, int64_t index_vector_dim, bool indices_are_sorted, bool unique_indices, topsStream_t stream)

This function performs the gather function.

Parameters
  • output – Gather result.

  • operand – The array we’re gathering from.

  • start_indices – Array containing the starting indices of the slices we gather.

  • offset_dims – The set of dimensions in the output shape that offset into an array sliced from operand.

  • slice_sizes – Slice_sizes[i] is the bounds for the slice on dimension i.

  • collapsed_slice_dims – The set of dimensions in each slice that are collapsed away. These dimensions must have size 1.

  • start_index_map – A map that describes how to map indices in start_indices to legal indices into operand.

  • index_vector_dim – The dimension in start_indices that “contains” the starting indices.

  • indices_are_sorted – Whether the indices are guaranteed to be sorted by the caller.

  • unique_indices – Whether the indices are guaranteed to be unique by the caller.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsxlaScatter (topsatenTensor &output, const topsatenTensor &operand, const topsatenTensor &indices, const topsatenTensor &updates, topsatenScatterComputationType_t computation, int64_t index_vector_dim, const topsatenSize_t &update_window_dims, const topsatenSize_t &inserted_window_dims, const topsatenSize_t &scatter_dims_to_operand_dims, bool indices_are_sorted, bool unique_indices, topsStream_t stream)

This function performs the scatter function.

Parameters
  • output – Scatter result.

  • operand – Array we’re scattering to.

  • indices – Array containing the starting indices of the slices that must be scattered to.

  • updates – Array containing the values that must be used for scattering operands.

  • computation – Computation to be used for combining the existing values in the input array and the updates during scatter.

  • index_vector_dim – The dimension in indices that contains the starting indices.

  • update_window_dims – The set of dimensions in updates shape that are window dimensions.

  • inserted_window_dims – The set of window dimensions that must be inserted into updates shape.

  • scatter_dims_to_operand_dims – A dimensions map from the scatter indices to the operand index space.

  • indices_are_sorted – Whether the indices are guaranteed to be sorted by the caller.

  • unique_indices – Whether the indices are guaranteed to be unique by the caller.

  • stream – Tops stream.

Returns

topsatenStatus_t.