// List of ops and their informal types: used to generate Go and C code with the corresponding enum types and other
// boilerplate code.
//
// The program gopjrt/internal/cmd/xlabuilder_codegen is used to generate the code. It is configured as a `go:generate`
// rule in xlabuilder package.
//
// Format:
// - <op_name>:<op_type>, where <op_name> is used to generate enums and function names, and <op_type> is used
//   to condition the generation of code.
// - Any empty lines or lines starting with // or # are comments.
// - Any line with a node type should not have anything else (no comments after the node type name)
// - Order matter
// - Comments starting with // just preceding an entry becomes comments to the corresponding function.
//
// **IMPORTANT** Change in the order of this file will make binary releases among different versions incompatible.
// For backward (or forward, depending on the reference point) compatibility, pls only add new ops in the end,
// even if things look out of order.

# Invalid should always be the first one.
Invalid:invalid

// Special ops:
Parameter:special
Iota:special
Constant:special
Identity:special
ConvertDType:special
Where:special
Tuple:special
GetTupleElement:special
Reshape:special
Broadcast:special
BroadcastInDim:special
Transpose:special
Call:special
Reduce:special
ReduceWindow:special
Concatenate:special
Slice:special
ArgMinMax:special
Pad:special
Gather:special
Scatter:special
SelectAndScatter:special
# ConvGeneralDilated is called simply "ConvGeneral" in package xlabuilder
ConvGeneralDilated:special
Reverse:special
DotGeneral:special
Fft:special
BatchNormTraining:special
BatchNormInference:special
BatchNormGrad:special
RngBitGenerator:special
While:special

# One-argument ops:

Abs:one
Neg:one
Exp:one
Expm1:one
Floor:one
Ceil:one
Round:one
Log:one
// Log1p returns the expression log(x+1).
Log1p:one
LogicalNot:one
// Logistic returns the element-wise expression 1/(1+exp(-x)). Also known as the Sigmoid function.
Logistic:one
// Sign returns element-wise +1, +/-0 or -1 depending on the sign of x. It returns NaN if the input is NaN.
Sign:one
// Clz returns element-wise the "count leading zeros" bits of input node x -- for integer values.
Clz:one
Cos:one
Sin:one
Tanh:one
Sqrt:one
// Rsqrt returns the element-wise reciprocal of square root operation 1/sqrt(x).
Rsqrt:one
// Imag returns the imaginary part of a complex number. It returns 0 if the x is a float number.
Imag:one
// Real return the real part of a complex number. It returns x if the x is a float number.
Real:one
// Conj returns the conjugate of a complex number. E.g: Conj(1+3i) = 1-3i
Conj:one

# Two-arguments ops:

// Add returns the element-wise sum of the two values.
// Standard broadcasting rules apply (see documentation).
Add:two
// Mul returns the element-wise multiplication of the two values.
// Standard broadcasting rules apply (see documentation).
Mul:two
// Sub returns the element-wise subtraction of the two values.
// Standard broadcasting rules apply (see documentation).
Sub:two
// Div returns the element-wise division of the two values.
// Standard broadcasting rules apply (see documentation).
Div:two
// Rem returns the remainder operation, also known as modulo (or Mod for short).
// Notice despite the name XLA implements Mod not IEEE754 Remainder operation.
Rem:two
// LogicalAnd returns the element-wise logical AND operation.
LogicalAnd:two
// LogicalOr returns the element-wise logical OR operation.
LogicalOr:two
// LogicalXor returns the element-wise logical XOR operator.
LogicalXor:two
// Dot returns the "dot product" operation.
// The exact semantics of this operation depend on the ranks of the operands:
//
// | Input | Output | Semantics |
// | vector [n] dot vector [n] | scalar | vector dot product |
// | matrix [m x k] dot vector [k] | vector [m]	matrix-vector multiplication |
// | matrix [m x k] dot matrix [k x n] | matrix [m x n] | matrix-matrix multiplication |
//
// The operation performs sum of products over the second dimension of x0 (or the first if it has rank 1) and
// the first dimension of x1.
// These are the "contracted" dimensions.
// The contracted dimensions of x0 and x1 must be of the same size.
// In practice, it can be used to perform dot products between vectors, vector/matrix multiplications or
// matrix/matrix multiplications.
Dot:two
// Min returns the element-wise smallest value among the two.
Min:two
// Max returns the element-wise highest value among the two.
Max:two
Pow:two
// Complex returns the complex number taking x0 as the real part and x1 as the imaginary part.
// The real (x0) and imaginary (x1) must have the same dtype, and they must be either `dtypes.Float32` or
// `dtypes.Float64`.
// The output will be either `dtypes.Complex64` or `dtypes.Complex128`, depending on x0 and x1 dtypes.
// The shapes of `real` or `imaginary` must be the same, or one must be a scalar, in which case
// the value is broadcast to every other value.
Complex:two

# Two-arguments comparison ops:

// Equal performs element-wise equality check, returns boolean results with the same dimensions as input.
Equal:two_cmp
// NotEqual performs element-wise inequality check, returns boolean results with the same dimensions as input.
NotEqual:two_cmp
// GreaterOrEqual performs element-wise comparison, returns boolean results with the same dimensions as input.
GreaterOrEqual:two_cmp
// GreaterThan performs element-wise comparison, returns boolean results with the same dimensions as input.
GreaterThan:two_cmp
// LessOrEqual performs element-wise comparison, returns boolean results with the same dimensions as input.
LessOrEqual:two_cmp
// LessThan performs element-wise comparison, returns boolean results with the same dimensions as input.
LessThan:two_cmp

// EqualTotalOrder returns the element-wise operation.
//
// Standard broadcasting rules apply (see documentation).
//
// The "TotalOrder" version of the operation enforces `-NaN < -Inf < -Finite < -0 < +0 < +Finite < +Inf < +NaN`.
EqualTotalOrder:two_cmp

// NotEqualTotalOrder returns the element-wise operation.
//
// Standard broadcasting rules apply (see documentation).
//
// The "TotalOrder" version of the operation enforces `-NaN < -Inf < -Finite < -0 < +0 < +Finite < +Inf < +NaN`.
NotEqualTotalOrder:two_cmp

// GreaterOrEqualTotalOrder returns the element-wise operation.
//
// Standard broadcasting rules apply (see documentation).
//
// The "TotalOrder" version of the operation enforces `-NaN < -Inf < -Finite < -0 < +0 < +Finite < +Inf < +NaN`.
GreaterOrEqualTotalOrder:two_cmp

// GreaterThanTotalOrder returns the element-wise operation.
//
// Standard broadcasting rules apply (see documentation).
//
// The "TotalOrder" version of the operation enforces `-NaN < -Inf < -Finite < -0 < +0 < +Finite < +Inf < +NaN`.
GreaterThanTotalOrder:two_cmp

// LessOrEqualTotalOrder returns the element-wise operation.
//
// Standard broadcasting rules apply (see documentation).
//
// The "TotalOrder" version of the operation enforces `-NaN < -Inf < -Finite < -0 < +0 < +Finite < +Inf < +NaN`.
LessOrEqualTotalOrder:two_cmp

// LessThanTotalOrder returns the element-wise operation.
//
// Standard broadcasting rules apply (see documentation).
//
// The "TotalOrder" version of the operation enforces `-NaN < -Inf < -Finite < -0 < +0 < +Finite < +Inf < +NaN`.
LessThanTotalOrder:two_cmp


DynamicSlice:special
DynamicUpdateSlice:special


// Erf returns the "error function", defined as erf(x) = 2/Pi * \int_{0}^{x}{e^{-t^2}dt}.
Erf:one

// IsFinite tests whether each element of operand is finite, i.e., is not positive or negative infinity, and is not NaN.
// It returns an array of boolean values with the same shape as the input, where each element is true if and only if
// the corresponding input element is finite.
IsFinite:one

// PopulationCount computes the number of bits set in each element of operand.
PopulationCount:one

// ShiftLeft n bits. It implicitly preserves the sign bit, if there is no overflow. So ShiftLeft(-1, 1) = -2.
ShiftLeft:two

// ShiftRightArithmetic shifts right by n bits, preserving the sign bit. So ShiftRight(-2, 1) = -1.
ShiftRightArithmetic:two

// ShiftRightLogical shifts right by n bits, destroying the sign bit.
ShiftRightLogical:two

// BitwiseAnd returns the element-wise bitwise AND operation.
BitwiseAnd:two
// BitwiseOr returns the element-wise bitwise OR operation.
BitwiseOr:two
// BitwiseXor returns the element-wise bitwise XOR operator.
BitwiseXor:two
// BitwiseNot returns the element-wise bitwise AND operation.
BitwiseNot:one

Bitcast:special

#################################### IMPORTANT ####################################
# - New ops must be appended to the bottom -- changing the order would break
#   all types of compatibility.
# - Any changes require a bump in xlabuilder.cpp GopjrtXlaBuilderVersion.
#################################### IMPORTANT ####################################

