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

enumerator TOPSATEN_ACTIVATION_GELU_TANH

TOPSATEN_ACTIVATION_GELU_TANH 12

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 topsatenFusionNormMode_t

Values:

enumerator TOPSTNNC_LAYERNORM

TOPSATEN_LAYERNORM 0

enumerator TOPSTNNC_RMSNORM

TOPSATEN_RMSNORM 1

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 verison info of the aten lib.

Returns

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. support datatype: bool,i/u8,i/u16,i/u32,fp32,tf32,fp16,bf16. support dim limit: < 2^24 for a single dim in input support buffer size: < 4.0 GB.

  • in – Input tensor. support datatype: bool,i/u8,i/u16,i/u32,fp32,tf32,fp16,bf16. support dim limit: < 2^24 for a single dim in input support buffer size: < 4.0 GB.

  • dim – The dimension in which to index.

  • index – The 1-D tensor containing the indices to index support datatype:i32/i64.

  • 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 topsatenAminmax (topsatenTensor &output_min, topsatenTensor &output_max, const topsatenTensor &input, topsStream_t stream=nullptr)

This function computes the minimum and maximum values of the input tensor.

Parameters
  • output_min – The output minimum tensor.

  • output_max – The output maximum tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenAminmax (topsatenTensor &output_min, topsatenTensor &output_max, const topsatenTensor &input, const int32_t dim, const bool keepdim, topsStream_t stream=nullptr)

This function computes the minimum and maximum values of the input tensor.

Parameters
  • output_min – The output minimum tensor.

  • output_max – The output maximum tensor.

  • input – The input tensor.

  • dim – The dimension along which to compute the values.

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

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenAminmax (topsatenTensor &output_min, topsatenTensor &output_max, const topsatenTensor &input, const topsatenSize_t &dims, const bool keepdim, topsStream_t stream=nullptr)

This function computes the minimum and maximum values of the input tensor.

Parameters
  • output_min – The output minimum tensor.

  • output_max – The output maximum tensor.

  • input – The input tensor.

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

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

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenAminmax (std::tuple< topsatenTensor &, topsatenTensor & > output, const topsatenTensor &input, const topsatenScalar_t &dim={TOPSATEN_DATA_NONE, {}}, const bool &keepdim=false, topsStream_t stream=nullptr)

This function computes the minimum and maximum values of the input tensor.

Parameters
  • output – A tuple (min, max) containing the output of min and max.

  • input – The input tensor.

  • dim – The dimension along which to compute the values. If None, computes the values over the entire input tensor. Default is None.

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

  • stream – Tops stream.

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 topsatenAmin (topsatenTensor &out, const topsatenTensor &self, const topsatenSize_t &dim, bool &keepdim, topsStream_t stream=nullptr)

Returns the minimum value of each slice of the input tensor in the given dimension(s) dim.

Parameters
  • out – The output tensor.

  • self – The input tensor.

  • dim – The dims to reduce.

  • keepdim – 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 topsatenFmin (topsatenTensor &out, const topsatenTensor &input, const topsatenTensor &other, topsStream_t stream=nullptr)

Computes the element-wise minimum of input and other.

Parameters
  • out – The output tensor.

  • input – The input tensor.

  • other – The second input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

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

Computes the element-wise maximum of input and other.

Parameters
  • out – The output tensor.

  • input – The input tensor.

  • other – The second input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

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

Return the next floating-point value after input towards other, elementwise.

Parameters
  • out – The output tensor.

  • input – The input tensor.

  • other – The second 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 topsatenLinearActivation (topsatenTensor &out, const topsatenTensor &lhs, const topsatenTensor &rhs, const topsatenTensor &bias, const topsatenActivationMode_t &activation_mode, const topsatenScalar_t &coef, topsStream_t stream=nullptr)

Linear activation operator.

Parameters
  • out – The output tensor.

  • lhs – The input tensor of lhs.

  • rhs – The input tensor of rhs.

  • bias – The input tensor of bias.

  • activation_mode – The activation_mode after linear.

  • coef – The coef for activation.

  • 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 topsatenLinearQuant (topsatenTensor &out, const topsatenTensor &lhs, const topsatenTensor &rhs, const topsatenTensor &bias, const topsatenTensor &scale, int group_size=-1, 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 topsatenLinearQuantActivation (topsatenTensor &out, const topsatenTensor &lhs, const topsatenTensor &rhs, const topsatenTensor &bias, const topsatenTensor &scale, const topsatenActivationMode_t &activation_mode, const topsatenScalar_t &coef, const topsStream_t stream=nullptr)

Linearquant activation 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.

  • activation_mode – The activation_mode after linearQuant.

  • coef – The coef for activation.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenLinearQuantActivation (topsatenTensor &out, const topsatenTensor &lhs, const topsatenTensor &rhs, const topsatenTensor &bias, const topsatenTensor &scale, const topsatenActivationMode_t &activation_mode, const topsatenScalar_t &coef, int group_size=-1, const topsStream_t stream=nullptr)

Linearquant activation 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.

  • activation_mode – The activation_mode after linearQuant.

  • coef – The coef for activation.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGemmQuant (topsatenTensor &out, const topsatenTensor &lhs, const topsatenTensor &rhs, const topsatenTensor &scale, const topsatenTensor &zeros, const topsatenTensor &bias, int group_size, topsStream_t stream=nullptr)

Gemm operator.

Parameters
  • out – The output tensor.

  • lhs – The input tensor of lhs.

  • rhs – The input tensor of rhs.

  • scale – The input tensor of scale.

  • zeros – The input tensor of zeros.

  • bias – The input tensor of bias.

  • stream – Tops stream.

Returns

topsatenStatus_t.

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

Dotbiasquant operator.

Parameters
  • out – The output tensor.

  • lhs – The input tensor of lhs.

  • rhs – The input tensor of rhs.

  • scale – The input tensor of scale.

  • bias – The input tensor of bias.

  • 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 topsatenRandperm (topsatenTensor &output, const int64_t n, topsStream_t stream=nullptr)

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

Parameters
  • output – Output tensor.

  • n – The upper bound.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenRandperm (topsatenTensor &output, const int64_t n, 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.

  • 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 topsatenBaddbmmActivation (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}}, const topsatenActivationMode_t &activation_mode=TOPSATEN_ACTIVATION_NONE, const topsatenScalar_t &coef={TOPSATEN_DATA_FP32, {1.0}}, topsStream_t stream=nullptr)

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

  • activation_mode – The activation_mode after Baddbmm.

  • coef – The coef for activation.

  • 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, 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, 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 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 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 topsatenLogicalXor (topsatenTensor &output, const topsatenTensor &lhs, const topsatenScalar_t &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 scalar to compute XOR with.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenLogicalXor (topsatenTensor &output, const topsatenScalar_t &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 scalar.

  • 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 topsatenLogicalAnd (topsatenTensor &output, const topsatenTensor &lhs, const topsatenScalar_t &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 scalar to compute AND with.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenLogicalAnd (topsatenTensor &output, const topsatenScalar_t &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 scalar.

  • 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 topsatenLogicalOr (topsatenTensor &output, const topsatenTensor &lhs, const topsatenScalar_t &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 scalar to compute OR with.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenLogicalOr (topsatenTensor &output, const topsatenScalar_t &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 scalar.

  • 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 topsatenMatmulActivation (topsatenTensor &out, const topsatenTensor &lhs, const topsatenTensor &rhs, const topsatenActivationMode_t &activation_mode, const topsatenScalar_t &coef, topsStream_t stream=nullptr)

Matmul activation operator.

Parameters
  • out – The output tensor.

  • lhs – The input tensor of lhs.

  • rhs – The input tensor of rhs.

  • activation_mode – The activation_mode after matmul.

  • coef – The coef for activation.

  • 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 topsatenAddmmActivation (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}}, const topsatenActivationMode_t &activation_mode=TOPSATEN_ACTIVATION_NONE, const topsatenScalar_t &coef={TOPSATEN_DATA_FP32, {1.0}}, topsStream_t stream=nullptr)

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

  • activation_mode – The activation_mode after Addmm.

  • coef – The coef for activation.

  • 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 topsatenNativeDropout (topsatenTensor &output, topsatenTensor &mask, const topsatenTensor &input, double p, topsatenScalar_t 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 &grad_input, const topsatenTensor &grad_output, const topsatenScalar_t &alpha, const topsatenScalar_t &scale, const topsatenScalar_t &input_scale, const bool &is_result, const topsatenTensor &self_or_result, topsStream_t stream=nullptr)

This function performs the elu backward function. a: grad_output, b: self_or_result is_result == True : b <= 0 ? a * input_scale * (b + alpha * scale) : a * scale; is_result == False : b <= 0 ? a * input_scale * alpha * scale * std::exp(b * input_scale) : a * scale;.

Parameters
  • grad_input – Elu backward result.

  • grad_output – 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.

  • self_or_result – The source tensor.

  • 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 topsatenNllLossForward (std::tuple< topsatenTensor &, topsatenTensor & > outputs, 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
  • outputs – A tuple (output, total_weight) containing the output (the output tensor) and 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 topsatenNllLoss2dForward (std::tuple< topsatenTensor &, topsatenTensor & > outputs, 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
  • outputs – A tuple (output, total_weight) containing the output (the output tensor) and 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 shape(batch, o_seq_len, o_heads, head_size).

  • query – Input tensor query shape(batch, q_seq_len, q_heads, head_size).

  • key – Input tensor key shape(batch, k_seq_len, k_heads, head_size).

  • value – Input tensor value shape(batch, v_seq_len, v_heads, head_size).

  • attn_mask – Attention mask shape(batch, q_heads, q_seq_len, k_seq_len); or shape(q_seq_len, k_seq_len) should expand to (1, 1, q_seq_len, k_seq_len); or shape(k_seq_len) should expand to (1, 1, 1, k_seq_len).

  • dropout_p – Dropout probability.

  • is_causal – If true, assumes causal attention masking.

  • scale – Scale value(1/sqrt(head_size).

  • 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 shape(batch, o_seq_len, o_heads, head_size).

  • logsumexp – The output tensor.

  • seed – The output tensor.

  • offset – The last output tensor in output tuple.

  • query – Input tensor query shape(batch, q_seq_len, q_heads, head_size).

  • key – Input tensor key shape(batch, k_seq_len, k_heads, head_size).

  • value – Input tensor value shape(batch, v_seq_len, v_heads, head_size).

  • attn_mask – Attention mask shape(batch, q_heads, q_seq_len, k_seq_len); or shape(q_seq_len, k_seq_len) should expand to (1, 1, q_seq_len, k_seq_len);.

  • compute_log_sumexp – Whether compute log mask.

  • dropout_p – Dropout probability.

  • is_causal – If true, assumes causal attention masking.

  • scale – Scale value(1/sqrt(head_size).

  • 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 shape(batch, o_seq_len, o_heads, head_size).

  • 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 shape(batch, q_seq_len, q_heads, head_size).

  • key – Input tensor key shape(batch, k_seq_len, k_heads, head_size).

  • value – Input tensor value shape(batch, v_seq_len, v_heads, head_size).

  • dropout_p – Dropout probability.

  • is_causal – If true, assumes causal attention masking.

  • return_debug_mask – Whether return debug mask.

  • scale – Scale value(1/sqrt(head_size).

  • 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 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. Now Support: Interconversion: TOPSOP_DATA_FP32, TOPSOP_DATA_FP16, TOPSOP_DATA_BF16, TOPSOP_DATA_I8, TOPSOP_DATA_I16, TOPSOP_DATA_I32, TOPSOP_DATA_PRED, TOPSOP_DATA_U8, TOPSOP_DATA_U16, TOPSOP_DATA_U32 In addition: TOPSOP_DATA_I64<->TOPSOP_DATA_I32.

  • non_blocking – If true and this copy is between CPU and GCU.(Not enable, default is false).

  • copy – Whether to create a new tensor.(Not enable, default is false).

  • format – The memory format of the output tensor.(Not enable, default is TOPSOP_MEMORY_PRESERVE).

  • 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 topsatenSinc (topsatenTensor &output, const topsatenTensor &input, topsStream_t stream=nullptr)

Computes the normalized sinc of input.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

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

Tests if each element of input has its sign bit set or not.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

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

Tests if each element of input is positive infinity or not.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

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

Tests if each element of input is negative infinity or not.

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 topsatenLogsumexp (topsatenTensor &output, const topsatenTensor &input, const topsatenSize_t &dim, const bool &keepdim=false, topsStream_t stream=nullptr)

Returns the log of summed exponentials of each row of the input tensor in the given dimension dim. The computation is numerically stabilized.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • dim – The dimension or dimensions to reduce. If None, all dimensions are reduced.

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

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenLogcumsumexp (topsatenTensor &out, const topsatenTensor &self, const int64_t &dim, topsStream_t stream=nullptr)

Returns the logarithm of the cumulative summation of the exponentiation of elements of input in the dimension dim.

Parameters
  • out – The output tensor.

  • self – The input tensor.

  • dim – The dimension to do the operation over.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenNanmean (topsatenTensor &output, const topsatenTensor &input, const topsatenSize_t &dim, const bool &keepdim=false, const topsatenDataType_t &dtype=TOPSATEN_DATA_NONE, topsStream_t stream=nullptr)

Computes the mean of all non-NaN elements along the specified dimensions.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • dim – The dimension or dimensions to reduce. If None, all dimensions are reduced.

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

  • dtype – The desired data type of returned tensor.

  • 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 topsatenForeachExp (std::vector< topsatenTensor > &output, const std::vector< topsatenTensor > &input, topsStream_t stream=nullptr)

Foreach exp operator.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

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

Foreach abs operator.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

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

Foreach acos operator.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

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

Foreach asin operator.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

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

Foreach atan operator.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

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

Foreach ceil operator.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

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

Foreach cos operator.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

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

Foreach cosh operator.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

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

Foreach expm1 operator.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

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

Foreach floor operator.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

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

Foreach log operator.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

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

Foreach log10 operator.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

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

Foreach log1p operator.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

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

Foreach log2 operator.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

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

Foreach neg operator.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

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

Foreach tan operator.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

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

Foreach tanh operator.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

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

Foreach sin operator.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

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

Foreach sinh operator.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

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

Foreach round operator.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

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

Foreach reciprocal operator.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

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

Foreach sigmoid operator.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

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

Foreach trunc operator.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

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

Foreach zero operator.

Parameters
  • output – The output tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

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

Foreach erf operator.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

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

Foreach lgamma operator.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

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

Foreach frac operator.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

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

Foreach erfc operator.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

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

Foreach pow operator.

Parameters
  • out – The output tensor.

  • lhs – Input lhs tensor.

  • rhs – Input rhs scalar.

  • stream – Tops stream.

Returns

topsatenStatus_t.

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

Foreach pow operator.

Parameters
  • out – The output tensor.

  • lhs – Input lhs tensor.

  • rhs – Input rhs tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

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

Foreach pow operator.

Parameters
  • out – The output tensor.

  • lhs – Input lhs tensor.

  • rhs – Input rhs scalar.

  • stream – Tops stream.

Returns

topsatenStatus_t.

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

Foreach pow 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 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 topsatenNativeLayerNormQuant (topsatenTensor &output, topsatenTensor &mean, topsatenTensor &rstd, const topsatenTensor &input, const topsatenTensor &scaling, 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 quant.

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.

  • scaling – Scaling tensor.

  • 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 topsatenNativeLayerNormBackward (std::tuple< topsatenTensor &, topsatenTensor &, topsatenTensor & > output, const topsatenTensor &grad_out, const topsatenTensor &input, const topsatenSize_t &normalized_shape, const topsatenTensor &mean, const topsatenTensor &rstd, const topsatenTensor &weight, const topsatenTensor &bias, const std::array< bool, 3 > output_mask, topsStream_t stream=nullptr)

This function performs the backward layer normalization.

This function calculates the gradient of the loss with respect to the input tensor.

Parameters
  • output[out] – The computed x/scale/beta gradient of the loss with respect to the input tensor.

  • grad_out[in] – Gradient of input tensor.

  • input[in] – The input tensor.

  • normalized_shape[in] – Input shape from an expected input of size.

  • mean[in] – Mean of input.

  • rstd[in] – Rstd of input.

  • weight[in] – Weight tensor.

  • bias[in] – Bias tensor.

  • output_mask[in] – Mask of output.

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

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 topsatenNativeGroupNormQuant (topsatenTensor &output, topsatenTensor &mean, topsatenTensor &rstd, const topsatenTensor &input, const topsatenTensor &scaling, 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 quant.

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.

  • scaling – Scaling tensor.

  • 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 topsatenNormalize (topsatenTensor &output, const topsatenTensor &input, const float p, const topsatenSize_t &dim, const float eps=1e-12, topsStream_t stream=nullptr)

This function Perform Lp normalization of inputs over specified dimension.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • p – The exponent value in the norm formulation.

  • dim – The dimension to reduce.

  • eps – Small value to avoid division by zero.

  • 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 topsatenQuantile (topsatenTensor &out, const topsatenTensor &self, double &q, const topsatenScalar_t &dim={TOPSATEN_DATA_NONE, {}}, const bool &keepdim=false, const char *interpolation="linear", topsStream_t stream=nullptr)

Computes the q-th quantiles of each row of the input tensor along the dimension dim.

Parameters
  • out – The output tensor.

  • self – The input tensor.

  • q – A scalar of values in the range [0, 1].

  • dim – The dimension to reduce.

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

  • interpolation – Interpolation method to use when the desired quantile lies between two data points. Can be linear, lower, higher, midpoint and nearest. Default is linear.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenQuantile (topsatenTensor &out, const topsatenTensor &self, const topsatenTensor &q, const topsatenScalar_t &dim={TOPSATEN_DATA_NONE, {}}, const bool &keepdim=false, const char *interpolation="linear", topsStream_t stream=nullptr)

Computes the q-th quantiles of each row of the input tensor along the dimension dim.

Parameters
  • out – The output tensor.

  • self – The input tensor.

  • q – A 1-d tensor of values in the range [0, 1].

  • dim – The dimension to reduce.

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

  • interpolation – Interpolation method to use when the desired quantile lies between two data points. Can be linear, lower, higher, midpoint and nearest. Default is linear.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenNanquantile (topsatenTensor &out, const topsatenTensor &self, double &q, const topsatenScalar_t &dim={TOPSATEN_DATA_NONE, {}}, const bool &keepdim=false, const char *interpolation="linear", topsStream_t stream=nullptr)

Computes the q-th quantiles of each row of the input tensor along the dimension dim, “ignores” NaN values.

Parameters
  • out – The output tensor.

  • self – The input tensor.

  • q – A scalar of values in the range [0, 1].

  • dim – The dimension to reduce.

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

  • interpolation – Interpolation method to use when the desired quantile lies between two data points. Can be linear, lower, higher, midpoint and nearest. Default is linear.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenNanquantile (topsatenTensor &out, const topsatenTensor &self, const topsatenTensor &q, const topsatenScalar_t &dim={TOPSATEN_DATA_NONE, {}}, const bool &keepdim=false, const char *interpolation="linear", topsStream_t stream=nullptr)

Computes the q-th quantiles of each row of the input tensor along the dimension dim, “ignores” NaN values.

Parameters
  • out – The output tensor.

  • self – The input tensor.

  • q – A 1-d tensor of values in the range [0, 1].

  • dim – The dimension to reduce.

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

  • interpolation – Interpolation method to use when the desired quantile lies between two data points. Can be linear, lower, higher, midpoint and nearest. Default is linear.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenMedian (topsatenTensor &values, const topsatenTensor &in, topsStream_t stream=nullptr)

Returns the median of the values in input.

Parameters
  • values – Median values.

  • in – The source tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenMedian (topsatenTensor &values, topsatenTensor &indices, const topsatenTensor &in, const int64_t &dim, const bool &keepdim=false, topsStream_t stream=nullptr)

Returns the median of the values in input.

Parameters
  • values – Median values.

  • indices – Indices in the dimension dim of input.

  • in – The source tensor.

  • dim – The axis along which to index.

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

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenNanmedian (topsatenTensor &values, const topsatenTensor &in, topsStream_t stream=nullptr)

Returns the median of the values in input, ignoring NaN values.

Parameters
  • values – Median values.

  • in – The source tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenNanmedian (topsatenTensor &values, topsatenTensor &indices, const topsatenTensor &in, const int64_t &dim, const bool &keepdim=false, topsStream_t stream=nullptr)

Returns the median of the values in input, ignoring NaN values.

Parameters
  • values – Median values.

  • indices – Indices in the dimension dim of input.

  • in – The source tensor.

  • dim – The axis along which to index.

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

  • 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 topsatenVarMean (std::tuple< topsatenTensor &, topsatenTensor & > output, const topsatenTensor &input, const topsatenSize_t &dim, const topsatenScalar_t &correction, const bool &keepdim=false, topsStream_t stream=nullptr)

This function return the variance and mean over the dimensions specified by dim.

Parameters
  • output – A tuple (var, mean) containing the variance and mean.

  • 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 topsatenUpsampleTrilinear3d (topsatenTensor &output, const topsatenTensor &input, const topsatenSize_t &output_size, bool align_corners, const topsatenScalar_t &scales_d, const topsatenScalar_t &scales_h, const topsatenScalar_t &scales_w, topsStream_t stream)

This function performs 3D Trilinear upsampling on a multi-channel input signal. You can define the scale using either the output size (d, h, w) or a scaling factor (scale_factor).

Parameters
  • output – The out tensor.

  • input – The input tensor.

  • output_size – The size of the output tensor.

  • align_corners – If True, the corner pixels of the input and output tensors are aligned.

  • scales_d – The topsopScalar_t of scales_d.

  • scales_h – Multiplier for spatial size.

  • scales_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
  • input – A one-element float tensor containing the scale value.

  • output – The output tensor.

  • 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, const topsatenTensor &LU, const topsatenTensor &pivots, const 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 topsatenAdaptiveAvgPool2d (topsatenTensor &output, const topsatenTensor &input, const topsatenSize_t &output_size, topsStream_t stream=nullptr)
Parameters
  • output – : The output tensor. Shape: [N, C, H, W], support: uint8, int16, fp16, bf16, int32, uint32, fp32

  • input – : The input tensor. Shape: [N, C, H, W], support: uint8, int16, fp16, bf16, int32, uint32, fp32

  • output_size – : size of the output plane. Can be a single number or a tuple (kH, kW).

  • 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, const topsatenScalar_t &min, const 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 vector of tensors 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 topsatenLstmCell (std::tuple< topsatenTensor &, 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 tuple of tensors 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.

topsatenStatus_t TOPSATEN_EXPORT topsatenDSplit (std::vector< topsatenTensor > &out, const topsatenTensor input, const int64_t size, topsStream_t stream=nullptr)

Split an array into multiple sub-arrays along dim = 2.

Parameters
  • out – The output chunks.

  • input – The input tensor.

  • size – The size of a single chunk or list of sizes for each chunk.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenDSplit (std::vector< topsatenTensor > &out, const topsatenTensor input, const topsatenSize_t offsets, topsStream_t stream=nullptr)

Split an array into multiple sub-arrays along dim = 2.

Parameters
  • out – The output chunks.

  • input – The input tensor.

  • size – The size of a single chunk or list of sizes for each chunk.

  • stream – Tops stream.

Returns

topsatenStatus_t.

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

Flip tensor in the up/down direction, returning a new tensor.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenKlDiv (topsatenTensor &output, const topsatenTensor &input, const topsatenTensor &target, int64_t reduction, bool log_target, topsStream_t stream)

This function computes the KL-divergence.

Parameters
  • output – The output tensor.

  • inputs – The input tensors.

  • targets – The target tensors.

  • reduction – Parameter to specify which reduction operation should be performed.

  • log_target – Flag indicating whether target is passed in the log space.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenKthvalue (std::tuple< topsatenTensor, topsatenTensor > &output, const topsatenTensor &input, const int64_t k, const int64_t dim, const bool keepdim, topsStream_t stream=nullptr)

Returns a namedtuple (values, indices) where values is the k th smallest element of each row of the input tensor in the given dimension dim. And indices is the index location of each element found.

Parameters
  • output – The tuple of tensors containing the output and index tensors.

  • input – The tensor containing input.

  • k – The k-th smallest element.

  • dim – The dimension to find the kth value along.

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

  • stream – Tops stream.

Returns

topsatenStatus_t.

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

Computes the complementary error function of input.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenIsin (topsatenTensor &output, const topsatenTensor &elements, const topsatenTensor &test_elements, bool assume_unique, bool invert, topsStream_t stream=nullptr)

Tests if each element of elements is in test_elements.

Parameters
  • output – The output tensor.

  • elements – The input tensor.

  • test_elements – Values against which to test for each input element.

  • assume_unique – If True, assumes both elements and test_elements contain unique elements.

  • invert – If True, inverts the boolean return tensor, resulting in True values for elements not in test_elements. Default: False.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenIsin (topsatenTensor &output, const topsatenTensor &elements, const topsatenScalar_t &test_element, bool assume_unique, bool invert, topsStream_t stream=nullptr)

Tests if each element of elements is in test_elements.

Parameters
  • output – The output tensor.

  • elements – The input tensor.

  • test_elements – Values against which to test for each input element.

  • assume_unique – If True, assumes both elements and test_elements contain unique elements.

  • invert – If True, inverts the boolean return tensor, resulting in True values for elements not in test_elements. Default: False.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenIsin (topsatenTensor &output, const topsatenScalar_t &element, const topsatenTensor &test_elements, bool assume_unique, bool invert, topsStream_t stream=nullptr)

Tests if each element of elements is in test_elements.

Parameters
  • output – The output tensor.

  • element – The Scalar input.

  • test_elements – Values against which to test for each input element.

  • assume_unique – If True, assumes both elements and test_elements contain unique elements.

  • invert – If True, inverts the boolean return tensor, resulting in True values for elements not in test_elements. Default: False.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenSmoothL1Loss (topsatenTensor &output, const topsatenTensor &input, const topsatenTensor &target, int64_t reduction, double beta, topsStream_t stream=nullptr)

This function creates a criterion that uses a squared term if the absolute element-wise error falls below beta and an L1 term otherwise.

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.

  • beta – Specifies the threshold at which to change between L1 and L2 loss.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenMultiMarginLossBackward (topsatenTensor &grad_input, const topsatenTensor &grad_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 gradient of the multi-margin loss function with respect to the input tensor.

Parameters
  • grad_output – The gradient of the loss with respect to the output of the multi-margin loss.

  • 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 topsatenRot90 (topsatenTensor &output, const topsatenTensor &input, int64_t k, const topsatenSize_t &dims, topsStream_t stream=nullptr)

Rotate an n-D tensor by 90 degrees in the plane specified by dims axis.

Parameters
  • output – The output tensor.

  • inputs – The input tensors.

  • k – Number of times to rotate.

  • dims – Given axis, along which rotation is applied.

  • stream – Tops stream.

Returns

topsatenStatus_t.

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

Creates a block diagonal matrix from provided tensors.

Parameters
  • output – The output tensor.

  • input – The vector of input tensors.

  • stream – Tops stream.

Returns

topsatenStatus_t.

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

Stack tensors in sequence horizontally (column wise).

Parameters
  • output – The output tensor.

  • inputs – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenOneHot (topsatenTensor &output, const topsatenTensor &input, int64_t num_classes, topsStream_t stream=nullptr)

Calculate a tensor that has one more dimension with 1 values at the index of last dimension indicated by the input, and 0 everywhere else.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • num_classes – Total number of classes.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenHuberLoss (topsatenTensor &output, const topsatenTensor &input, const topsatenTensor &target, int64_t reduction, double delta, topsStream_t stream=nullptr)

This function creates a criterion that uses a squared term if the absolute element-wise error falls below delta and a delta-scaled L1 term otherwise.

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.

  • delta – Specifies the threshold at which to change between delta-scaled L1 and L2 loss.

  • stream – Tops stream.

Returns

topsatenStatus_t.

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

Stack tensors in sequence depthwise (along third axis).

Parameters
  • output – The output tensor.

  • inputs – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

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

Stack tensors in sequence vertically (row wise).

Parameters
  • output – The output tensor.

  • inputs – The input tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

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

Returns a tensor of the same size as input with each element sampled from a Bernoulli distribution.

Parameters
  • output – The output tensor.

  • self – The input tensor of probability values for the Bernoulli distribution.

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

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenBernoulli_ (topsatenTensor &self, const topsatenTensor &p, const topsatenGenerator_t &generator, topsStream_t stream=nullptr)

Returns a tensor of the same size as input with each element sampled from a Bernoulli distribution.

Parameters
  • self – The inplace tensor.

  • p – The input tensor of probability values for the Bernoulli distribution.

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

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenBernoulli (topsatenTensor &self, const double p, const topsatenGenerator_t &generator, topsStream_t stream=nullptr)

Returns a tensor of the same size as input with each element sampled from a Bernoulli distribution.

Parameters
  • self – The inplace tensor.

  • p – The input probability value for the Bernoulli distribution.

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

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenSoftMarginLoss (topsatenTensor &output, const topsatenTensor &input, const topsatenTensor &target, int64_t reduction, topsStream_t stream=nullptr)

This function creates a criterion that optimizes a two-class classification logistic loss between input tensor x and target tensor y.

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 topsatenMseLossBackward (topsatenTensor &grad_input, const topsatenTensor &grad_output, const topsatenTensor &input, const topsatenTensor &target, int64_t reduction, topsStream_t stream=nullptr)

Creates a criterion that measures the mean squared error (squared L2 norm) between each element in the input and target.

Parameters
  • grad_input – The gradient of the loss with respect to the output of the mse_loss_backward.

  • grad_output – The grad_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 mean of the output is taken, ‘sum’: the output will be summed.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenCtcLoss (topsatenTensor &output, const topsatenTensor &log_probs, const topsatenTensor &targets, const topsatenTensor &input_lengths, const topsatenTensor &target_lengths, const int64_t blank, const int64_t reduction, const bool zero_infinity, topsStream_t stream=nullptr)

This function computes loss between a continuous (unsegmented) time series and a target sequence.

Parameters
  • output – - The output tensor.

  • out_log_alpha – - Optional, out log alpha tensor.

  • log_probs – - The logarithmized probabilities.

  • targets – - It represent the target sequences.

  • input_lengths – - It represent the lengths of the inputs.

  • target_lengths – - It represent lengths of the targets.

  • blank – - blank label. Default 0.

  • reduction – - Optional, default is ‘none’ 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.

  • zero_infinity – - Whether to zero infinite losses.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenCtcLoss (topsatenTensor &output, const topsatenTensor &log_probs, const topsatenTensor &targets, const topsatenSize_t &input_lengths, const topsatenSize_t &target_lengths, const int64_t blank, const int64_t reduction, const bool zero_infinity, topsStream_t stream=nullptr)
topsatenStatus_t TOPSATEN_EXPORT topsatenCtcLoss (topsatenTensor &output, topsatenTensor &out_log_alpha, const topsatenTensor &log_probs, const topsatenTensor &targets, const topsatenTensor &input_lengths, const topsatenTensor &target_lengths, const int64_t blank, const bool zero_infinity, topsStream_t stream=nullptr)
topsatenStatus_t TOPSATEN_EXPORT topsatenCtcLoss (topsatenTensor &output, topsatenTensor &out_log_alpha, const topsatenTensor &log_probs, const topsatenTensor &targets, const topsatenSize_t &input_lengths, const topsatenSize_t &target_lengths, const int64_t blank, const bool zero_infinity, topsStream_t stream=nullptr)
topsatenStatus_t TOPSATEN_EXPORT topsatenCtcLossBackward (topsatenTensor &output, const topsatenTensor &grad_out, const topsatenTensor &log_probs, const topsatenTensor &targets, const topsatenTensor &input_lengths, const topsatenTensor &target_lengths, const topsatenTensor &neg_log_likelihood, const topsatenTensor &log_alpha, const int64_t blank, const bool zero_infinity, topsStream_t stream=nullptr)

This function computes loss between a continuous (unsegmented) time series and a target sequence.

Parameters
  • output – - The output tensor.

  • grad_out – - The grad tensor [bs].

  • log_probs – - The logarithmized probabilities.

  • targets – - It represent the target sequences.

  • input_lengths – - It represent the lengths of the inputs.

  • target_lengths – - It represent lengths of the targets.

  • neg_log_likelihood – - The negative log likelihood loss tensor.

  • log_alpha – - The log alpha tensor.

  • blank – - blank label. Default 0.

  • zero_infinity – - Whether to zero infinite losses.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenCtcLossBackward (topsatenTensor &output, const topsatenTensor &grad_out, const topsatenTensor &log_probs, const topsatenTensor &targets, const topsatenSize_t &input_lengths, const topsatenSize_t &target_lengths, const topsatenTensor &neg_log_likelihood, const topsatenTensor &log_alpha, const int64_t blank, const bool zero_infinity, topsStream_t stream=nullptr)

This function computes loss between a continuous (unsegmented) time series and a target sequence.

Parameters
  • output – - The output tensor.

  • grad_out – - The grad tensor [bs].

  • log_probs – - The logarithmized probabilities.

  • targets – - It represent the target sequences.

  • input_lengths – - It represent the lengths of the inputs.

  • target_lengths – - It represent lengths of the targets.

  • neg_log_likelihood – - The negative log likelihood loss tensor.

  • log_alpha – - The log alpha tensor.

  • blank – - blank label. Default 0.

  • zero_infinity – - Whether to zero infinite losses.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenLogSoftmaxBackwardData (topsatenTensor &result, const topsatenTensor &grad_output, const topsatenTensor &output, const int64_t &dim, const topsatenDataType_t &input_dtype, topsStream_t stream=nullptr)

Computes the gradient of the LogSoftmax loss function with respect to the output tensor.

Parameters
  • grad_output – The gradient of the loss with respect to the output of the LogSoftmax loss.

  • output – The output of LogSoftmaxForward.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenSliceBackward (topsatenTensor &result, const topsatenTensor &grad_output, const topsatenSize_t &input_sizes, const int64_t &dim, const int64_t &start, const int64_t &end, const int64_t &step, topsStream_t stream=nullptr)

Computes the gradient of a tensor operation where a slice of the input tensor is taken.

Parameters
  • output – The output tensor.

  • grad_output – This is the gradient of the output tensor.

  • input_sizes – This specifies the size (dimensions) of the original input tensor before slicing.

  • dim – Specifies the dimension along which slicing was performed.

  • start – Starting index of the slice.

  • step – Step size for the slice operation.

  • end – Ending index of the slice (exclusive).

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenSiluBackward (topsatenTensor &result, const topsatenTensor &grad_output, const topsatenTensor &self, const topsatenTensor &grad_input, topsStream_t stream=nullptr)
topsatenStatus_t TOPSATEN_EXPORT topsatenSoftmaxBackwardData (topsatenTensor &result, const topsatenTensor &grad_output, const topsatenTensor &output, const int64_t &dim, const topsatenDataType_t &input_dtype, topsStream_t stream=nullptr)

This function performs backward propagation on the softmax function.

Parameters
  • grad_input – The grad_input is the resultant tensor.

  • grad_output – The grad_output is input tensor.

  • output – The output is softmax output tensor taken as input for backward.

  • dim – The dimension to calculate backward.

  • input_dtype – The input tensor dtype.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenIndexSelectBackward (topsatenTensor &result, const topsatenTensor &grad, const topsatenSize_t &self_sizes, const int64_t &dim, const topsatenTensor &index, topsStream_t stream=nullptr)

This function performs backward Index Select operation.

Parameters
  • result – The output tensor.

  • grad – The input tensor.

  • split_sizes – The output shape.

  • dim – The dimension for which we index.

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

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenEmbeddingBackward (topsatenTensor &result, const topsatenTensor &grad, const topsatenTensor &indices, const int64_t &num_weights, const int64_t &padding_idx, const bool &scale_grad_by_freq, const bool &sparse, topsStream_t stream=nullptr)

Computes the gradient of a tensor operation that looks up embeddings in a fixed dictionary and size.

Parameters
  • result – The output tensor.

  • grad – This is the gradient of the output tensor.

  • indices – Tensor containing indices into the embedding matrix.

  • num_weights – Number of rows in result tensor.

  • padding_idx – Index which do not contribute to the gradient.

  • scale_grad_by_freq – If true, this will scale gradients by the inverse of frequency of the words in the mini-batch.

  • sparse – If True, gradient w.r.t. weight will be a sparse tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenIsPinned (bool &result, const topsatenTensor &self, topsStream_t stream=nullptr)
topsatenStatus_t TOPSATEN_EXPORT topsatenScaledDotProductFlashAttentionBackward (topsatenTensor &result, const topsatenTensor &grad_out, const topsatenTensor &query, const topsatenTensor &key, const topsatenTensor &value, const topsatenTensor &out, const topsatenTensor &logsumexp, const topsatenTensor &cum_seq_q, const topsatenTensor &cum_seq_k, const int64_t &max_q, const int64_t &max_k, const double &dropout_p, const bool &is_causal, const topsatenTensor &philox_seed, const topsatenTensor &philox_offset, const topsatenScalar_t &scale, topsStream_t stream=nullptr)
topsatenStatus_t TOPSATEN_EXPORT topsatenIgammac (topsatenTensor &output, const topsatenTensor &a, const topsatenTensor &x, topsStream_t stream=nullptr)

Computes the regularized upper incomplete gamma function.

Parameters
  • output – The output pointer.

  • a – The a pointer.

  • x – The x pointer.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenIgamma (topsatenTensor &output, const topsatenTensor &a, const topsatenTensor &x, topsStream_t stream=nullptr)

Computes the regularized lower incomplete gamma function.

Parameters
  • output – The output pointer.

  • a – The a pointer.

  • x – The x pointer.

  • stream – Tops stream.

Returns

topsatenStatus_t.

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

Computes QR decomposition using householder transformations.

Parameters
  • output – The tuple of tensors containing the compressed QR and Tau tensors.

  • input – The tensor containing input.

  • stream – Tops stream.

Returns

topsatenStatus_t.

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

Computes the first n columns of a product of Householder matrices.

Parameters
  • output – The output tensor.

  • input – The input tensors.

  • tau – Elementary reflector tensors.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenOrmqr (topsatenTensor &output, const topsatenTensor &input, const topsatenTensor &tau, const topsatenTensor &other, bool left, bool transpose, topsStream_t stream=nullptr)

Computes the matrix-matrix multiplication of a product of Householder matrices with a general matrix.

Parameters
  • output – The output tensor.

  • input – The input tensors.

  • tau – Elementary reflector tensors.

  • other – Tensor.

  • left – Controls the order of multiplication.

  • transpose – Controls whether the matrix Q is conjugate transpose or not.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenLinalgQr (std::tuple< topsatenTensor &, topsatenTensor & > output, const topsatenTensor &input, const char *mode, topsStream_t stream=nullptr)

Computes the QR decomposition of a matrix.

Parameters
  • output – The tuple of tensors containing the Q and R tensors.

  • input – The tensor containing input.

  • mode – A string that controls the shape of the output tensors. Can be one of ‘reduced’, ‘complete’, ‘r’.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenQr (std::tuple< topsatenTensor &, topsatenTensor & > output, const topsatenTensor &input, bool some, topsStream_t stream=nullptr)

Computes the QR decomposition of a matrix.

Parameters
  • output – The tuple of tensors containing the Q and R tensors.

  • input – The tensor containing input.

  • some – True for reduced QR decomposition and False for complete QR decomposition.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenHistogramdd (std::tuple< topsatenTensor &, std::vector< topsatenTensor > & > output, const topsatenTensor &input, const std::vector< topsatenTensor > &bins, const std::vector< double > &range, const topsatenTensor &weight, const bool &density, topsStream_t stream=nullptr)
topsatenStatus_t TOPSATEN_EXPORT topsatenHistogramdd (std::tuple< topsatenTensor &, std::vector< topsatenTensor > & > output, const topsatenTensor &input, const topsatenSize_t &bins, const std::vector< double > &range, const topsatenTensor &weight, const bool &density=false, topsStream_t stream=nullptr)

Returns N-dimensional Tensor containing the values of the histogram.

Parameters
  • hist – Output[0] - The output tensor.

  • bins_edges – Output[1] - List of tensors containing the min and max values(data in bins tensors will be in range given by bin_edges tensors).

  • input – The input tensor whose values is to be searched in bins tensors.

  • bins – Integer values of dtype topsatenSize_t. Each tensor in list is used to find the index for the corresponding input row.

  • range – Range defines the bounds for the bins for each dimension of the input data.

  • weight – Values of weight will be added to the index found in hist tensor.

  • density – If False (default), the result will contain the count (or total weight) in each bin. If True, each count (weight) is divided by the total count (total weight), then divided by the volume of its associated bin.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenHistogramdd (std::tuple< topsatenTensor &, std::vector< topsatenTensor > & > output, const topsatenTensor &input, const int64_t &bins, const std::vector< double > &range, const topsatenTensor &weight, const bool &density=false, topsStream_t stream=nullptr)

Returns N-dimensional Tensor containing the values of the histogram.

Parameters
  • hist – Output[0] - The output tensor.

  • bins_edges – Output[1] - List of tensors containing the min and max values(data in bins tensors will be in range given by bin_edges tensors).

  • input – The input tensor whose values is to be searched in bins tensors.

  • bins – Integer variable whose value defines the dimension of all bins tensors.

  • range – Range defines the bounds for the bins for each dimension of the input data.

  • weight – Values of weight will be added to the index found in hist tensor.

  • density – If False (default), the result will contain the count (or total weight) in each bin. If True, each count (weight) is divided by the total count (total weight), then divided by the volume of its associated bin.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenSegmentReduce (topsatenTensor &output, const topsatenTensor &data, const char *reduce, const topsatenTensor &lengths, const topsatenTensor &indices, const topsatenTensor &offsets, const int64_t axis, bool unsafe, const topsatenScalar_t &initial, topsStream_t stream=nullptr)

The operator performs reduction operations over segments of a tensor.

Parameters
  • output – The tensor containing output.

  • data – The tensor containing input.

  • reduce – The type of reduction operation to perform - [“max”, “min”, “sum”, “prod”, “mean”].

  • lengths – An optional tensor specifying the lengths of each segment.

  • indices – An optional tensor specifying the indices for reduction.

  • offsets – An optional tensor specifying the offsets for each segment.

  • axis – The axis along which to apply the reduction.

  • unsafe – A boolean indicating whether to perform unsafe operations.

  • initial – An optional initial value for the reduction.

  • stream – Tops stream.

Returns

topsatenStatus_t.

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

This function performs per-channel and per-tensor quantization.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • scales – The scales tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

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

This function performs per-channel and per-tensor dequantization.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • scales – The scales tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenAsymQuantize (topsatenTensor &output, const topsatenTensor &input, const topsatenTensor &scales, const topsatenTensor &qzeros, topsStream_t stream=nullptr)

This function performs per-channel and per-tensor asymquantization.

Parameters
  • output – The output tensor. Support datatype: uint8/uint8.

  • input – The input tensor. Support datatype: bf16/fp16.

  • scales – The scales tensor. Support datatype: bf16/fp16.

  • qzeros – The qzeros tensor. Support datatype: bf16/fp16.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGridSampler (topsatenTensor &output, const topsatenTensor &input, const topsatenTensor &grid, const int64_t interpolation_mode, const int64_t padding_mode, const bool align_corners, topsStream_t stream=nullptr)

Compute grid sample. Given an input and a flow-field grid, computes the output using input values and pixel locations from grid.

Parameters
  • output – The output tensor.

  • input – The input tensor, of shape (N,C,Hin,Win) or (N,C,Din,Hin,Win).

  • grid – The grid tensor, of shape (N,Hout,Wout,2) or (N,Dout,Hout,Wout,3).

  • interpolation_mode – Interpolation mode to calculate output values ‘bilinear’ | ‘nearest’ | ‘bicubic’. Default: ‘bilinear’.

  • padding_mode – Padding mode for outside grid values ‘zeros’ | ‘border’ | ‘reflection’. Default: ‘zeros’.

  • align_corners – If set to True, the extrema (-1 and 1) are considered as referring to the center points of the input’s corner pixels. If set to False, they are instead considered as referring to the corner points of the input’s corner pixels.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGridSampler2d (topsatenTensor &output, const topsatenTensor &input, const topsatenTensor &grid, const int64_t interpolation_mode, const int64_t padding_mode, const bool align_corners, topsStream_t stream=nullptr)

Compute grid sample. Given an input and a flow-field grid, computes the output using input values and pixel locations from grid.

Parameters
  • output – The output tensor.

  • input – The input tensor, of shape (N,C,Hin,Win).

  • grid – The grid tensor, of shape (N,Hout,Wout,2).

  • interpolation_mode – Interpolation mode to calculate output values ‘bilinear’ | ‘nearest’ | ‘bicubic’. Default: ‘bilinear’.

  • padding_mode – Padding mode for outside grid values ‘zeros’ | ‘border’ | ‘reflection’. Default: ‘zeros’.

  • align_corners – If set to True, the extrema (-1 and 1) are considered as referring to the center points of the input’s corner pixels. If set to False, they are instead considered as referring to the corner points of the input’s corner pixels.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGridSampler3d (topsatenTensor &output, const topsatenTensor &input, const topsatenTensor &grid, const int64_t interpolation_mode, const int64_t padding_mode, const bool align_corners, topsStream_t stream=nullptr)

Compute grid sample. Given an input and a flow-field grid, computes the output using input values and pixel locations from grid.

Parameters
  • output – The output tensor.

  • input – The input tensor, of shape (N,C,Din,Hin,Win).

  • grid – The grid tensor, of shape (N,Dout,Hout,Wout,3).

  • interpolation_mode – Interpolation mode to calculate output values ‘bilinear’ | ‘nearest’ | ‘bicubic’. Default: ‘bilinear’.

  • padding_mode – Padding mode for outside grid values ‘zeros’ | ‘border’ | ‘reflection’. Default: ‘zeros’.

  • align_corners – If set to True, the extrema (-1 and 1) are considered as referring to the center points of the input’s corner pixels. If set to False, they are instead considered as referring to the corner points of the input’s corner pixels.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenUpsampleLinear1d (topsatenTensor &output, const topsatenTensor &input, const topsatenSize_t &size, bool align_corners, const topsatenScalar_t &scale, topsStream_t stream=nullptr)

This function performs 1D linear upsampling on a multi-channel input signal. You can define the scale using either the output size (w) or a scaling factor (scale_factor).

Parameters
  • output – The out tensor.

  • input – The input tensor.

  • size – Output spatial size.

  • align_corners – If True, the corner pixels of the input and output tensors are aligned.

  • scale – Multiplier for spatial size.

  • stream – Tops stream.

Returns

topsatenStatus_t.

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

This function returns a new 1-D tensor which indexes the input tensor according to the boolean mask tensor.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • mask – The mask tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenAsymDeQuantize (topsatenTensor &output, const topsatenTensor &input, const topsatenTensor &scales, const topsatenTensor &qzeros, topsStream_t stream=nullptr)

This function performs per-channel and per-tensor asymdequantization.

Parameters
  • output – The output tensor. Support datatype: bf16/fp16.

  • input – The input tensor. Support datatype: uint8/uint8.

  • scales – The scales tensor. Support datatype: bf16/fp16.

  • qzeros – The qzeros tensor. Support datatype: bf16/fp16.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenNms (topsatenTensor &output, const topsatenTensor &input, const topsatenTensor &scores, double iou_threshold, topsStream_t stream=nullptr)

Nms.

Parameters
  • output – The output tensor to store indexes.

  • input – The input tensor to store boxes.

  • scores – The score tensor to store value for each box.

  • iou_threshold – The threshold value to compare with IoU.

  • stream – Tops stream.

Returns

topsopStatus_t

topsatenStatus_t TOPSATEN_EXPORT topsatenMultiHeadAttentionFusion (topsatenTensor &output, topsatenTensor &residual_output, const topsatenTensor &input, const topsatenTensor &residual_input, const topsatenTensor &weight_QKV, const topsatenTensor &bias_QKV, const topsatenTensor &weight_O, const topsatenTensor &bias_O, const topsatenTensor &norm_scale, const topsatenTensor &norm_bias, const topsatenTensor &mask, const int32_t *seq_length, const float qk_scale_coeff, const float residual_scale, const bool use_residual_add, const topsatenFusionNormMode_t norm_type, const int qkv_head, topsStream_t stream, const float norm_eps)

TopsatenMultiHeadAttentionFusion operator.

Parameters
  • output – The output tensor handle of the operator.

  • input – The input tensor handle of the operator.

  • weight_QKV – The weight tensor handle of Q-dot.

  • bias_QKV – The bias tensor handle of Q-dot.

  • weight_O – The weight tensor handle of O-dot.

  • bias_O – The bias tensor handle of O-dot.

  • mask – Mask tensor of softmax in SDP.

  • qk_scale_coeff – Should be layer_id + 1, the scale before softmax operation and after Q-dot operation.

  • residual_scale – Multiply the qkv input with this scale, then add to context_layer_dot output.

  • norm_scale – Scale tensor of norm.

  • norm_bias – Bias tensor of norm.

  • use_residual_add – Option to choose if use residual add.

  • norm_type – Choose Norm type in MultiQueryAttention.

  • batch_size – Batch size.

  • max_seq_len – Max sequence length.

  • hidden_size – hidden size.

  • stream – tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenMultiLayerPerceptronFusion (topsatenTensor &output, topsatenTensor &residual_output, const topsatenTensor &input, const topsatenTensor &residual_input, const topsatenTensor &weight_A, const topsatenTensor &bias_A, const topsatenTensor &weight_B, const topsatenTensor &bias_B, const topsatenTensor &norm_scale, const topsatenTensor &norm_bias, const int32_t *seq_length, const float residual_scale, const bool use_residual_add, const topsatenActivationMode_t activation_type, const topsatenFusionNormMode_t norm_type, topsStream_t stream, const float norm_eps)

TopsatenMultiLayerPerceptronFusion operator.

Parameters
  • output – The output tensor handle of the operator.

  • input – The input tensor handle of the operator.

  • weight_A – The weight tensor handle of dot_A.

  • bias_A – The bias tensor handle of dot_A.

  • weight_B – The weight tensor handle of dot_B.

  • bias_B – The bias tensor handle of dot_B.

  • residual_scale – Multiply the mlp input with this scale, then add to mlp output.

  • norm_scale – Scale tensor of norm.

  • norm_bias – Bias tensor of norm.

  • activation_type – Choose activation type in MLP.

  • norm_type – Choose Norm type in MLP.

  • use_residual_add – Option to choose if use residual add.

  • 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 extensions ops

This section describes topsaten extensions ops api definitions.

topsatenStatus_t TOPSATEN_EXPORT topsatenUpfirdn2d (topsatenTensor &out, const topsatenTensor &input, const topsatenTensor &kernel, int up_x, int up_y, int down_x, int down_y, int pad_x0, int pad_x1, int pad_y0, int pad_y1, topsStream_t stream=nullptr)

Computes the upsampling-Convolution-downsampling.

Parameters
  • output – The output tensor.

  • input – The input tensors.

  • kernel – The convolution kernel.

  • up_x – Upsampling padding num in x-dim.

  • up_y – Upsampling padding num in y-dim.

  • down_x – Downsampling padding num in x-dim.

  • down_y – Downsampling padding num in y-dim.

  • pad_x0 – Before-conv padding num in x-dim for low dimension.

  • pad_x1 – Before-conv padding num in x-dim for high dimension.

  • pad_y0 – Before-conv padding num in y-dim for low dimension.

  • pad_y1 – Before-conv padding num in y-dim for high dimension.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenInplaceAbn (topsatenTensor &x, const topsatenTensor &mean, const topsatenTensor &var, const topsatenTensor &weight, const topsatenTensor &bias, const bool affine, const float eps, topsStream_t stream=nullptr)

Computes the batchnorm+bias with inplace operation.

Parameters
  • x – Input data and inplace with output data.

  • mean – The tensor containing param mean.

  • var – The tensor containing param var.

  • weight – The tensor containing param weight.

  • bias – The tensor containing param bias.

  • affine – If calculation is affined.

  • eps – Float param episilon.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenFusedBiasAct (topsatenTensor &output, const topsatenTensor &input, const topsatenTensor &bias, const topsatenTensor &refer, const int64_t act, const int64_t grad, const float alpha, const float scale, topsStream_t stream=nullptr)

Computes the fused bias activation.

Parameters
  • output – The output tensor.

  • input – The input tensors.

  • bias – The bias tensors.

  • refer – The refer tensors.

  • act – A float to choose corresponding activation.

  • grad – A float to choose corresponding activation.

  • alpha – The multiplier for corresponding activation.

  • scale – The input tensor of scale.

  • stream – Tops stream.

Returns

topsatenStatus_t.

2.4. Aten graph ops

This section describes topsaten graph ops api definitions.

using topsatenBuilder_t = topsatenBuilder*
using topsatenGraphOp_t = topsatenGraphOp*
topsatenStatus_t TOPSATEN_EXPORT topsatenElementwiseFusion (std::vector< topsatenTensor > &outputs, const std::vector< topsatenTensor > &inputs, topsatenBuilder_t graph_ptr, topsStream_t stream=nullptr)
topsatenStatus_t TOPSATEN_EXPORT topsatenCreateBuilder (topsatenBuilder_t &builder)

Create builder object.

Parameters

builder – Handle of the created builder object.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenReleaseBuilder (topsatenBuilder_t builder)

Release builder object.

Parameters

builder – Handle of the builder object to be released.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenSetNumArguments (topsatenBuilder_t builder, int num)

Set the number of the graph arguments.

Parameters
  • builder – The builder handle.

  • num – Number to be set as arguments number.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenSetArgumentShape (topsatenBuilder_t builder, int i, const topsatenTensor &shape)

Set shape for the ith argument.

Parameters
  • builder – The builder handle.

  • i – The index of the argument.

  • shape – The shape to be set as the argument shape.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGetArgument (topsatenBuilder_t builder, int i, topsatenGraphOp_t &argument)

Get the graphop of the ith argument.

Parameters
  • builder – The builder handle.

  • i – The index of the argument.

  • argument – Handle of the ith argument.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenCreateArgument (topsatenBuilder_t builder, topsatenGraphOp_t &argument, const topsatenTensor &shape)

Create an argument.

Parameters
  • builder – The builder handle.

  • argument – Handle of the ith argument.

  • shape – The shape to be set as the argument shape.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenCreateScalar (topsatenBuilder_t builder, topsatenGraphOp_t &scalar, const topsatenScalar_t &value)

Create a scalar.

Parameters
  • builder – The builder handle.

  • scalar – Handle of the created scalar.

  • value – The scalar value.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenSetNumResults (topsatenBuilder_t builder, int num)

Set the number of the graph results.

Parameters
  • builder – The builder handle.

  • num – Number to be set as results number.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenSetResult (topsatenBuilder_t builder, int i, topsatenGraphOp_t &result)

Set the graph op as the ith graph result.

Parameters
  • builder – The builder handle.

  • i – The index of the result.

  • result – The graph op to be set as the ith result op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenPrintIRText (topsatenBuilder_t builder, std::ostream &os=std::cout)

Dump the built graph as ir text.

Parameters

builder – The builder handle.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphValidate (topsatenBuilder_t builder)

Validate the built graph, and print error if invalid.

Parameters

builder – The builder handle.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphAbs (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input)

Build Abs operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphNeg (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input)

Build Neg operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphSign (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input)

Build Sign operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphReciprocal (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input)

Build Reciprocal operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphBitwiseNot (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input)

Build BitwiseNot operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphLogicalNot (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input)

Build LogicalNot operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphCeil (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input)

Build Ceil operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphFloor (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input)

Build Floor operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphRound (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input)

Build Round operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphTrunc (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input)

Build Trunc operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphExp (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input)

Build Exp operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphExp2 (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input)

Build Exp2 operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphExpm1 (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input)

Build Expm1 operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphLog (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input)

Build Log operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphLog10 (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input)

Build Log10 operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphLog1p (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input)

Build Log1p operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphLog2 (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input)

Build Log2 operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphLogit (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input)

Build Logit operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphSquare (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input)

Build Square operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphSqrt (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input)

Build Sqrt operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphRsqrt (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input)

Build Rsqrt operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphCbrt (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input)

Build Cbrt operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphIsNan (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input)

Build IsNan operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphIsInf (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input)

Build IsInf operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphIsFinite (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input)

Build IsFinite operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphCos (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input)

Build Cos operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphCosh (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input)

Build Cosh operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphAcos (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input)

Build Acos operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphAcosh (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input)

Build Acosh operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphSin (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input)

Build Sin operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphSinh (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input)

Build Sinh operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphAsin (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input)

Build Asin operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphAsinh (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input)

Build Asinh operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphTan (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input)

Build Tan operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphTanh (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input)

Build Tanh operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphAtan (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input)

Build Atan operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphAtanh (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input)

Build Atanh operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphConj (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input)

Build Conj operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphNegConj (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input)

Build NegConj operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphConvert (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input, topsatenDataType_t dtype)

Build convert operator.

Parameters
  • builder – The builder handle.

  • output – The output tensor.

  • input – The source tensor.

  • dtype – The data type of the output tensor. Now Support: Interconversion: TOPSATEN_DATA_FP32, TOPSATEN_DATA_FP16, TOPSATEN_DATA_BF16, TOPSATEN_DATA_I8, TOPSATEN_DATA_I16, TOPSATEN_DATA_I32, TOPSATEN_DATA_PRED, TOPSATEN_DATA_U8, TOPSATEN_DATA_U16, TOPSATEN_DATA_U32 In addition: TOPSATEN_DATA_I64<->TOPSATEN_DATA_I32.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphNanToNum (topsatenBuilder_t builder, topsatenGraphOp_t &out, topsatenGraphOp_t input, float nan=0.0, float posinf=0.0, float neginf=0.0)

Build NanToNum operator.

Parameters
  • builder – The builder handle.

  • out – The output op.

  • input – Input op.

  • nan – The replacement for nan.

  • posinf – The replacement for positive infinity.

  • neginf – The replacement for negative infinity.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphSigmoid (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input)

Build Sigmoid operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphLogSigmoid (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input)

Build LogSigmoid operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphHardsigmoid (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input)

Build Hardsigmoid operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphHardswish (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input)

Build Hardswish operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphHardshrink (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input, float lambd=0.5)

Build Hardshrink operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

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

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphHardtanh (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input, float min_val=-1.0, float max_val=1.0)

Build Hardtanh operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

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

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

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphThreshold (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input, float threshold, float value)

Build Threshold operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

  • threshold – The value to threshold at.

  • value – The value to replace with.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphGelu (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input, const char *const approximate="none")

Build Gelu operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

  • approximate – The gelu approximation algorithm to use.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphRelu (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input)

Build Relu operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphRelu6 (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input)

Build Relu6 operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphSelu (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input)

Build Selu operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphMish (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input)

Build Mish operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphElu (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input, float alpha=1.0, float scale=1.0, float input_scale=1.0)

Build Elu operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

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

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphSoftplus (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input, float beta=1.0, float threshold=20)

Build Softplus operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

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

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

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphSoftshrink (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input, float lambd=0.5)

Build Softshrink operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

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

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphSilu (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input)

Build Silu operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphErf (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input)

Build Erf operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphSgn (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input)

Build Sgn operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphRad2Deg (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input)

Build Rad2Deg operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphDeg2Rad (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input)

Build Deg2Rad operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphErfinv (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input)

Build Erfinv operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphLgamma (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input)

Build Lgamma operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphDigamma (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input)

Build Digamma operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphI0 (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input)

Build I0 operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphErfc (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input)

Build Erfc operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphFrac (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input)

Build Frac operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphSqueeze (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input, const topsatenSize_t &axes)

Build Squeeze operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

  • axes – Now accepts tuples of dimensions.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphUnSqueeze (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input, const topsatenSize_t &axes)

Build UnSqueeze operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

  • axes – Now accepts tuples of dimensions.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphSum (topsatenBuilder_t builder, topsatenGraphOp_t &output, topsatenGraphOp_t input, const topsatenSize_t &dimensions, bool keepdims, topsatenDataType_t dtype)

Build Sum operator.

Parameters
  • builder – The builder handle.

  • output – The output op.

  • input – The input op.

  • dimensions – The dimensions to reduce sum.

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

  • data_type – Data type.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphAdd (topsatenBuilder_t builder, topsatenGraphOp_t &out, topsatenGraphOp_t lhs, topsatenGraphOp_t rhs)

Build Add operator.

Parameters
  • builder – The builder handle.

  • out – The output op.

  • lhs – Input lhs op.

  • rhs – Input rhs op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphAddRelu (topsatenBuilder_t builder, topsatenGraphOp_t &out, topsatenGraphOp_t lhs, topsatenGraphOp_t rhs, float alpha=1.0)

Build AddRelu operator.

Parameters
  • builder – The builder handle.

  • out – The output op.

  • lhs – Input lhs op.

  • rhs – Input rhs op.

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

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphSub (topsatenBuilder_t builder, topsatenGraphOp_t &out, topsatenGraphOp_t lhs, topsatenGraphOp_t rhs)

Build Sub operator.

Parameters
  • builder – The builder handle.

  • out – The output op.

  • lhs – Input lhs op.

  • rhs – Input rhs op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphRsub (topsatenBuilder_t builder, topsatenGraphOp_t &out, topsatenGraphOp_t lhs, topsatenGraphOp_t rhs, float alpha)

Build Rsub operator.

Parameters
  • builder – The builder handle.

  • out – The output op.

  • lhs – Input lhs op.

  • rhs – Input rhs op.

  • alpha – The multiplier for lhs.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphMul (topsatenBuilder_t builder, topsatenGraphOp_t &out, topsatenGraphOp_t lhs, topsatenGraphOp_t rhs)

Build Mul operator.

Parameters
  • builder – The builder handle.

  • out – The output op.

  • lhs – Input lhs op.

  • rhs – Input rhs op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphDiv (topsatenBuilder_t builder, topsatenGraphOp_t &out, topsatenGraphOp_t lhs, topsatenGraphOp_t rhs)

Build Div operator.

Parameters
  • builder – The builder handle.

  • out – The output op.

  • lhs – Input lhs op.

  • rhs – Input rhs op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphMax (topsatenBuilder_t builder, topsatenGraphOp_t &out, topsatenGraphOp_t lhs, topsatenGraphOp_t rhs)

Build Max operator.

Parameters
  • builder – The builder handle.

  • out – The output op.

  • lhs – Input lhs op.

  • rhs – Input rhs op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphMin (topsatenBuilder_t builder, topsatenGraphOp_t &out, topsatenGraphOp_t lhs, topsatenGraphOp_t rhs)

Build Min operator.

Parameters
  • builder – The builder handle.

  • out – The output op.

  • lhs – Input lhs op.

  • rhs – Input rhs op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphPow (topsatenBuilder_t builder, topsatenGraphOp_t &out, topsatenGraphOp_t lhs, topsatenGraphOp_t rhs)

Build Pow operator.

Parameters
  • builder – The builder handle.

  • out – The output op.

  • lhs – Input lhs op.

  • rhs – Input rhs op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphRemainder (topsatenBuilder_t builder, topsatenGraphOp_t &out, topsatenGraphOp_t lhs, topsatenGraphOp_t rhs)

Build Remainder operator.

Parameters
  • builder – The builder handle.

  • out – The output op.

  • lhs – Input lhs op.

  • rhs – Input rhs op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphFmod (topsatenBuilder_t builder, topsatenGraphOp_t &out, topsatenGraphOp_t lhs, topsatenGraphOp_t rhs)

Build Fmod operator.

Parameters
  • builder – The builder handle.

  • out – The output op.

  • lhs – Input lhs op.

  • rhs – Input rhs op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphAtan2 (topsatenBuilder_t builder, topsatenGraphOp_t &out, topsatenGraphOp_t lhs, topsatenGraphOp_t rhs)

Build Atan2 operator.

Parameters
  • builder – The builder handle.

  • out – The output op.

  • lhs – Input lhs op.

  • rhs – Input rhs op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphAnd (topsatenBuilder_t builder, topsatenGraphOp_t &out, topsatenGraphOp_t lhs, topsatenGraphOp_t rhs)

Build And operator.

Parameters
  • builder – The builder handle.

  • out – The output op.

  • lhs – Input lhs op.

  • rhs – Input rhs op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphOr (topsatenBuilder_t builder, topsatenGraphOp_t &out, topsatenGraphOp_t lhs, topsatenGraphOp_t rhs)

Build Or operator.

Parameters
  • builder – The builder handle.

  • out – The output op.

  • lhs – Input lhs op.

  • rhs – Input rhs op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphLogicalAnd (topsatenBuilder_t builder, topsatenGraphOp_t &out, topsatenGraphOp_t lhs, topsatenGraphOp_t rhs)

Build LogicalAnd operator.

Parameters
  • builder – The builder handle.

  • out – The output op.

  • lhs – Input lhs op.

  • rhs – Input rhs op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphLogicalOr (topsatenBuilder_t builder, topsatenGraphOp_t &out, topsatenGraphOp_t lhs, topsatenGraphOp_t rhs)

Build LogicalOr operator.

Parameters
  • builder – The builder handle.

  • out – The output op.

  • lhs – Input lhs op.

  • rhs – Input rhs op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphLogicalXor (topsatenBuilder_t builder, topsatenGraphOp_t &out, topsatenGraphOp_t lhs, topsatenGraphOp_t rhs)

Build LogicalXor operator.

Parameters
  • builder – The builder handle.

  • out – The output op.

  • lhs – Input lhs op.

  • rhs – Input rhs op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphBitwiseAnd (topsatenBuilder_t builder, topsatenGraphOp_t &out, topsatenGraphOp_t lhs, topsatenGraphOp_t rhs)

Build BitwiseAnd operator.

Parameters
  • builder – The builder handle.

  • out – The output op.

  • lhs – Input lhs op.

  • rhs – Input rhs op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphBitwiseOr (topsatenBuilder_t builder, topsatenGraphOp_t &out, topsatenGraphOp_t lhs, topsatenGraphOp_t rhs)

Build BitwiseOr operator.

Parameters
  • builder – The builder handle.

  • out – The output op.

  • lhs – Input lhs op.

  • rhs – Input rhs op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphBitwiseXor (topsatenBuilder_t builder, topsatenGraphOp_t &out, topsatenGraphOp_t lhs, topsatenGraphOp_t rhs)

Build BitwiseXor operator.

Parameters
  • builder – The builder handle.

  • out – The output op.

  • lhs – Input lhs op.

  • rhs – Input rhs op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphBitwiseRightShift (topsatenBuilder_t builder, topsatenGraphOp_t &out, topsatenGraphOp_t lhs, topsatenGraphOp_t rhs)

Build BitwiseRightShift operator.

Parameters
  • builder – The builder handle.

  • out – The output op.

  • lhs – Input lhs op.

  • rhs – Input rhs op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphBitwiseLeftShift (topsatenBuilder_t builder, topsatenGraphOp_t &out, topsatenGraphOp_t lhs, topsatenGraphOp_t rhs)

Build BitwiseLeftShift operator.

Parameters
  • builder – The builder handle.

  • out – The output op.

  • lhs – Input lhs op.

  • rhs – Input rhs op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphPrelu (topsatenBuilder_t builder, topsatenGraphOp_t &out, topsatenGraphOp_t lhs, topsatenGraphOp_t rhs)

Build Prelu operator.

Parameters
  • builder – The builder handle.

  • out – The output op.

  • lhs – Input lhs op.

  • rhs – Input rhs op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphGcd (topsatenBuilder_t builder, topsatenGraphOp_t &out, topsatenGraphOp_t lhs, topsatenGraphOp_t rhs)

Build Gcd operator.

Parameters
  • builder – The builder handle.

  • out – The output op.

  • lhs – Input lhs op.

  • rhs – Input rhs op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphCopysign (topsatenBuilder_t builder, topsatenGraphOp_t &out, topsatenGraphOp_t lhs, topsatenGraphOp_t rhs)

Build Copysign operator.

Parameters
  • builder – The builder handle.

  • out – The output op.

  • lhs – Input lhs op.

  • rhs – Input rhs op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphXlogy (topsatenBuilder_t builder, topsatenGraphOp_t &out, topsatenGraphOp_t lhs, topsatenGraphOp_t rhs)

Build Xlogy operator.

Parameters
  • builder – The builder handle.

  • out – The output op.

  • lhs – Input lhs op.

  • rhs – Input rhs op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphLogaddexp (topsatenBuilder_t builder, topsatenGraphOp_t &out, topsatenGraphOp_t lhs, topsatenGraphOp_t rhs)

Build Logaddexp operator.

Parameters
  • builder – The builder handle.

  • out – The output op.

  • lhs – Input lhs op.

  • rhs – Input rhs op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphLogaddexp2 (topsatenBuilder_t builder, topsatenGraphOp_t &out, topsatenGraphOp_t lhs, topsatenGraphOp_t rhs)

Build Logaddexp2 operator.

Parameters
  • builder – The builder handle.

  • out – The output op.

  • lhs – Input lhs op.

  • rhs – Input rhs op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphHypot (topsatenBuilder_t builder, topsatenGraphOp_t &out, topsatenGraphOp_t lhs, topsatenGraphOp_t rhs)

Build Hypot operator.

Parameters
  • builder – The builder handle.

  • out – The output op.

  • lhs – Input lhs op.

  • rhs – Input rhs op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphLcm (topsatenBuilder_t builder, topsatenGraphOp_t &out, topsatenGraphOp_t lhs, topsatenGraphOp_t rhs)

Build Lcm operator.

Parameters
  • builder – The builder handle.

  • out – The output op.

  • lhs – Input lhs op.

  • rhs – Input rhs op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphLdexp (topsatenBuilder_t builder, topsatenGraphOp_t &out, topsatenGraphOp_t lhs, topsatenGraphOp_t rhs)

Build Ldexp operator.

Parameters
  • builder – The builder handle.

  • out – The output op.

  • lhs – Input lhs op.

  • rhs – Input rhs op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphIgamma (topsatenBuilder_t builder, topsatenGraphOp_t &out, topsatenGraphOp_t lhs, topsatenGraphOp_t rhs)

Build Igamma operator.

Parameters
  • builder – The builder handle.

  • out – The output op.

  • lhs – Input lhs op.

  • rhs – Input rhs op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphIgammac (topsatenBuilder_t builder, topsatenGraphOp_t &out, topsatenGraphOp_t lhs, topsatenGraphOp_t rhs)

Build Igammac operator.

Parameters
  • builder – The builder handle.

  • out – The output op.

  • lhs – Input lhs op.

  • rhs – Input rhs op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphEq (topsatenBuilder_t builder, topsatenGraphOp_t &out, topsatenGraphOp_t lhs, topsatenGraphOp_t rhs)

Build Eq operator.

Parameters
  • builder – The builder handle.

  • out – The output op.

  • lhs – Input lhs op.

  • rhs – Input rhs op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphNe (topsatenBuilder_t builder, topsatenGraphOp_t &out, topsatenGraphOp_t lhs, topsatenGraphOp_t rhs)

Build Ne operator.

Parameters
  • builder – The builder handle.

  • out – The output op.

  • lhs – Input lhs op.

  • rhs – Input rhs op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphGe (topsatenBuilder_t builder, topsatenGraphOp_t &out, topsatenGraphOp_t lhs, topsatenGraphOp_t rhs)

Build Ge operator.

Parameters
  • builder – The builder handle.

  • out – The output op.

  • lhs – Input lhs op.

  • rhs – Input rhs op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphGt (topsatenBuilder_t builder, topsatenGraphOp_t &out, topsatenGraphOp_t lhs, topsatenGraphOp_t rhs)

Build Gt operator.

Parameters
  • builder – The builder handle.

  • out – The output op.

  • lhs – Input lhs op.

  • rhs – Input rhs op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphLe (topsatenBuilder_t builder, topsatenGraphOp_t &out, topsatenGraphOp_t lhs, topsatenGraphOp_t rhs)

Build Le operator.

Parameters
  • builder – The builder handle.

  • out – The output op.

  • lhs – Input lhs op.

  • rhs – Input rhs op.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsatenGraphLt (topsatenBuilder_t builder, topsatenGraphOp_t &out, topsatenGraphOp_t lhs, topsatenGraphOp_t rhs)

Build Lt operator.

Parameters
  • builder – The builder handle.

  • out – The output op.

  • lhs – Input lhs op.

  • rhs – Input rhs op.

Returns

topsatenStatus_t.

struct topsatenBuilder
#include <topsaten_graph.h>
struct topsatenGraphOp
#include <topsaten_graph.h>

2.5. Aten onnx ops

This section describes topsaten onnx ops api definitions.

topsatenStatus_t TOPSATEN_EXPORT topsonnxDepthToSpace (topsatenTensor &output, const topsatenTensor &input, int block_size, char *mode, topsStream_t stream=nullptr)

Onnx depth to space.

Parameters
  • output – Output tensor.

  • input – Input tensor.

  • block_size – Block_size.

  • mode – Tensor data format:”DCR”(NCHW),”CRD”(NHWC).

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsonnxMaxPool (topsatenTensor &output, topsatenTensor &indices, const topsatenTensor &input, const topsatenSize_t &kernel_size, const topsatenSize_t &stride, const topsatenSize_t &padding, const topsatenSize_t &dilation, const int32_t storage_order=0, const int32_t ceil_mode=0, const char *auto_pad="NOTSET", topsStream_t stream=nullptr)

MaxPool consumes an input tensor X and applies max pooling across the tensor according to kernel sizes, stride sizes, and pad lengths. max pooling consisting of computing the max on all values of a subset of the input tensor according to the kernel size and downsampling the data into the output tensor Y for further processing. The output spatial shape is calculated differently depending on whether explicit padding is used, where pads is employed, or auto padding is used, where auto_pad is utilized. With explicit padding see reference: https://onnx.ai/onnx/operators/onnx__MaxPool.html.

Parameters
  • output – The output tensor.

  • indices – Optional, Indices tensor from max pooling across the input tensor. The dimensions of indices are the same as output tensor. The values in indices of are the indices of the selected values during pooling. The indices are computed as flatten 1-D tensor, and the indices do not consider padding. So the values in indices are in [0, N x C x D1 x … x Dn)..

  • input – The input tensor.

  • kernel_size – Size of the pooling region. Can be a single number or a tuple (kH, kW).

  • stride – Stride along each spatial axis. If not present, the stride defaults to 1 along each spatial axis.

  • padding – Padding for the beginning and ending along each spatial axis, it can take any value greater than or equal to 0. The value represent the number of pixels added to the beginning and end part of the corresponding axis. pads format should be as follow [x1_begin, x2_begin…x1_end, x2_end,…], where xi_begin the number of pixels added at the beginning of axis i and xi_end, the number of pixels added at the end of axis i. This attribute cannot be used simultaneously with auto_pad attribute. If not present, the padding defaults to 0 along start and end of each spatial axis.

  • dilation – Dilation value along each spatial axis of filter. If not present, the dilation defaults to 1 along each spatial axis.

  • ceil_mode – If True(1), will use ceil instead of floor to compute the output shape.

  • storage_order – The storage order of the tensor. 0 is row major, and 1 is column major. This attribute is used only to convert an n-tuple index value into a single integer value for producing the second output.

  • auto_pad – Auto_pad must be either NOTSET, SAME_UPPER, SAME_LOWER or VALID. Where default value is NOTSET, which means explicit padding is used. SAME_UPPER or SAME_LOWER mean pad the input so that output_shape[i] = ceil(input_shape[i] / strides[i]) for each axis i. The padding is split between the two sides equally or almost equally (depending on whether it is even or odd). In case the padding is an odd number, the extra padding is added at the end for SAME_UPPER and at the beginning for SAME_LOWER.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsonnxLSTM (std::tuple< topsatenTensor, topsatenTensor, topsatenTensor > &outputs, const topsatenTensor X, const topsatenTensor W, const topsatenTensor R, const topsatenTensor B, const topsatenTensor sequence_lens, const topsatenTensor initial_h, const topsatenTensor initial_c, const topsatenTensor P, std::vector< topsatenScalar_t > activation_alpha, std::vector< topsatenScalar_t > activation_beta, std::vector< const char * > activations, topsatenScalar_t clip, const char *direction, topsatenScalar_t hidden_size, topsatenScalar_t input_forget, topsatenScalar_t layout, topsStream_t stream=nullptr)

Computes an LSTM (Long Short-Term Memory) as per ONNX LSTM Operator. This function returns tuple of output tensors.

In below shapes num_directions must be equal to 1 for forward and reverse whereas num_directions must be equal to 2 for bidirectional

output(Y): A tensor that concats all the intermediate output values of the hidden. It has shape [seq_length, num_directions, batch_size, hidden_size]. output(Y_h): The last output value of the hidden. It has shape [num_directions, batch_size, hidden_size]. output(Y_c): The last output value of the cell. It has shape [num_directions, batch_size, hidden_size].

Parameters
  • X – The input tensor packed into one 3-D tensor with the shape of [seq_length, batch_size, input_size].

  • W – The weight tensor for the gates. The tensor has shape [num_directions, 4*hidden_size, input_size].

  • R – The recurrence weight tensor. This tensor has shape [num_directions, 4*hidden_size, hidden_size].

  • B – The bias tensor for input gate. This tensor has shape [num_directions, 8*hidden_size].

  • sequence_lens – Optional tensor specifying lengths of the sequences in a batch. It has shape [batch_size] and Int32 data_type.

  • initial_h – Optional initial value of the hidden. It has shape [num_directions, batch_size, hidden_size].

  • initial_c – Optional initial value of the cell. It has shape [num_directions, batch_size, hidden_size].

  • P – Optional weight tensor for peepholes. It has shape [num_directions, 3*hidde_size].

  • activation_alpha – Optional scaling values used by some activation functions.

  • activation_beta – Optional scaling values used by some activation functions.

  • activations – A list of 3 (or 6 if bidirectional) activation functions.

  • clip – Cell clip threshold.

  • direction – Specify if the RNN is forward, reverse, or bidirectional. Must be one of forward, reverse, or bidirectional.

  • hidden_size – Number of neurons in the hidden layer.

  • input_forget – Couple the input and forget gates if 1.

  • layout – The shape format of inputs X, initial_h, initial_c and outputs Y, Y_h, Y_c.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsonnxGather (topsatenTensor &output, const topsatenTensor &data, const topsatenTensor &indices, int axis=0, topsStream_t stream=nullptr)

Gather slices from data axis according to indices.

Parameters
  • output – Output tensor.

  • data – Input tensor.

  • indices – Tensor of int32 indices. The values must be in range (0, data.shape[axis]).

  • axis – Which axis to gather on. Negative value means counting dimensions from the back. Accepted range is [-r, r-1] where r = rank(data).

  • stream – Tops stream.

Returns

topsatenStatus_t.

2.6. Aten paddle ops

This section describes paddle onnx ops api definitions.

topsatenStatus_t TOPSATEN_EXPORT topsatenConvTransposeActivation (topsatenTensor &output, const topsatenTensor &input, const topsatenTensor &filter, const topsatenTensor &bias, const topsatenSize_t &stride, const topsatenSize_t &padding, const topsatenSize_t &output_padding, const int64_t groups, const topsatenSize_t &dilation, const topsatenActivationMode_t activation_mode, const topsatenScalar_t &coef={TOPSATEN_DATA_FP32, {.fval=1.0f}}, topsStream_t stream=nullptr)

ConvTranspose operator fusion with Activation operator, only support 2D convolution and groups equal to 1 now.

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 – Controls the additional size added to one side of the output shape.

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

  • 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 topsatenConvScaledBiasActivation (topsatenTensor &output, const topsatenTensor &input, const topsatenTensor &filter, const topsatenTensor &bias, const topsatenTensor &residual, 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}}, const topsatenScalar_t alpha={TOPSATEN_DATA_FP32, {.fval=1.0f}}, const topsatenScalar_t beta={TOPSATEN_DATA_FP32, {.fval=0.0f}}, topsStream_t stream=nullptr)

ConvScaledBiasActivation operator.

Parameters
  • output – The output tensor, also named y.

  • input – The input tensor of feature, also named x.

  • filter – The input tensor of reduce window, also named w.

  • bias – The input tensor of bias, disabled if tensor datatype is TOPSATEN_DATA_NONE, also named b.

  • residual – The input tensor of residual, residual share buffer with input if tensor datatype is TOPSATEN_DATA_NONE, also named z.

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

  • alpha – A floating point scalar, y = act(alpha*conv(x,w) + beta*z + b).

  • beta – A floating point scalar, y = act(alpha*conv(x,w) + beta*z + b).

  • stream – Tops stream.

Returns

topsatenStatus_t.

2.7. 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 topsteLayerNormFwdQuant (topsatenTensor &output, topsatenTensor &mean, topsatenTensor &rstd, const topsatenTensor &input, const topsatenTensor &scaling, const topsatenTensor &gamma, const topsatenTensor &beta, const topsatenScalar_t &epsilon, topsStream_t stream=nullptr)

Compute LayerNormQuant 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].

  • scaling – Scaling tensor of shape [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 topsteRmsNormFwdQuant (topsatenTensor &output, topsatenTensor &rstd, const topsatenTensor &input, const topsatenTensor &gamma, const topsatenTensor &scaling, const topsatenScalar_t &epsilon, topsStream_t stream=nullptr)

Compute RMSNormQuant 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].

  • scaling – Scaling tensor of shape [1] or [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.

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

nvte fused rope operator.

Parameters
  • output – The output tensor.

  • input – The input tensor of lhs.

  • freq – The input tensor of rhs.

  • stream – Tops stream.

Returns

topsatenStatus_t.

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

topsatenStatus_t TOPSATEN_EXPORT topstfSequenceMask (topsatenTensor &output, const topsatenTensor &lengths, const topsatenTensor &maxlen, const topsatenDataType_t dtype, topsStream_t stream=nullptr)

This function returns a mask tensor representing the first N positions of each cell.

Parameters
  • output – The output tensor.

  • lengths – Integer tensor, all its values <= maxlen.

  • maxlen – Scalar integer tensor, size of last dimension of returned tensor. Default is the maximum value in lengths.

  • dtype – Output type of the resulting tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topstfSequenceMask (topsatenTensor &output, const topsatenTensor &lengths, const int64_t maxlen, const topsatenDataType_t dtype, topsStream_t stream=nullptr)

This function returns a mask tensor representing the first N positions of each cell.

Parameters
  • output – The output tensor.

  • lengths – Integer tensor, all its values <= maxlen.

  • maxlen – Scalar integer, size of last dimension of returned tensor. Default is the maximum value in lengths.

  • dtype – Output type of the resulting tensor.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topstfUnsortedSegmentSum (topsatenTensor &output, const topsatenTensor &input, const topsatenTensor &seg_ids, int32_t num_segments, topsStream_t stream=nullptr)

This function returns a tensor with computes the sum along segments.

Parameters
  • output – The output tensor.

  • input – The input tensor.

  • segment_ids – The tensor whose shape is a prefix of input.shape, the values must be less than num_segments.

  • num_segments – The output tensor’s dim0, should equal the number of distinct segment IDs.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topstfGatherNd (topsatenTensor &output, const topsatenTensor &params, const topsatenTensor &indices, const char *const name, int32_t batch_dims=0, topsStream_t stream=nullptr)

Gather slices from params into a Tensor with shape specified by indices.

Parameters
  • output – The output tensor.

  • params – A Tensor. The tensor from which to gather values.

  • indices – A Tensor. Must be int32 Index tensor. The total size needs to be less than 1022MB.

  • name – A name for the operation (optional).

  • batch_dims – An integer or a scalar ‘Tensor’. The number of batch dimensions.

  • stream – Tops stream.

Returns

topsatenStatus_t.

2.9. 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 topsvllmMemoryEfficientAttentionV1 (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 topsatenScalar_t &mask_mode, const topsatenTensor &alibi_slopes, const topsatenScalar_t &sliding_window, 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.

  • mask_mode – Attention mask mode.

  • alibi_slopes – Input tensor alibi slopes.

  • sliding_window – Input tensor sliding window.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsvllmMemEfficientAttentionV1 (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, const topsatenScalar_t &mask_mode, const topsatenTensor &alibi_slopes, const topsatenScalar_t &sliding_window, 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.

  • mask_mode – Attention mask mode.

  • alibi_slopes – Input tensor alibi slopes.

  • sliding_window – Input tensor sliding window.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsvllmSiluMulQuant (topsatenTensor &out, const topsatenTensor &in, const topsatenTensor &scaling, topsStream_t stream=nullptr)

This function applies the Sigmoid Linear Unit (SiLU) and mul function, then quantize to out pointer.

Parameters
  • out – The output tensor.

  • in – The input tensor.

  • scaling – Scaling tensor for quantize.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsvllmGeluMulQuant (topsatenTensor &out, const topsatenTensor &in, const topsatenTensor &scaling, topsStream_t stream=nullptr)

This function applies the GeLUErf and mul function, then quantize to out pointer.

Parameters
  • out – The output tensor.

  • in – The input tensor.

  • scaling – Scaling tensor for quantize.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsvllmGeluTanhMulQuant (topsatenTensor &out, const topsatenTensor &in, const topsatenTensor &scaling, topsStream_t stream=nullptr)

This function applies the GeLUTanh and mul function, then quantize to out pointer.

Parameters
  • out – The output tensor.

  • in – The input tensor.

  • scaling – Scaling tensor for quantize.

  • 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 topsvllmGeluTanhQuant (topsatenTensor &out, const topsatenTensor &in, const topsatenTensor &scale, topsStream_t stream=nullptr)

Gelu tanh quantize operator.

Parameters
  • out – The output tensor. Support datatype: int8.

  • in – Input tensor. Support datatype: bf16/fp16.

  • scale – Scale tensor for quant.Support datatype: bf16/fp16.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsvllmGeluQuant (topsatenTensor &out, const topsatenTensor &in, const topsatenTensor &scale, topsStream_t stream=nullptr)

Gelu quantize operator.

Parameters
  • out – The output tensor. Support datatype: int8.

  • in – Input tensor. Support datatype: bf16/fp16.

  • scale – Scale tensor for quant.Support datatype: bf16/fp16.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsvllmGeluNewQuant (topsatenTensor &out, const topsatenTensor &in, const topsatenTensor &scale, topsStream_t stream=nullptr)

Gelu new quantize operator.

Parameters
  • out – The output tensor. Support datatype: int8.

  • in – Input tensor. Support datatype: bf16/fp16.

  • scale – Scale tensor for quant. Support datatype: bf16/fp16.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsvllmSiluQuant (topsatenTensor &out, const topsatenTensor &in, const topsatenTensor &scale, topsStream_t stream=nullptr)

Silu quantize operator.

Parameters
  • out – The output tensor. Support datatype: int8.

  • in – Input tensor. Support datatype: bf16/fp16.

  • scale – Scale tensor for quant. Support datatype: bf16/fp16.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsvllmGeluFastQuant (topsatenTensor &out, const topsatenTensor &in, const topsatenTensor &scale, topsStream_t stream=nullptr)

Gelu fast quantize operator.

Parameters
  • out – The output tensor. Support datatype: int8.

  • in – Input tensor. Support datatype: bf16/fp16.

  • scale – Scale tensor for quant. Support datatype: bf16/fp16.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsvllmGeluTanhAsymQuant (topsatenTensor &out, const topsatenTensor &in, const topsatenTensor &scale, const topsatenTensor &qzero, topsStream_t stream=nullptr)

Gelu tanh asym quantize operator.

Parameters
  • out – The output tensor. Support datatype: uint8.

  • in – Input tensor. Support datatype: bf16/fp16.

  • scale – Scale tensor for quant.Support datatype: bf16/fp16.

  • qzero – Qzero tensor for quant. Support datatype: bf16/fp16.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsvllmGeluAsymQuant (topsatenTensor &out, const topsatenTensor &in, const topsatenTensor &scale, const topsatenTensor &qzero, topsStream_t stream=nullptr)

Gelu tanh asym quantize operator.

Parameters
  • out – The output tensor. Support datatype: uint8.

  • in – Input tensor. Support datatype: bf16/fp16.

  • scale – Scale tensor for quant.Support datatype: bf16/fp16.

  • qzero – Qzero tensor for quant. Support datatype: bf16/fp16.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsvllmGeluNewAsymQuant (topsatenTensor &out, const topsatenTensor &in, const topsatenTensor &scale, const topsatenTensor &qzero, topsStream_t stream=nullptr)

Gelu new asym quantize operator.

Parameters
  • out – The output tensor. Support datatype: uint8.

  • in – Input tensor. Support datatype: bf16/fp16.

  • scale – Scale tensor for quant. Support datatype: bf16/fp16.

  • qzero – Qzero tensor for quant. Support datatype: bf16/fp16.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsvllmSiluAsymQuant (topsatenTensor &out, const topsatenTensor &in, const topsatenTensor &scale, const topsatenTensor &qzero, topsStream_t stream=nullptr)

Silu asym quantize operator.

Parameters
  • out – The output tensor. Support datatype: uint8.

  • in – Input tensor. Support datatype: bf16/fp16.

  • scale – Scale tensor for quant. Support datatype: bf16/fp16.

  • qzero – Qzero tensor for quant. Support datatype: bf16/fp16.

  • stream – Tops stream.

Returns

topsatenStatus_t.

topsatenStatus_t TOPSATEN_EXPORT topsvllmGeluFastAsymQuant (topsatenTensor &out, const topsatenTensor &in, const topsatenTensor &scale, const topsatenTensor &qzero, topsStream_t stream=nullptr)

Gelu fast asym quantize operator.

Parameters
  • out – The output tensor. Support datatype: uint8.

  • in – Input tensor. Support datatype: bf16/fp16.

  • scale – Scale tensor for quant. Support datatype: bf16/fp16.

  • qzero – Qzero tensor for quant. Support datatype: bf16/fp16.

  • 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 topsvllmReshapeAndCacheQuant (topsatenTensor &key_cache, topsatenTensor &value_cache, const topsatenTensor &key, const topsatenTensor &value, const topsatenTensor &slot_mapping, const char *kv_cache_dtype, const float k_scale=1.0f, const float k_zp=0.0f, const float v_scale=1.0f, const float v_zp=0.0f, topsStream_t stream=nullptr)

Reshape and cache quant operator.

Parameters
  • key_cache – The key cache tensor. Shape: [num_blocks, num_heads, head_size/x, block_size, x].

  • value_cache – The value cache tensor. Shape: [num_blocks, num_heads, head_size, block_size].

  • key – Key tensor. Shape: [num_tokens, num_heads, head_size].

  • value – Value tensor. Shape: [num_tokens, num_heads, head_size].

  • slot_mapping – Slot mapping tensor. Shape: [num_tokens].

  • kv_cache_dtype – Quant type of kv cache. choose in [int8, uint8, auto].

  • k_scale – Scaling factor for key quantization.

  • k_zp – Qzero for key quantization.

  • v_scale – Scaling factor for value quantization.

  • v_zp – Qzero factor for value quantization.

  • 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 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, const char *kv_cache_dtype, const topsatenScalar_t &k_scale, const topsatenScalar_t &k_zp, const topsatenScalar_t &v_scale, const topsatenScalar_t &v_zp, const topsatenTensor &out_scales, topsStream_t stream=nullptr)

Paged attention v1 quant 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.

  • kv_cache_dtype – “int8” means int8, “auto” means fp16.

  • k_scale – K_scale.

  • k_zp – K_zp.

  • v_scale – V_scale.

  • v_zp – V_zp.

  • 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, const char *kv_cache_dtype, const topsatenScalar_t &k_scale, const topsatenScalar_t &k_zp, const topsatenScalar_t &v_scale, const topsatenScalar_t &v_zp, topsatenTensor &out_scales, topsStream_t stream=nullptr)
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 topsvllmRmsNormQuant (topsatenTensor &output, const topsatenTensor &input, const topsatenTensor &weight, const topsatenTensor &scaling, const topsatenScalar_t &epsilon, topsStream_t stream=nullptr)

Compute RMSNormQuant 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].

  • scaling – Scaling 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 topsvllmFusedAddRmsNormQuant (topsatenTensor &output, const topsatenTensor &input, const topsatenTensor &residual, const topsatenTensor &weight, float epsilon, const topsatenTensor &scaling, topsStream_t stream=nullptr)

Fused Add and RMS Normalization Quant.

Parameters
  • output – Output 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.

  • scaling – Scaling tensor of shape [hidden_size].

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

topsatenStatus_t TOPSATEN_EXPORT topsvllmInvokeFusedMoeKernel (topsatenTensor &C, const topsatenTensor &A, const topsatenTensor &B, const topsatenTensor &bias, 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.

  • bias – The bias tensor with shape (N).

  • 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.10. 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.