# This is the Python adaptation and derivative work of Myia (https://github.com/mila-iqia/myia/).
#
# Copyright 2021-2024 Huawei Technologies Co., Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ============================================================================
"""The names of functional part are summarized here."""

from mindspore.common._register_for_tensor import tensor_operator_registry
from mindspore.ops import _constants
from mindspore.ops.function import *
from mindspore.ops.function.array_func import chunk_ext, zero_
from mindspore.ops.function.math_func import all, argmax_ext
from mindspore.ops.function.random_func import uniform_ext
from mindspore.ops import operations as P
from mindspore.ops.operations import array_ops
from mindspore.ops.operations._sequence_ops import TensorToTuple
from mindspore.ops.primitive import Primitive
from mindspore.ops.operations import _grad_ops, _csr_ops, _inner_ops, linalg_ops, _sequence_ops, other_ops
from mindspore.ops.operations.math_ops import Median
from mindspore.ops.operations.array_ops import UniqueConsecutive
from mindspore.ops.operations.nn_ops import AdaptiveMaxPool2D
from mindspore.ops.operations.math_ops import Roll
from mindspore.ops.composite.math_ops import mm
from mindspore.ops.function.math_func import dot
from mindspore.ops import auto_generate
from mindspore.ops.auto_generate import cast
from mindspore.ops_generate.gen_ops_inner_prim import DtypeToEnum
from mindspore.ops.operations.manually_defined.ops_def import scalar_div, scalar_mod, scalar_add, scalar_mul, \
    scalar_sub, scalar_gt, scalar_ge, scalar_le, scalar_lt, scalar_eq, scalar_floordiv, scalar_log, scalar_pow, \
    scalar_uadd, scalar_usub, flash_attention_score

typeof = Primitive('typeof')
hastype = Primitive('hastype')
_cast = P.Cast()
dtype = P.DType()
isconstant = _inner_ops.IsConstant()
isconstant.set_const_prim(True)
merge = P.Merge()
geswitch = P.GeSwitch()
reduce_sum = P.ReduceSum()
reduce_max = P.ReduceMax()
reduce_min = P.ReduceMin()
reduce_mean = P.ReduceMean()
tensor_range = P.Range()
tensor_scatter_update = P.TensorScatterUpdate()
scatter_nd_update = P.ScatterNdUpdate()
mixed_precision_cast = _inner_ops.MixedPrecisionCast()
_py_interpret = other_ops.PyInterpret()
_dtype_to_enum = DtypeToEnum()

# Dynamic shape
is_sequence_value_unknown = Primitive("IsShapeUnKnown")
is_sequence_shape_unknown = Primitive("IsDimUnKnown")
is_dynamic_sequence_element_unknown = Primitive("IsElementUnknown")
is_tensor_bool_cond = Primitive("IsTensorBoolCond")

partial = P.Partial()
# depend: mount a node to another node
depend = P.Depend()
identity = P.identity()
# tuple/list/scalar ops
tuple_setitem = Primitive('tuple_setitem')
tuple_getitem = Primitive(_constants.kTupleGetItem)
list_getitem = Primitive('list_getitem')
list_setitem = Primitive('list_setitem')
dict_getitem = Primitive('dict_getitem')
dict_setitem = Primitive('dict_setitem')
tuple_div = Primitive("tuple_div")
tuple_len = Primitive("sequence_len")
list_len = Primitive("sequence_len")
tuple_reversed = Primitive("tuple_reversed")
make_range = Primitive("make_range")
make_tuple = Primitive('MakeTuple')
make_dict = Primitive('make_dict')
make_list = Primitive('make_list')
make_slice = Primitive('make_slice')
tuple_equal = Primitive("tuple_equal")
list_equal = Primitive("list_equal")
scalar_ne = Primitive('scalar_ne')
string_eq = Primitive('string_eq')
string_concat = Primitive('string_concat')
bool_not = Primitive('BoolNot')
bool_or = Primitive("bool_or")
bool_and = Primitive("bool_and")
bool_eq = Primitive("bool_eq")
array_to_scalar = Primitive('array_to_scalar')
is_ = Primitive("is_")
is_not = Primitive("is_not")
in_dict = Primitive("in_dict")
not_in_dict = Primitive("not_in_dict")
broadcast_gradient_args = Primitive('BroadcastGradientArgs')
array_reduce = Primitive('array_reduce')
distribute = Primitive('distribute')
embed = Primitive('embed')
ref_to_embed = _grad_ops.RefToEmbed()
environ_create = Primitive('EnvironCreate')
environ_set = Primitive('EnvironSet')
environ_get = Primitive('EnrironGet')
environ_add = Primitive('EnvironAdd')
J = Primitive('J')
SliceGetItem = Primitive("SliceGetItem")
switch = Primitive('Switch')
switch_layer = Primitive('switch_layer')
# for sum bprop
reduced_shape = Primitive("reduced_shape")
# shape_mul:input must be shape multiply elements in tuple(shape)
shape_mul = _sequence_ops.shape_mul()

setattr(tensor_operator_registry, 'tuple_to_tensor',
        _sequence_ops.TupleToTensor)
setattr(tensor_operator_registry, 'add', add)
setattr(tensor_operator_registry, 'softmax', softmax)
setattr(tensor_operator_registry, 'addr', addr)
setattr(tensor_operator_registry, 'addcdiv', addcdiv)
setattr(tensor_operator_registry, 'addcmul', addcmul)
setattr(tensor_operator_registry, 'all', all)
setattr(tensor_operator_registry, 'angle', angle)
setattr(tensor_operator_registry, 'any', any)
setattr(tensor_operator_registry, 'atan2', atan2)
setattr(tensor_operator_registry, 'abs', abs)
setattr(tensor_operator_registry, 'baddbmm', baddbmm)
setattr(tensor_operator_registry, 'geqrf', geqrf)
setattr(tensor_operator_registry, 'histc', histc)
setattr(tensor_operator_registry, 'real', real)
setattr(tensor_operator_registry, 'reciprocal', reciprocal)
setattr(tensor_operator_registry, 'rsqrt', rsqrt)
setattr(tensor_operator_registry, 'bincount', bincount)
setattr(tensor_operator_registry, 'slogdet', slogdet)
setattr(tensor_operator_registry, 'trace', trace)
setattr(tensor_operator_registry, 'tracev2', auto_generate.trace_v2_op)
setattr(tensor_operator_registry, 'tril', tril)
setattr(tensor_operator_registry, 'chunk', chunk)
setattr(tensor_operator_registry, 'count_nonzero', count_nonzero)
setattr(tensor_operator_registry, 'sqrt', sqrt)
setattr(tensor_operator_registry, 'square', square)
setattr(tensor_operator_registry, 'sub', sub)
setattr(tensor_operator_registry, 'triu', triu)
setattr(tensor_operator_registry, 'tan', tan)
setattr(tensor_operator_registry, 't', t)
setattr(tensor_operator_registry, 'cauchy', P.Cauchy)
setattr(tensor_operator_registry, 'log_normal', P.LogNormalReverse)
setattr(tensor_operator_registry, 'acos', acos)
setattr(tensor_operator_registry, 'cos', cos)
setattr(tensor_operator_registry, 'acosh', acosh)
setattr(tensor_operator_registry, 'cosh', cosh)
setattr(tensor_operator_registry, 'cov', cov)
setattr(tensor_operator_registry, 'asin', asin)
setattr(tensor_operator_registry, 'sin', sin)
setattr(tensor_operator_registry, 'sinc', sinc)
setattr(tensor_operator_registry, 'pow', pow)
setattr(tensor_operator_registry, 'negative', neg)
setattr(tensor_operator_registry, 'amin', amin)
setattr(tensor_operator_registry, 'amax', amax)
setattr(tensor_operator_registry, 'aminmax', aminmax)
setattr(tensor_operator_registry, 'mean', mean)
setattr(tensor_operator_registry, 'prod', prod)
setattr(tensor_operator_registry, 'round', round)
setattr(tensor_operator_registry, 'reshape', reshape)
setattr(tensor_operator_registry, 'reverse', reverse)
setattr(tensor_operator_registry, 'reverse_sequence', reverse_sequence)
setattr(tensor_operator_registry, 'xlogy', xlogy)
setattr(tensor_operator_registry, 'flatten', flatten)
setattr(tensor_operator_registry, 'transpose', transpose)
setattr(tensor_operator_registry, 'broadcast_to', broadcast_to)
setattr(tensor_operator_registry, 'matmul', matmul)
setattr(tensor_operator_registry, 'inner', inner)
setattr(tensor_operator_registry, 'xdivy', xdivy)
setattr(tensor_operator_registry, 'argmax', argmax)
setattr(tensor_operator_registry, 'argmin', argmin)
setattr(tensor_operator_registry, 'cumsum', P.CumSum)
setattr(tensor_operator_registry, 'cummin', cummin)
setattr(tensor_operator_registry, 'cummax', cummax)
setattr(tensor_operator_registry, 'nelement', numel)
setattr(tensor_operator_registry, 'numel', numel)
setattr(tensor_operator_registry, 'positive', positive)
setattr(tensor_operator_registry, 'permute', permute)
setattr(tensor_operator_registry, 'remainder', remainder)
setattr(tensor_operator_registry, 'index_fill', index_fill)
setattr(tensor_operator_registry, 'index_select', index_select)
setattr(tensor_operator_registry, 'flip', flip)
setattr(tensor_operator_registry, 'fliplr', fliplr)
setattr(tensor_operator_registry, 'flipud', flipud)
setattr(tensor_operator_registry, 'float_power', float_power)
setattr(tensor_operator_registry, 'fmax', fmax)
setattr(tensor_operator_registry, 'fmin', fmin)
setattr(tensor_operator_registry, 'fmod', fmod)
setattr(tensor_operator_registry, 'is_floating_point', is_floating_point)
setattr(tensor_operator_registry, 'bitwise_and', bitwise_and)
setattr(tensor_operator_registry, 'bitwise_or', bitwise_or)
setattr(tensor_operator_registry, 'bitwise_xor', bitwise_xor)
setattr(tensor_operator_registry, 'bitwise_left_shift', bitwise_left_shift)
setattr(tensor_operator_registry, 'bitwise_right_shift', bitwise_right_shift)
setattr(tensor_operator_registry, 'ger', ger)
setattr(tensor_operator_registry, 'reduce_max', P.ReduceMax)
setattr(tensor_operator_registry, 'reduce_min', P.ReduceMin)
setattr(tensor_operator_registry, 'random_categorical', random_categorical)
setattr(tensor_operator_registry, 'mirror_pad', P.MirrorPad)
setattr(tensor_operator_registry, 'minimum', minimum)
setattr(tensor_operator_registry, 'matrix_power', matrix_power)
setattr(tensor_operator_registry, 'det', det)
setattr(tensor_operator_registry, 'dot', dot)
setattr(tensor_operator_registry, 'outer', outer)
setattr(tensor_operator_registry, 'log1p', log1p)
setattr(tensor_operator_registry, 'logdet', logdet)
setattr(tensor_operator_registry,
        'log_matrix_determinant', log_matrix_determinant)
setattr(tensor_operator_registry, 'matrix_determinant', matrix_determinant)
setattr(tensor_operator_registry, 'ceil', ceil)
setattr(tensor_operator_registry, 'fillv2', P.FillV2)
setattr(tensor_operator_registry, 'tile', tile)
setattr(tensor_operator_registry, 'logit', logit)
setattr(tensor_operator_registry, 'sum', sum)
setattr(tensor_operator_registry, 'split', split)
setattr(tensor_operator_registry, 'tensor_split', tensor_split)
setattr(tensor_operator_registry, 'vsplit', vsplit)
setattr(tensor_operator_registry, 'hsplit', hsplit)
setattr(tensor_operator_registry, 'dsplit', dsplit)
setattr(tensor_operator_registry, 'zeros_like', zeros_like)
setattr(tensor_operator_registry, 'zero_', zero_)
setattr(tensor_operator_registry, 'scalar_to_tensor', scalar_to_tensor)
setattr(tensor_operator_registry, 'stop_gradient', stop_gradient)
setattr(tensor_operator_registry, 'masked_fill', masked_fill)
setattr(tensor_operator_registry, 'masked_select', masked_select)
setattr(tensor_operator_registry, 'nonzero', nonzero)
setattr(tensor_operator_registry, 'i0', i0)
setattr(tensor_operator_registry, 'isclose', isclose)
setattr(tensor_operator_registry, 'isneginf', isneginf)
setattr(tensor_operator_registry, 'isposinf', isposinf)
setattr(tensor_operator_registry, 'isreal', isreal)
setattr(tensor_operator_registry, 'inv', inv)
setattr(tensor_operator_registry, 'digamma', digamma)
setattr(tensor_operator_registry, 'lgamma', lgamma)
setattr(tensor_operator_registry, 'logaddexp', logaddexp)
setattr(tensor_operator_registry, 'logaddexp2', logaddexp2)
setattr(tensor_operator_registry, 'logcumsumexp', logcumsumexp)
setattr(tensor_operator_registry, 'logsumexp', logsumexp)
setattr(tensor_operator_registry, 'inverse', inverse)
setattr(tensor_operator_registry, 'invert', invert)
setattr(tensor_operator_registry, 'hardshrink', hardshrink)
setattr(tensor_operator_registry, 'heaviside', heaviside)
setattr(tensor_operator_registry, 'hypot', hypot)
setattr(tensor_operator_registry, 'searchsorted', P.SearchSorted)
setattr(tensor_operator_registry, 'soft_shrink', soft_shrink)
setattr(tensor_operator_registry, 'svd', linalg_ops.Svd)
setattr(tensor_operator_registry, 'diag', diag)
setattr(tensor_operator_registry, 'diagflat', diagflat)
setattr(tensor_operator_registry, 'unique_consecutive', UniqueConsecutive)
setattr(tensor_operator_registry, 'unique_with_pad', unique_with_pad)
setattr(tensor_operator_registry, 'inplace_update', inplace_update)
setattr(tensor_operator_registry, 'col2im', col2im)
setattr(tensor_operator_registry, 'standard_laplace', P.StandardLaplace)
setattr(tensor_operator_registry, 'erf', erf)
setattr(tensor_operator_registry, 'erfc', erfc)
setattr(tensor_operator_registry, 'standard_normal', P.StandardNormal)
setattr(tensor_operator_registry, 'sigmoid', sigmoid)
setattr(tensor_operator_registry, 'median', Median)
setattr(tensor_operator_registry, 'tanh', tanh)
setattr(tensor_operator_registry, 'exp', exp)
setattr(tensor_operator_registry, 'addbmm', addbmm)
setattr(tensor_operator_registry, 'addmm', addmm)
setattr(tensor_operator_registry, 'addmm_', auto_generate.inplace_addmm_op)
setattr(tensor_operator_registry, 'addmv', addmv)
setattr(tensor_operator_registry, 'adjoint', adjoint)
setattr(tensor_operator_registry, 'asinh', asinh)
setattr(tensor_operator_registry, 'arcsinh', arcsinh)
setattr(tensor_operator_registry, 'atan', atan)
setattr(tensor_operator_registry, 'atanh', atanh)
setattr(tensor_operator_registry, 'arctanh', arctanh)
setattr(tensor_operator_registry, 'bmm', bmm)
setattr(tensor_operator_registry, 'conj', conj)
setattr(tensor_operator_registry, 'cross', cross)
setattr(tensor_operator_registry, 'erfinv', erfinv)
setattr(tensor_operator_registry, 'less_equal', less_equal)
setattr(tensor_operator_registry, 'lcm', lcm)
setattr(tensor_operator_registry, 'ldexp', ldexp)
setattr(tensor_operator_registry, 'clamp', clamp)
setattr(tensor_operator_registry, 'fold', fold)
setattr(tensor_operator_registry, 'unfold', unfold)
setattr(tensor_operator_registry, 'diagonal', diagonal)
setattr(tensor_operator_registry, 'diagonal_scatter', diagonal_scatter)
setattr(tensor_operator_registry, 'index_add', index_add)
setattr(tensor_operator_registry, 'greater', greater)
setattr(tensor_operator_registry, 'greater_equal', greater_equal)
setattr(tensor_operator_registry, 'igamma', igamma)
setattr(tensor_operator_registry, 'igammac', igammac)
setattr(tensor_operator_registry, 'lu_solve', lu_solve)
setattr(tensor_operator_registry, 'nextafter', nextafter)
setattr(tensor_operator_registry, 'qr', qr)
setattr(tensor_operator_registry, 'ormqr', ormqr)
setattr(tensor_operator_registry, 'masked_scatter', array_ops.MaskedScatter)
setattr(tensor_operator_registry, 'index_put', array_ops.IndexPut)
setattr(tensor_operator_registry, 'quantile', quantile)
setattr(tensor_operator_registry, 'nanquantile', nanquantile)
setattr(tensor_operator_registry, 'orgqr', orgqr)
# ms cannot support Tensor(True) compare
setattr(tensor_operator_registry, '__eq__', equal)
setattr(tensor_operator_registry, '__ne__', not_equal)
setattr(tensor_operator_registry, '__neg__', neg)
setattr(tensor_operator_registry, '__lt__', tensor_lt)
setattr(tensor_operator_registry, '__le__', tensor_le)
setattr(tensor_operator_registry, '__gt__', tensor_gt)
setattr(tensor_operator_registry, '__ge__', tensor_ge)
setattr(tensor_operator_registry, '__logical_not__', logical_not)
setattr(tensor_operator_registry, 'gt', gt)
setattr(tensor_operator_registry, 'ge', ge)
setattr(tensor_operator_registry, 'shape', shape)
setattr(tensor_operator_registry, 'squeeze', squeeze)
setattr(tensor_operator_registry, 'unsqueeze', unsqueeze)
setattr(tensor_operator_registry, 'expand_dims', expand_dims)
setattr(tensor_operator_registry, 'contiguous', auto_generate.contiguous)
# support GE backend for no compare operators
setattr(tensor_operator_registry, 'cast', _cast)
setattr(tensor_operator_registry, 'shape_mul', shape_mul)
setattr(tensor_operator_registry, 'concatenate', concat)
setattr(tensor_operator_registry, 'fill', fill)
setattr(tensor_operator_registry, 'fills', fills)
setattr(tensor_operator_registry, 'fill_diagonal', P.FillDiagonal)
setattr(tensor_operator_registry, 'eye', eye)
setattr(tensor_operator_registry, 'eigvals', eigvals)
setattr(tensor_operator_registry, 'reduce_sum', reduce_sum)
setattr(tensor_operator_registry, 'reducesum', P.ReduceSum)
setattr(tensor_operator_registry, 'tensor_slice', tensor_slice)
setattr(tensor_operator_registry, 'select', select)
setattr(tensor_operator_registry, 'uniform', uniform_ext)
setattr(tensor_operator_registry, 'gather', gather)
setattr(tensor_operator_registry, 'gather_d', gather_d)
setattr(tensor_operator_registry, 'gather_elements', gather_elements)
setattr(tensor_operator_registry, 'gather_nd', gather_nd)
setattr(tensor_operator_registry, 'stack', stack)
setattr(tensor_operator_registry, 'unstack', unstack)
setattr(tensor_operator_registry, 'unbind', unstack)
setattr(tensor_operator_registry, 'log', log)
setattr(tensor_operator_registry, 'log10', log10)
setattr(tensor_operator_registry, 'log2', log2)
setattr(tensor_operator_registry, 'lerp', lerp)
setattr(tensor_operator_registry, 'floor', floor)
setattr(tensor_operator_registry, 'floor_divide', floor_divide)
# support sparse tensor operators
setattr(tensor_operator_registry, 'csr_add', csr_add)
setattr(tensor_operator_registry, 'csr_mul', csr_mul)
setattr(tensor_operator_registry, 'csr2coo', csr2coo)
setattr(tensor_operator_registry, 'coo2csr', coo2csr)
setattr(tensor_operator_registry, 'csr_div', csr_div)
setattr(tensor_operator_registry, 'csr_mv', csr_mv)
setattr(tensor_operator_registry, 'csr_mm_akg', _csr_ops.CSRMM)
setattr(tensor_operator_registry, 'csr_mm', csr_mm)
setattr(tensor_operator_registry, 'csr_reduce_sum', csr_reduce_sum)
setattr(tensor_operator_registry, 'dense_to_sparse_csr', dense_to_sparse_csr)
setattr(tensor_operator_registry, 'dense_to_sparse_coo', dense_to_sparse_coo)
setattr(tensor_operator_registry, 'csr_to_dense', csr_to_dense)
setattr(tensor_operator_registry, 'narrow', narrow)
setattr(tensor_operator_registry, 'sort', sort)
setattr(tensor_operator_registry, 'argsort', argsort)
setattr(tensor_operator_registry, 'msort', msort)
setattr(tensor_operator_registry, 'mm', mm)
setattr(tensor_operator_registry, 'nan_to_num', nan_to_num)
setattr(tensor_operator_registry, 'nansum', nansum)
setattr(tensor_operator_registry, 'nanmean', nanmean)
setattr(tensor_operator_registry, 'nanmedian', nanmedian)
setattr(tensor_operator_registry, 'csr_to_coo', csr_to_coo)
setattr(tensor_operator_registry, 'zeros', zeros)
setattr(tensor_operator_registry, 'ones', ones)
setattr(tensor_operator_registry, 'unsorted_segment_min', unsorted_segment_min)
setattr(tensor_operator_registry, 'unsorted_segment_max', unsorted_segment_max)
setattr(tensor_operator_registry, 'unsorted_segment_prod', unsorted_segment_prod)
setattr(tensor_operator_registry, 'scatter', scatter)
setattr(tensor_operator_registry, 'tensor_scatter_update', tensor_scatter_update)
setattr(tensor_operator_registry, 'tensor_scatter_mul', tensor_scatter_mul)
setattr(tensor_operator_registry, 'tensor_scatter_div', tensor_scatter_div)
setattr(tensor_operator_registry, 'tensor_scatter_min', tensor_scatter_min)
setattr(tensor_operator_registry, 'tensor_scatter_max', tensor_scatter_max)
setattr(tensor_operator_registry, 'tensor_scatter_sub', tensor_scatter_sub)
setattr(tensor_operator_registry, 'tensor_scatter_add', tensor_scatter_add)
setattr(tensor_operator_registry, 'slice_scatter', slice_scatter)
setattr(tensor_operator_registry, 'select_scatter', select_scatter)
setattr(tensor_operator_registry, 'bernoulli', bernoulli)
setattr(tensor_operator_registry, 'poisson', P.Poisson)
setattr(tensor_operator_registry, 'randperm', P.Randperm)
setattr(tensor_operator_registry, 'multinomial', multinomial)
setattr(tensor_operator_registry, 'norm', norm)
setattr(tensor_operator_registry, 'renorm', renorm)
setattr(tensor_operator_registry, 'adaptive_max_pool2d', AdaptiveMaxPool2D)
setattr(tensor_operator_registry, 'coalesce', coalesce)
setattr(tensor_operator_registry, 'argmax_with_value', max)
setattr(tensor_operator_registry, 'argmin_with_value', min)
setattr(tensor_operator_registry, 'argwhere', argwhere)
setattr(tensor_operator_registry, 'coo_add', coo_add)
setattr(tensor_operator_registry, 'topk', topk)
setattr(tensor_operator_registry, 'isfinite', isfinite)
setattr(tensor_operator_registry, 'to', _cast)
setattr(tensor_operator_registry, 'bool', _cast)
setattr(tensor_operator_registry, 'float', _cast)
setattr(tensor_operator_registry, 'half', _cast)
setattr(tensor_operator_registry, 'int', _cast)
setattr(tensor_operator_registry, 'long', _cast)
setattr(tensor_operator_registry, 'byte', _cast)
setattr(tensor_operator_registry, 'cholesky', cholesky)
setattr(tensor_operator_registry, 'cholesky_inverse', cholesky_inverse)
setattr(tensor_operator_registry, 'cholesky_solve', cholesky_solve)
setattr(tensor_operator_registry, 'expand', broadcast_to)
setattr(tensor_operator_registry, 'tensortotuple', TensorToTuple)
setattr(tensor_operator_registry, 'cumprod', cumprod)
setattr(tensor_operator_registry, 'diff', diff)
setattr(tensor_operator_registry, 'div', div)
setattr(tensor_operator_registry, 'equal', equal)
setattr(tensor_operator_registry, 'expm1', expm1)
setattr(tensor_operator_registry, 'frac', frac)
setattr(tensor_operator_registry, 'isinf', isinf)
setattr(tensor_operator_registry, 'isnan', isnan)
setattr(tensor_operator_registry, 'is_complex', is_complex)
setattr(tensor_operator_registry, 'le', le)
setattr(tensor_operator_registry, 'less', less)
setattr(tensor_operator_registry, 'logical_and', logical_and)
setattr(tensor_operator_registry, 'logical_not', logical_not)
setattr(tensor_operator_registry, 'logical_or', logical_or)
setattr(tensor_operator_registry, 'logical_xor', logical_xor)
setattr(tensor_operator_registry, 'lstsq', lstsq)
setattr(tensor_operator_registry, 'mvlgamma', mvlgamma)
setattr(tensor_operator_registry, 'maximum', maximum)
setattr(tensor_operator_registry, 'max', max)
setattr(tensor_operator_registry, 'min', min)
setattr(tensor_operator_registry, 'mul', mul)
setattr(tensor_operator_registry, 'multiply', multiply)
setattr(tensor_operator_registry, 'moveaxis', moveaxis)
setattr(tensor_operator_registry, 'movedim', movedim)
setattr(tensor_operator_registry, 'neg', neg)
setattr(tensor_operator_registry, 'ne', ne)
setattr(tensor_operator_registry, 'not_equal', not_equal)
setattr(tensor_operator_registry, 'sgn', sgn)
setattr(tensor_operator_registry, 'sign', sign)
setattr(tensor_operator_registry, 'signbit', signbit)
setattr(tensor_operator_registry, 'sinh', sinh)
setattr(tensor_operator_registry, 'trunc', trunc)
setattr(tensor_operator_registry, 'where', where)
setattr(tensor_operator_registry, 'imag', imag)
setattr(tensor_operator_registry, 'repeat_interleave', repeat_interleave)
setattr(tensor_operator_registry, 'rad2deg', rad2deg)
setattr(tensor_operator_registry, 'deg2rad', deg2rad)
setattr(tensor_operator_registry, 'copy_', auto_generate.copy_ext)
setattr(tensor_operator_registry, 'add_', auto_generate.inplace_add_ext)
setattr(tensor_operator_registry, 'adds_', auto_generate.inplace_adds_ext)
setattr(tensor_operator_registry, 'copysign', copysign)
setattr(tensor_operator_registry, 'roll', Roll)
setattr(tensor_operator_registry, 'rot90', rot90)
setattr(tensor_operator_registry, 'swapaxes', swapaxes)
setattr(tensor_operator_registry, 'swapdims', swapdims)
setattr(tensor_operator_registry, 'repeat_elements', repeat_elements)
setattr(tensor_operator_registry, 'top_k', top_k)

__all__ = [name for name in dir() if name[0] != "_"]
__all__.remove('Primitive')
__all__.remove('argmax_ext')
__all__.remove('uniform_ext')
