add statistical functions

This commit is contained in:
mcDandy
2026-01-10 14:13:44 +01:00
parent 2db7fcc004
commit 43c3d060b0
11 changed files with 3061 additions and 1439 deletions
+5
View File
@@ -82,6 +82,11 @@ You can also get the node from comfy manager under the name of More math.
- `tmax(x, y)`: Element-wise maximum of x and y.
- `smin(x, ...)`: Scalar minimum. Returns the single smallest value across all input tensors/values.
- `smax(x, ...)`: Scalar maximum. Returns the single largest value across all input tensors/values.
- `sum(x)`: Sum of all elements.
- `mean(x)`: Mean value of all elements.
- `std(x)`: Standard deviation of all elements.
- `var(x)`: Variance of all elements.
- `dot(a, b)`: Dot product of two tensors (flattens inputs to 1D) or lists.
- `topk(x, k)`: Returns a tensor with the **top K largest** values preserved at their original positions (others zeroed). For lists, returns the top K largest items sorted descending. (uses magnitude for for complex numbers).
- `botk(x, k)`: Returns a tensor with the **bottom K smallest** values preserved at their original positions (others zeroed). For lists, returns the bottom K smallest items sorted ascending. (uses magnitude for for complex numbers)
- `tnorm(x)`: Tensor normalisation. Normalises x (L2 norm along last dimension).
+185 -192
View File
@@ -1,215 +1,208 @@
grammar MathExpr;
// Top-level expression, with operator precedence (lowest to highest)
expr
: atom | compExpr
;
expr: atom | compExpr;
compExpr
: compExpr GT addExpr # GtExp
| compExpr GE addExpr # GeExp
| compExpr LT addExpr # LtExp
| compExpr LE addExpr # LeExp
| compExpr EQ addExpr # EqExp
| compExpr NE addExpr # NeExp
| addExpr # ToAdd
;
compExpr:
compExpr GT addExpr # GtExp
| compExpr GE addExpr # GeExp
| compExpr LT addExpr # LtExp
| compExpr LE addExpr # LeExp
| compExpr EQ addExpr # EqExp
| compExpr NE addExpr # NeExp
| addExpr # ToAdd;
addExpr
: addExpr PLUS mulExpr # AddExp
| addExpr MINUS mulExpr # SubExp
| mulExpr # ToMul
;
addExpr:
addExpr PLUS mulExpr # AddExp
| addExpr MINUS mulExpr # SubExp
| mulExpr # ToMul;
mulExpr
: mulExpr MULT powExpr # MulExp
| mulExpr DIV powExpr # DivExp
| mulExpr MOD powExpr # ModExp
| powExpr # ToPow
;
mulExpr:
mulExpr MULT powExpr # MulExp
| mulExpr DIV powExpr # DivExp
| mulExpr MOD powExpr # ModExp
| powExpr # ToPow;
powExpr
: unaryExpr POW powExpr # PowExp
| unaryExpr # ToUnary
;
powExpr: unaryExpr POW powExpr # PowExp | unaryExpr # ToUnary;
unaryExpr
: PLUS unaryExpr # UnaryPlus
| MINUS unaryExpr # UnaryMinus
| atom # ToAtom
;
unaryExpr:
PLUS unaryExpr # UnaryPlus
| MINUS unaryExpr # UnaryMinus
| atom # ToAtom;
// Atoms: function calls, variable, number, constant, or parenthesized expression
atom
: func1 # Func1Exp
| func2 # Func2Exp
| func3 # Func3Exp
| func4 # Func4Exp
| funcN # FuncNExp
| VARIABLE # VariableExp
| NUMBER # NumberExp
| CONSTANT # ConstantExp
| LPAREN expr RPAREN # ParenExp
| PIPE expr PIPE # AbsExp
| LBRACKET expr (COMMA expr)* RBRACKET # ListExp
;
atom:
func1 # Func1Exp
| func2 # Func2Exp
| func3 # Func3Exp
| func4 # Func4Exp
| funcN # FuncNExp
| VARIABLE # VariableExp
| NUMBER # NumberExp
| CONSTANT # ConstantExp
| LPAREN expr RPAREN # ParenExp
| PIPE expr PIPE # AbsExp
| LBRACKET expr (COMMA expr)* RBRACKET # ListExp;
// Single-argument functions
func1
: SIN LPAREN expr RPAREN # SinFunc
| COS LPAREN expr RPAREN # CosFunc
| TAN LPAREN expr RPAREN # TanFunc
| ASIN LPAREN expr RPAREN # AsinFunc
| ACOS LPAREN expr RPAREN # AcosFunc
| ATAN LPAREN expr RPAREN # AtanFunc
| SINH LPAREN expr RPAREN # SinhFunc
| COSH LPAREN expr RPAREN # CoshFunc
| TANH LPAREN expr RPAREN # TanhFunc
| ASINH LPAREN expr RPAREN # AsinhFunc
| ACOSH LPAREN expr RPAREN # AcoshFunc
| ATANH LPAREN expr RPAREN # AtanhFunc
| ABS LPAREN expr RPAREN # AbsFunc
| SQRT LPAREN expr RPAREN # SqrtFunc
| LN LPAREN expr RPAREN # LnFunc
| LOG LPAREN expr RPAREN # LogFunc
| EXP LPAREN expr RPAREN # ExpFunc
| TNORM LPAREN expr RPAREN # TNormFunc
| SNORM LPAREN expr RPAREN # SNormFunc
| FLOOR LPAREN expr RPAREN # FloorFunc
| CEIL LPAREN expr RPAREN # CeilFunc
| ROUND LPAREN expr RPAREN # RoundFunc
| GAMMA LPAREN expr RPAREN # GammaFunc
| SIGM LPAREN expr RPAREN # sigmoidFunc
| SFFT LPAREN expr RPAREN # sfftFunc
| SIFFT LPAREN expr RPAREN # sifftFunc
| ANGL LPAREN expr RPAREN # anglFunc
| PRNT LPAREN expr RPAREN # printFunc
| FRACT LPAREN expr RPAREN # FractFunc
| RELU LPAREN expr RPAREN # ReluFunc
| SOFTPLUS LPAREN expr RPAREN # SoftplusFunc
| GELU LPAREN expr RPAREN # GeluFunc
| SIGN LPAREN expr RPAREN # SignFunc
| PRINT_SHAPE LPAREN expr RPAREN # PrintShapeFunc
| PINV LPAREN expr RPAREN # PinvFunc
| SUM LPAREN expr RPAREN # SumFunc
| MEAN LPAREN expr RPAREN # MeanFunc
| STD LPAREN expr RPAREN # StdFunc
| VAR LPAREN expr RPAREN # VarFunc
| MEDIAN LPAREN expr RPAREN # MedianFunc
;
func1:
SIN LPAREN expr RPAREN # SinFunc
| COS LPAREN expr RPAREN # CosFunc
| TAN LPAREN expr RPAREN # TanFunc
| ASIN LPAREN expr RPAREN # AsinFunc
| ACOS LPAREN expr RPAREN # AcosFunc
| ATAN LPAREN expr RPAREN # AtanFunc
| SINH LPAREN expr RPAREN # SinhFunc
| COSH LPAREN expr RPAREN # CoshFunc
| TANH LPAREN expr RPAREN # TanhFunc
| ASINH LPAREN expr RPAREN # AsinhFunc
| ACOSH LPAREN expr RPAREN # AcoshFunc
| ATANH LPAREN expr RPAREN # AtanhFunc
| ABS LPAREN expr RPAREN # AbsFunc
| SQRT LPAREN expr RPAREN # SqrtFunc
| LN LPAREN expr RPAREN # LnFunc
| LOG LPAREN expr RPAREN # LogFunc
| EXP LPAREN expr RPAREN # ExpFunc
| TNORM LPAREN expr RPAREN # TNormFunc
| SNORM LPAREN expr RPAREN # SNormFunc
| FLOOR LPAREN expr RPAREN # FloorFunc
| CEIL LPAREN expr RPAREN # CeilFunc
| ROUND LPAREN expr RPAREN # RoundFunc
| GAMMA LPAREN expr RPAREN # GammaFunc
| SIGM LPAREN expr RPAREN # sigmoidFunc
| SFFT LPAREN expr RPAREN # sfftFunc
| SIFFT LPAREN expr RPAREN # sifftFunc
| ANGL LPAREN expr RPAREN # anglFunc
| PRNT LPAREN expr RPAREN # printFunc
| FRACT LPAREN expr RPAREN # FractFunc
| RELU LPAREN expr RPAREN # ReluFunc
| SOFTPLUS LPAREN expr RPAREN # SoftplusFunc
| GELU LPAREN expr RPAREN # GeluFunc
| SIGN LPAREN expr RPAREN # SignFunc
| PRINT_SHAPE LPAREN expr RPAREN # PrintShapeFunc
| PINV LPAREN expr RPAREN # PinvFunc
| SUM LPAREN expr RPAREN # SumFunc
| MEAN LPAREN expr RPAREN # MeanFunc
| STD LPAREN expr RPAREN # StdFunc
| VAR LPAREN expr RPAREN # VarFunc;
// Two-argument functions
func2
: POWE LPAREN expr COMMA expr RPAREN # PowFunc
| ATAN2 LPAREN expr COMMA expr RPAREN # Atan2Func
| TMIN LPAREN expr COMMA expr RPAREN # TMinFunc
| TMAX LPAREN expr COMMA expr RPAREN # TMaxFunc
| STEP LPAREN expr COMMA expr RPAREN # StepFunc
| TOPK LPAREN expr COMMA expr RPAREN # TopkFunc
| BOTK LPAREN expr COMMA expr RPAREN # BotkFunc
| DOT LPAREN expr COMMA expr RPAREN # DotFunc
;
// Two-argument functions Two-argument functions
func2:
POWE LPAREN expr COMMA expr RPAREN # PowFunc
| ATAN2 LPAREN expr COMMA expr RPAREN # Atan2Func
| TMIN LPAREN expr COMMA expr RPAREN # TMinFunc
| TMAX LPAREN expr COMMA expr RPAREN # TMaxFunc
| STEP LPAREN expr COMMA expr RPAREN # StepFunc
| TOPK LPAREN expr COMMA expr RPAREN # TopkFunc
| BOTK LPAREN expr COMMA expr RPAREN # BotkFunc
| QUARTILE LPAREN expr COMMA expr RPAREN # QuartileFunc
| PERCENTILE LPAREN expr COMMA expr RPAREN # PercentileFunc
| DOT LPAREN expr COMMA expr RPAREN # DotFunc;
func3
: CLAMP LPAREN expr COMMA expr COMMA expr RPAREN # ClampFunc
| LERP LPAREN expr COMMA expr COMMA expr RPAREN # LerpFunc
| SMOOTHSTEP LPAREN expr COMMA expr COMMA expr RPAREN # SmoothstepFunc
| RANGE LPAREN expr COMMA expr COMMA expr RPAREN # RangeFunc
;
func3:
CLAMP LPAREN expr COMMA expr COMMA expr RPAREN # ClampFunc
| LERP LPAREN expr COMMA expr COMMA expr RPAREN # LerpFunc
| SMOOTHSTEP LPAREN expr COMMA expr COMMA expr RPAREN # SmoothstepFunc
| RANGE LPAREN expr COMMA expr COMMA expr RPAREN # RangeFunc;
func4
: SWAP LPAREN expr COMMA expr COMMA expr COMMA expr RPAREN # SwapFunc
;
func4:
SWAP LPAREN expr COMMA expr COMMA expr COMMA expr RPAREN # SwapFunc;
// N-argument functions
funcN
: SMIN LPAREN expr (COMMA expr)* RPAREN # SMinFunc
| SMAX LPAREN expr (COMMA expr)* RPAREN # SMaxFunc
| MAP LPAREN expr (COMMA expr)+ RPAREN # MapFunc
| EZCONV LPAREN expr (COMMA expr)+ RPAREN # EzConvFunc
| CONV LPAREN expr (COMMA expr)+ RPAREN # ConvFunc
| PERM LPAREN expr COMMA expr RPAREN # PermuteFunc
| RESHAPE LPAREN expr COMMA expr RPAREN # ReshapeFunc
;
funcN:
SMIN LPAREN expr (COMMA expr)* RPAREN # SMinFunc
| SMAX LPAREN expr (COMMA expr)* RPAREN # SMaxFunc
| MAP LPAREN expr (COMMA expr)+ RPAREN # MapFunc
| EZCONV LPAREN expr (COMMA expr)+ RPAREN # EzConvFunc
| CONV LPAREN expr (COMMA expr)+ RPAREN # ConvFunc
| PERM LPAREN expr COMMA expr RPAREN # PermuteFunc
| RESHAPE LPAREN expr COMMA expr RPAREN # ReshapeFunc;
// LEXER RULES
SIN : 'sin';
COS : 'cos';
TAN : 'tan';
ASIN : 'asin';
ACOS : 'acos';
ATAN : 'atan';
ATAN2 : 'atan2';
SINH : 'sinh';
COSH : 'cosh';
TANH : 'tanh';
ASINH : 'asinh';
ACOSH : 'acosh';
ATANH : 'atanh';
ABS : 'abs';
SQRT : 'sqrt';
LN : 'ln';
LOG : 'log';
EXP : 'exp';
SMIN : 'smin';
SMAX : 'smax';
TMIN : 'tmin';
TMAX : 'tmax';
TNORM : 'tnorm';
SNORM : 'snorm';
FLOOR : 'floor';
CEIL : 'ceil';
ROUND : 'round';
GAMMA : 'gamma';
POWE : 'pow';
SIGM : 'sigm';
CLAMP : 'clamp';
SFFT : 'fft';
SIFFT : 'ifft';
ANGL : 'angle';
PRNT : 'print';
PRINT_SHAPE : 'print_shape' | 'pshp';
LERP : 'lerp';
STEP : 'step';
SMOOTHSTEP : 'smoothstep';
FRACT : 'fract';
RELU : 'relu';
SOFTPLUS : 'softplus';
GELU : 'gelu';
SIGN : 'sign';
MAP : 'map';
EZCONV : 'ezconvolution' | 'ezconv';
CONV : 'convolution' | 'conv';
SWAP : 'swap';
PERM : 'permute' | 'perm';
RESHAPE : 'reshape' | 'rshp';
RANGE : 'range';
TOPK : 'topk';
BOTK : 'botk';
PINV : 'pinv';
SIN: 'sin';
COS: 'cos';
TAN: 'tan';
ASIN: 'asin';
ACOS: 'acos';
ATAN: 'atan';
ATAN2: 'atan2';
SINH: 'sinh';
COSH: 'cosh';
TANH: 'tanh';
ASINH: 'asinh';
ACOSH: 'acosh';
ATANH: 'atanh';
ABS: 'abs';
SQRT: 'sqrt';
LN: 'ln';
LOG: 'log';
EXP: 'exp';
SMIN: 'smin';
SMAX: 'smax';
TMIN: 'tmin';
TMAX: 'tmax';
TNORM: 'tnorm';
SNORM: 'snorm';
FLOOR: 'floor';
CEIL: 'ceil';
ROUND: 'round';
GAMMA: 'gamma';
POWE: 'pow';
SIGM: 'sigm';
CLAMP: 'clamp';
SFFT: 'fft';
SIFFT: 'ifft';
ANGL: 'angle';
PRNT: 'print';
PRINT_SHAPE: 'print_shape' | 'pshp';
LERP: 'lerp';
STEP: 'step';
SMOOTHSTEP: 'smoothstep';
FRACT: 'fract';
RELU: 'relu';
SOFTPLUS: 'softplus';
GELU: 'gelu';
SIGN: 'sign';
MAP: 'map';
EZCONV: 'ezconvolution' | 'ezconv';
CONV: 'convolution' | 'conv';
SWAP: 'swap';
PERM: 'permute' | 'perm';
RESHAPE: 'reshape' | 'rshp';
RANGE: 'range';
TOPK: 'topk';
BOTK: 'botk';
PINV: 'pinv';
SUM: 'sum';
MEAN: 'mean';
STD: 'std';
VAR: 'var';
QUARTILE: 'quartile';
PERCENTILE: 'percentile' | 'prcnt';
DOT: 'dot';
PLUS : '+';
MINUS : '-';
MULT : '*';
DIV : '/';
MOD : '%';
POW : '^';
PLUS: '+';
MINUS: '-';
MULT: '*';
DIV: '/';
MOD: '%';
POW: '^';
GE : '>=';
GT : '>';
LE : '<=';
LT : '<';
EQ : '==';
NE : '!=';
PIPE : '|';
LPAREN : '(';
RPAREN : ')';
COMMA : ',';
LBRACKET : '[';
RBRACKET : ']';
GE: '>=';
GT: '>';
LE: '<=';
LT: '<';
EQ: '==';
NE: '!=';
PIPE: '|';
LPAREN: '(';
RPAREN: ')';
COMMA: ',';
LBRACKET: '[';
RBRACKET: ']';
CONSTANT : ('pi'|'PI'|'e'|'E');
NUMBER : [0-9]+ ('.' [0-9]+)?;
VARIABLE : [a-zA-Z_] [a-zA-Z_0-9]*;
WS : [ \t\r\n]+ -> skip;
CONSTANT: ('pi' | 'PI' | 'e' | 'E');
NUMBER: [0-9]+ ('.' [0-9]+)?;
VARIABLE: [a-zA-Z_] [a-zA-Z_0-9]*;
WS: [ \t\r\n]+ -> skip;
File diff suppressed because one or more lines are too long
+156 -143
View File
@@ -1,143 +1,156 @@
T__0=1
T__1=2
T__2=3
T__3=4
T__4=5
SIN=6
COS=7
TAN=8
ASIN=9
ACOS=10
ATAN=11
ATAN2=12
SINH=13
COSH=14
TANH=15
ASINH=16
ACOSH=17
ATANH=18
ABS=19
SQRT=20
LN=21
LOG=22
EXP=23
SMIN=24
SMAX=25
TMIN=26
TMAX=27
TNORM=28
SNORM=29
FLOOR=30
CEIL=31
ROUND=32
GAMMA=33
POWE=34
SIGM=35
CLAMP=36
SFFT=37
SIFFT=38
ANGL=39
PRNT=40
PRINT_SHAPE=41
LERP=42
STEP=43
SMOOTHSTEP=44
FRACT=45
RELU=46
SOFTPLUS=47
GELU=48
SIGN=49
MAP=50
EZCONV=51
CONV=52
SWAP=53
PERM=54
RESHAPE=55
RANGE=56
TOPK=57
BOTK=58
PINV=59
PLUS=60
MINUS=61
MULT=62
DIV=63
MOD=64
POW=65
GE=66
GT=67
LE=68
LT=69
EQ=70
NE=71
PIPE=72
CONSTANT=73
NUMBER=74
VARIABLE=75
WS=76
'('=1
')'=2
'['=3
','=4
']'=5
'sin'=6
'cos'=7
'tan'=8
'asin'=9
'acos'=10
'atan'=11
'atan2'=12
'sinh'=13
'cosh'=14
'tanh'=15
'asinh'=16
'acosh'=17
'atanh'=18
'abs'=19
'sqrt'=20
'ln'=21
'log'=22
'exp'=23
'smin'=24
'smax'=25
'tmin'=26
'tmax'=27
'tnorm'=28
'snorm'=29
'floor'=30
'ceil'=31
'round'=32
'gamma'=33
'pow'=34
'sigm'=35
'clamp'=36
'fft'=37
'ifft'=38
'angle'=39
'print'=40
'lerp'=42
'step'=43
'smoothstep'=44
'fract'=45
'relu'=46
'softplus'=47
'gelu'=48
'sign'=49
'map'=50
'swap'=53
'range'=56
'topk'=57
'botk'=58
'pinv'=59
'+'=60
'-'=61
'*'=62
'/'=63
'%'=64
'^'=65
'>='=66
'>'=67
'<='=68
'<'=69
'=='=70
'!='=71
'|'=72
SIN=1
COS=2
TAN=3
ASIN=4
ACOS=5
ATAN=6
ATAN2=7
SINH=8
COSH=9
TANH=10
ASINH=11
ACOSH=12
ATANH=13
ABS=14
SQRT=15
LN=16
LOG=17
EXP=18
SMIN=19
SMAX=20
TMIN=21
TMAX=22
TNORM=23
SNORM=24
FLOOR=25
CEIL=26
ROUND=27
GAMMA=28
POWE=29
SIGM=30
CLAMP=31
SFFT=32
SIFFT=33
ANGL=34
PRNT=35
PRINT_SHAPE=36
LERP=37
STEP=38
SMOOTHSTEP=39
FRACT=40
RELU=41
SOFTPLUS=42
GELU=43
SIGN=44
MAP=45
EZCONV=46
CONV=47
SWAP=48
PERM=49
RESHAPE=50
RANGE=51
TOPK=52
BOTK=53
PINV=54
SUM=55
MEAN=56
STD=57
VAR=58
QUARTILE=59
PERCENTILE=60
DOT=61
PLUS=62
MINUS=63
MULT=64
DIV=65
MOD=66
POW=67
GE=68
GT=69
LE=70
LT=71
EQ=72
NE=73
PIPE=74
LPAREN=75
RPAREN=76
COMMA=77
LBRACKET=78
RBRACKET=79
CONSTANT=80
NUMBER=81
VARIABLE=82
WS=83
'sin'=1
'cos'=2
'tan'=3
'asin'=4
'acos'=5
'atan'=6
'atan2'=7
'sinh'=8
'cosh'=9
'tanh'=10
'asinh'=11
'acosh'=12
'atanh'=13
'abs'=14
'sqrt'=15
'ln'=16
'log'=17
'exp'=18
'smin'=19
'smax'=20
'tmin'=21
'tmax'=22
'tnorm'=23
'snorm'=24
'floor'=25
'ceil'=26
'round'=27
'gamma'=28
'pow'=29
'sigm'=30
'clamp'=31
'fft'=32
'ifft'=33
'angle'=34
'print'=35
'lerp'=37
'step'=38
'smoothstep'=39
'fract'=40
'relu'=41
'softplus'=42
'gelu'=43
'sign'=44
'map'=45
'swap'=48
'range'=51
'topk'=52
'botk'=53
'pinv'=54
'sum'=55
'mean'=56
'std'=57
'var'=58
'quartile'=59
'dot'=61
'+'=62
'-'=63
'*'=64
'/'=65
'%'=66
'^'=67
'>='=68
'>'=69
'<='=70
'<'=71
'=='=72
'!='=73
'|'=74
'('=75
')'=76
','=77
'['=78
']'=79
File diff suppressed because one or more lines are too long
+322 -289
View File
@@ -1,4 +1,4 @@
# Generated from MathExpr.g4 by ANTLR 4.13.2
# Generated from ./MathExpr.g4 by ANTLR 4.13.2
from antlr4 import *
from io import StringIO
import sys
@@ -10,7 +10,7 @@ else:
def serializedATN():
return [
4,0,76,566,6,-1,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,
4,0,83,627,6,-1,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,
2,6,7,6,2,7,7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11,7,11,2,12,7,12,2,
13,7,13,2,14,7,14,2,15,7,15,2,16,7,16,2,17,7,17,2,18,7,18,2,19,7,
19,2,20,7,20,2,21,7,21,2,22,7,22,2,23,7,23,2,24,7,24,2,25,7,25,2,
@@ -21,195 +21,217 @@ def serializedATN():
52,7,52,2,53,7,53,2,54,7,54,2,55,7,55,2,56,7,56,2,57,7,57,2,58,7,
58,2,59,7,59,2,60,7,60,2,61,7,61,2,62,7,62,2,63,7,63,2,64,7,64,2,
65,7,65,2,66,7,66,2,67,7,67,2,68,7,68,2,69,7,69,2,70,7,70,2,71,7,
71,2,72,7,72,2,73,7,73,2,74,7,74,2,75,7,75,1,0,1,0,1,1,1,1,1,2,1,
2,1,3,1,3,1,4,1,4,1,5,1,5,1,5,1,5,1,6,1,6,1,6,1,6,1,7,1,7,1,7,1,
7,1,8,1,8,1,8,1,8,1,8,1,9,1,9,1,9,1,9,1,9,1,10,1,10,1,10,1,10,1,
10,1,11,1,11,1,11,1,11,1,11,1,11,1,12,1,12,1,12,1,12,1,12,1,13,1,
13,1,13,1,13,1,13,1,14,1,14,1,14,1,14,1,14,1,15,1,15,1,15,1,15,1,
15,1,15,1,16,1,16,1,16,1,16,1,16,1,16,1,17,1,17,1,17,1,17,1,17,1,
17,1,18,1,18,1,18,1,18,1,19,1,19,1,19,1,19,1,19,1,20,1,20,1,20,1,
21,1,21,1,21,1,21,1,22,1,22,1,22,1,22,1,23,1,23,1,23,1,23,1,23,1,
24,1,24,1,24,1,24,1,24,1,25,1,25,1,25,1,25,1,25,1,26,1,26,1,26,1,
26,1,26,1,27,1,27,1,27,1,27,1,27,1,27,1,28,1,28,1,28,1,28,1,28,1,
28,1,29,1,29,1,29,1,29,1,29,1,29,1,30,1,30,1,30,1,30,1,30,1,31,1,
31,1,31,1,31,1,31,1,31,1,32,1,32,1,32,1,32,1,32,1,32,1,33,1,33,1,
33,1,33,1,34,1,34,1,34,1,34,1,34,1,35,1,35,1,35,1,35,1,35,1,35,1,
36,1,36,1,36,1,36,1,37,1,37,1,37,1,37,1,37,1,38,1,38,1,38,1,38,1,
38,1,38,1,39,1,39,1,39,1,39,1,39,1,39,1,40,1,40,1,40,1,40,1,40,1,
40,1,40,1,40,1,40,1,40,1,40,1,40,1,40,1,40,1,40,3,40,356,8,40,1,
41,1,41,1,41,1,41,1,41,1,42,1,42,1,42,1,42,1,42,1,43,1,43,1,43,1,
43,1,43,1,43,1,43,1,43,1,43,1,43,1,43,1,44,1,44,1,44,1,44,1,44,1,
44,1,45,1,45,1,45,1,45,1,45,1,46,1,46,1,46,1,46,1,46,1,46,1,46,1,
46,1,46,1,47,1,47,1,47,1,47,1,47,1,48,1,48,1,48,1,48,1,48,1,49,1,
49,1,49,1,49,1,50,1,50,1,50,1,50,1,50,1,50,1,50,1,50,1,50,1,50,1,
50,1,50,1,50,1,50,1,50,1,50,1,50,1,50,1,50,3,50,432,8,50,1,51,1,
51,1,51,1,51,1,51,1,51,1,51,1,51,1,51,1,51,1,51,1,51,1,51,1,51,1,
51,3,51,449,8,51,1,52,1,52,1,52,1,52,1,52,1,53,1,53,1,53,1,53,1,
53,1,53,1,53,1,53,1,53,1,53,1,53,3,53,467,8,53,1,54,1,54,1,54,1,
54,1,54,1,54,1,54,1,54,1,54,1,54,1,54,3,54,480,8,54,1,55,1,55,1,
55,1,55,1,55,1,55,1,56,1,56,1,56,1,56,1,56,1,57,1,57,1,57,1,57,1,
57,1,58,1,58,1,58,1,58,1,58,1,59,1,59,1,60,1,60,1,61,1,61,1,62,1,
62,1,63,1,63,1,64,1,64,1,65,1,65,1,65,1,66,1,66,1,67,1,67,1,67,1,
68,1,68,1,69,1,69,1,69,1,70,1,70,1,70,1,71,1,71,1,72,1,72,1,72,1,
72,1,72,3,72,538,8,72,1,73,4,73,541,8,73,11,73,12,73,542,1,73,1,
73,4,73,547,8,73,11,73,12,73,548,3,73,551,8,73,1,74,1,74,5,74,555,
8,74,10,74,12,74,558,9,74,1,75,4,75,561,8,75,11,75,12,75,562,1,75,
1,75,0,0,76,1,1,3,2,5,3,7,4,9,5,11,6,13,7,15,8,17,9,19,10,21,11,
23,12,25,13,27,14,29,15,31,16,33,17,35,18,37,19,39,20,41,21,43,22,
45,23,47,24,49,25,51,26,53,27,55,28,57,29,59,30,61,31,63,32,65,33,
67,34,69,35,71,36,73,37,75,38,77,39,79,40,81,41,83,42,85,43,87,44,
89,45,91,46,93,47,95,48,97,49,99,50,101,51,103,52,105,53,107,54,
109,55,111,56,113,57,115,58,117,59,119,60,121,61,123,62,125,63,127,
64,129,65,131,66,133,67,135,68,137,69,139,70,141,71,143,72,145,73,
147,74,149,75,151,76,1,0,5,2,0,69,69,101,101,1,0,48,57,3,0,65,90,
95,95,97,122,4,0,48,57,65,90,95,95,97,122,3,0,9,10,13,13,32,32,577,
0,1,1,0,0,0,0,3,1,0,0,0,0,5,1,0,0,0,0,7,1,0,0,0,0,9,1,0,0,0,0,11,
1,0,0,0,0,13,1,0,0,0,0,15,1,0,0,0,0,17,1,0,0,0,0,19,1,0,0,0,0,21,
1,0,0,0,0,23,1,0,0,0,0,25,1,0,0,0,0,27,1,0,0,0,0,29,1,0,0,0,0,31,
1,0,0,0,0,33,1,0,0,0,0,35,1,0,0,0,0,37,1,0,0,0,0,39,1,0,0,0,0,41,
1,0,0,0,0,43,1,0,0,0,0,45,1,0,0,0,0,47,1,0,0,0,0,49,1,0,0,0,0,51,
1,0,0,0,0,53,1,0,0,0,0,55,1,0,0,0,0,57,1,0,0,0,0,59,1,0,0,0,0,61,
1,0,0,0,0,63,1,0,0,0,0,65,1,0,0,0,0,67,1,0,0,0,0,69,1,0,0,0,0,71,
1,0,0,0,0,73,1,0,0,0,0,75,1,0,0,0,0,77,1,0,0,0,0,79,1,0,0,0,0,81,
1,0,0,0,0,83,1,0,0,0,0,85,1,0,0,0,0,87,1,0,0,0,0,89,1,0,0,0,0,91,
1,0,0,0,0,93,1,0,0,0,0,95,1,0,0,0,0,97,1,0,0,0,0,99,1,0,0,0,0,101,
1,0,0,0,0,103,1,0,0,0,0,105,1,0,0,0,0,107,1,0,0,0,0,109,1,0,0,0,
0,111,1,0,0,0,0,113,1,0,0,0,0,115,1,0,0,0,0,117,1,0,0,0,0,119,1,
0,0,0,0,121,1,0,0,0,0,123,1,0,0,0,0,125,1,0,0,0,0,127,1,0,0,0,0,
129,1,0,0,0,0,131,1,0,0,0,0,133,1,0,0,0,0,135,1,0,0,0,0,137,1,0,
0,0,0,139,1,0,0,0,0,141,1,0,0,0,0,143,1,0,0,0,0,145,1,0,0,0,0,147,
1,0,0,0,0,149,1,0,0,0,0,151,1,0,0,0,1,153,1,0,0,0,3,155,1,0,0,0,
5,157,1,0,0,0,7,159,1,0,0,0,9,161,1,0,0,0,11,163,1,0,0,0,13,167,
1,0,0,0,15,171,1,0,0,0,17,175,1,0,0,0,19,180,1,0,0,0,21,185,1,0,
0,0,23,190,1,0,0,0,25,196,1,0,0,0,27,201,1,0,0,0,29,206,1,0,0,0,
31,211,1,0,0,0,33,217,1,0,0,0,35,223,1,0,0,0,37,229,1,0,0,0,39,233,
1,0,0,0,41,238,1,0,0,0,43,241,1,0,0,0,45,245,1,0,0,0,47,249,1,0,
0,0,49,254,1,0,0,0,51,259,1,0,0,0,53,264,1,0,0,0,55,269,1,0,0,0,
57,275,1,0,0,0,59,281,1,0,0,0,61,287,1,0,0,0,63,292,1,0,0,0,65,298,
1,0,0,0,67,304,1,0,0,0,69,308,1,0,0,0,71,313,1,0,0,0,73,319,1,0,
0,0,75,323,1,0,0,0,77,328,1,0,0,0,79,334,1,0,0,0,81,355,1,0,0,0,
83,357,1,0,0,0,85,362,1,0,0,0,87,367,1,0,0,0,89,378,1,0,0,0,91,384,
1,0,0,0,93,389,1,0,0,0,95,398,1,0,0,0,97,403,1,0,0,0,99,408,1,0,
0,0,101,431,1,0,0,0,103,448,1,0,0,0,105,450,1,0,0,0,107,466,1,0,
0,0,109,479,1,0,0,0,111,481,1,0,0,0,113,487,1,0,0,0,115,492,1,0,
0,0,117,497,1,0,0,0,119,502,1,0,0,0,121,504,1,0,0,0,123,506,1,0,
0,0,125,508,1,0,0,0,127,510,1,0,0,0,129,512,1,0,0,0,131,514,1,0,
0,0,133,517,1,0,0,0,135,519,1,0,0,0,137,522,1,0,0,0,139,524,1,0,
0,0,141,527,1,0,0,0,143,530,1,0,0,0,145,537,1,0,0,0,147,540,1,0,
0,0,149,552,1,0,0,0,151,560,1,0,0,0,153,154,5,40,0,0,154,2,1,0,0,
0,155,156,5,41,0,0,156,4,1,0,0,0,157,158,5,91,0,0,158,6,1,0,0,0,
159,160,5,44,0,0,160,8,1,0,0,0,161,162,5,93,0,0,162,10,1,0,0,0,163,
164,5,115,0,0,164,165,5,105,0,0,165,166,5,110,0,0,166,12,1,0,0,0,
167,168,5,99,0,0,168,169,5,111,0,0,169,170,5,115,0,0,170,14,1,0,
0,0,171,172,5,116,0,0,172,173,5,97,0,0,173,174,5,110,0,0,174,16,
1,0,0,0,175,176,5,97,0,0,176,177,5,115,0,0,177,178,5,105,0,0,178,
179,5,110,0,0,179,18,1,0,0,0,180,181,5,97,0,0,181,182,5,99,0,0,182,
183,5,111,0,0,183,184,5,115,0,0,184,20,1,0,0,0,185,186,5,97,0,0,
186,187,5,116,0,0,187,188,5,97,0,0,188,189,5,110,0,0,189,22,1,0,
0,0,190,191,5,97,0,0,191,192,5,116,0,0,192,193,5,97,0,0,193,194,
5,110,0,0,194,195,5,50,0,0,195,24,1,0,0,0,196,197,5,115,0,0,197,
198,5,105,0,0,198,199,5,110,0,0,199,200,5,104,0,0,200,26,1,0,0,0,
201,202,5,99,0,0,202,203,5,111,0,0,203,204,5,115,0,0,204,205,5,104,
0,0,205,28,1,0,0,0,206,207,5,116,0,0,207,208,5,97,0,0,208,209,5,
110,0,0,209,210,5,104,0,0,210,30,1,0,0,0,211,212,5,97,0,0,212,213,
5,115,0,0,213,214,5,105,0,0,214,215,5,110,0,0,215,216,5,104,0,0,
216,32,1,0,0,0,217,218,5,97,0,0,218,219,5,99,0,0,219,220,5,111,0,
0,220,221,5,115,0,0,221,222,5,104,0,0,222,34,1,0,0,0,223,224,5,97,
0,0,224,225,5,116,0,0,225,226,5,97,0,0,226,227,5,110,0,0,227,228,
5,104,0,0,228,36,1,0,0,0,229,230,5,97,0,0,230,231,5,98,0,0,231,232,
5,115,0,0,232,38,1,0,0,0,233,234,5,115,0,0,234,235,5,113,0,0,235,
236,5,114,0,0,236,237,5,116,0,0,237,40,1,0,0,0,238,239,5,108,0,0,
239,240,5,110,0,0,240,42,1,0,0,0,241,242,5,108,0,0,242,243,5,111,
0,0,243,244,5,103,0,0,244,44,1,0,0,0,245,246,5,101,0,0,246,247,5,
120,0,0,247,248,5,112,0,0,248,46,1,0,0,0,249,250,5,115,0,0,250,251,
5,109,0,0,251,252,5,105,0,0,252,253,5,110,0,0,253,48,1,0,0,0,254,
255,5,115,0,0,255,256,5,109,0,0,256,257,5,97,0,0,257,258,5,120,0,
0,258,50,1,0,0,0,259,260,5,116,0,0,260,261,5,109,0,0,261,262,5,105,
0,0,262,263,5,110,0,0,263,52,1,0,0,0,264,265,5,116,0,0,265,266,5,
109,0,0,266,267,5,97,0,0,267,268,5,120,0,0,268,54,1,0,0,0,269,270,
5,116,0,0,270,271,5,110,0,0,271,272,5,111,0,0,272,273,5,114,0,0,
273,274,5,109,0,0,274,56,1,0,0,0,275,276,5,115,0,0,276,277,5,110,
0,0,277,278,5,111,0,0,278,279,5,114,0,0,279,280,5,109,0,0,280,58,
1,0,0,0,281,282,5,102,0,0,282,283,5,108,0,0,283,284,5,111,0,0,284,
285,5,111,0,0,285,286,5,114,0,0,286,60,1,0,0,0,287,288,5,99,0,0,
288,289,5,101,0,0,289,290,5,105,0,0,290,291,5,108,0,0,291,62,1,0,
0,0,292,293,5,114,0,0,293,294,5,111,0,0,294,295,5,117,0,0,295,296,
5,110,0,0,296,297,5,100,0,0,297,64,1,0,0,0,298,299,5,103,0,0,299,
300,5,97,0,0,300,301,5,109,0,0,301,302,5,109,0,0,302,303,5,97,0,
0,303,66,1,0,0,0,304,305,5,112,0,0,305,306,5,111,0,0,306,307,5,119,
0,0,307,68,1,0,0,0,308,309,5,115,0,0,309,310,5,105,0,0,310,311,5,
103,0,0,311,312,5,109,0,0,312,70,1,0,0,0,313,314,5,99,0,0,314,315,
5,108,0,0,315,316,5,97,0,0,316,317,5,109,0,0,317,318,5,112,0,0,318,
72,1,0,0,0,319,320,5,102,0,0,320,321,5,102,0,0,321,322,5,116,0,0,
322,74,1,0,0,0,323,324,5,105,0,0,324,325,5,102,0,0,325,326,5,102,
0,0,326,327,5,116,0,0,327,76,1,0,0,0,328,329,5,97,0,0,329,330,5,
110,0,0,330,331,5,103,0,0,331,332,5,108,0,0,332,333,5,101,0,0,333,
78,1,0,0,0,334,335,5,112,0,0,335,336,5,114,0,0,336,337,5,105,0,0,
337,338,5,110,0,0,338,339,5,116,0,0,339,80,1,0,0,0,340,341,5,112,
0,0,341,342,5,114,0,0,342,343,5,105,0,0,343,344,5,110,0,0,344,345,
5,116,0,0,345,346,5,95,0,0,346,347,5,115,0,0,347,348,5,104,0,0,348,
349,5,97,0,0,349,350,5,112,0,0,350,356,5,101,0,0,351,352,5,112,0,
0,352,353,5,115,0,0,353,354,5,104,0,0,354,356,5,112,0,0,355,340,
1,0,0,0,355,351,1,0,0,0,356,82,1,0,0,0,357,358,5,108,0,0,358,359,
5,101,0,0,359,360,5,114,0,0,360,361,5,112,0,0,361,84,1,0,0,0,362,
363,5,115,0,0,363,364,5,116,0,0,364,365,5,101,0,0,365,366,5,112,
0,0,366,86,1,0,0,0,367,368,5,115,0,0,368,369,5,109,0,0,369,370,5,
111,0,0,370,371,5,111,0,0,371,372,5,116,0,0,372,373,5,104,0,0,373,
374,5,115,0,0,374,375,5,116,0,0,375,376,5,101,0,0,376,377,5,112,
0,0,377,88,1,0,0,0,378,379,5,102,0,0,379,380,5,114,0,0,380,381,5,
97,0,0,381,382,5,99,0,0,382,383,5,116,0,0,383,90,1,0,0,0,384,385,
5,114,0,0,385,386,5,101,0,0,386,387,5,108,0,0,387,388,5,117,0,0,
388,92,1,0,0,0,389,390,5,115,0,0,390,391,5,111,0,0,391,392,5,102,
0,0,392,393,5,116,0,0,393,394,5,112,0,0,394,395,5,108,0,0,395,396,
5,117,0,0,396,397,5,115,0,0,397,94,1,0,0,0,398,399,5,103,0,0,399,
400,5,101,0,0,400,401,5,108,0,0,401,402,5,117,0,0,402,96,1,0,0,0,
403,404,5,115,0,0,404,405,5,105,0,0,405,406,5,103,0,0,406,407,5,
110,0,0,407,98,1,0,0,0,408,409,5,109,0,0,409,410,5,97,0,0,410,411,
5,112,0,0,411,100,1,0,0,0,412,413,5,101,0,0,413,414,5,122,0,0,414,
415,5,99,0,0,415,416,5,111,0,0,416,417,5,110,0,0,417,418,5,118,0,
0,418,419,5,111,0,0,419,420,5,108,0,0,420,421,5,117,0,0,421,422,
5,116,0,0,422,423,5,105,0,0,423,424,5,111,0,0,424,432,5,110,0,0,
425,426,5,101,0,0,426,427,5,122,0,0,427,428,5,99,0,0,428,429,5,111,
0,0,429,430,5,110,0,0,430,432,5,118,0,0,431,412,1,0,0,0,431,425,
1,0,0,0,432,102,1,0,0,0,433,434,5,99,0,0,434,435,5,111,0,0,435,436,
5,110,0,0,436,437,5,118,0,0,437,438,5,111,0,0,438,439,5,108,0,0,
439,440,5,117,0,0,440,441,5,116,0,0,441,442,5,105,0,0,442,443,5,
111,0,0,443,449,5,110,0,0,444,445,5,99,0,0,445,446,5,111,0,0,446,
447,5,110,0,0,447,449,5,118,0,0,448,433,1,0,0,0,448,444,1,0,0,0,
449,104,1,0,0,0,450,451,5,115,0,0,451,452,5,119,0,0,452,453,5,97,
0,0,453,454,5,112,0,0,454,106,1,0,0,0,455,456,5,112,0,0,456,457,
5,101,0,0,457,458,5,114,0,0,458,459,5,109,0,0,459,460,5,117,0,0,
460,461,5,116,0,0,461,467,5,101,0,0,462,463,5,112,0,0,463,464,5,
101,0,0,464,465,5,114,0,0,465,467,5,109,0,0,466,455,1,0,0,0,466,
462,1,0,0,0,467,108,1,0,0,0,468,469,5,114,0,0,469,470,5,101,0,0,
470,471,5,115,0,0,471,472,5,104,0,0,472,473,5,97,0,0,473,474,5,112,
0,0,474,480,5,101,0,0,475,476,5,114,0,0,476,477,5,115,0,0,477,478,
5,104,0,0,478,480,5,112,0,0,479,468,1,0,0,0,479,475,1,0,0,0,480,
110,1,0,0,0,481,482,5,114,0,0,482,483,5,97,0,0,483,484,5,110,0,0,
484,485,5,103,0,0,485,486,5,101,0,0,486,112,1,0,0,0,487,488,5,116,
0,0,488,489,5,111,0,0,489,490,5,112,0,0,490,491,5,107,0,0,491,114,
1,0,0,0,492,493,5,98,0,0,493,494,5,111,0,0,494,495,5,116,0,0,495,
496,5,107,0,0,496,116,1,0,0,0,497,498,5,112,0,0,498,499,5,105,0,
0,499,500,5,110,0,0,500,501,5,118,0,0,501,118,1,0,0,0,502,503,5,
43,0,0,503,120,1,0,0,0,504,505,5,45,0,0,505,122,1,0,0,0,506,507,
5,42,0,0,507,124,1,0,0,0,508,509,5,47,0,0,509,126,1,0,0,0,510,511,
5,37,0,0,511,128,1,0,0,0,512,513,5,94,0,0,513,130,1,0,0,0,514,515,
5,62,0,0,515,516,5,61,0,0,516,132,1,0,0,0,517,518,5,62,0,0,518,134,
1,0,0,0,519,520,5,60,0,0,520,521,5,61,0,0,521,136,1,0,0,0,522,523,
5,60,0,0,523,138,1,0,0,0,524,525,5,61,0,0,525,526,5,61,0,0,526,140,
1,0,0,0,527,528,5,33,0,0,528,529,5,61,0,0,529,142,1,0,0,0,530,531,
5,124,0,0,531,144,1,0,0,0,532,533,5,112,0,0,533,538,5,105,0,0,534,
535,5,80,0,0,535,538,5,73,0,0,536,538,7,0,0,0,537,532,1,0,0,0,537,
534,1,0,0,0,537,536,1,0,0,0,538,146,1,0,0,0,539,541,7,1,0,0,540,
539,1,0,0,0,541,542,1,0,0,0,542,540,1,0,0,0,542,543,1,0,0,0,543,
550,1,0,0,0,544,546,5,46,0,0,545,547,7,1,0,0,546,545,1,0,0,0,547,
548,1,0,0,0,548,546,1,0,0,0,548,549,1,0,0,0,549,551,1,0,0,0,550,
544,1,0,0,0,550,551,1,0,0,0,551,148,1,0,0,0,552,556,7,2,0,0,553,
555,7,3,0,0,554,553,1,0,0,0,555,558,1,0,0,0,556,554,1,0,0,0,556,
557,1,0,0,0,557,150,1,0,0,0,558,556,1,0,0,0,559,561,7,4,0,0,560,
559,1,0,0,0,561,562,1,0,0,0,562,560,1,0,0,0,562,563,1,0,0,0,563,
564,1,0,0,0,564,565,6,75,0,0,565,152,1,0,0,0,12,0,355,431,448,466,
479,537,542,548,550,556,562,1,6,0,0
71,2,72,7,72,2,73,7,73,2,74,7,74,2,75,7,75,2,76,7,76,2,77,7,77,2,
78,7,78,2,79,7,79,2,80,7,80,2,81,7,81,2,82,7,82,1,0,1,0,1,0,1,0,
1,1,1,1,1,1,1,1,1,2,1,2,1,2,1,2,1,3,1,3,1,3,1,3,1,3,1,4,1,4,1,4,
1,4,1,4,1,5,1,5,1,5,1,5,1,5,1,6,1,6,1,6,1,6,1,6,1,6,1,7,1,7,1,7,
1,7,1,7,1,8,1,8,1,8,1,8,1,8,1,9,1,9,1,9,1,9,1,9,1,10,1,10,1,10,1,
10,1,10,1,10,1,11,1,11,1,11,1,11,1,11,1,11,1,12,1,12,1,12,1,12,1,
12,1,12,1,13,1,13,1,13,1,13,1,14,1,14,1,14,1,14,1,14,1,15,1,15,1,
15,1,16,1,16,1,16,1,16,1,17,1,17,1,17,1,17,1,18,1,18,1,18,1,18,1,
18,1,19,1,19,1,19,1,19,1,19,1,20,1,20,1,20,1,20,1,20,1,21,1,21,1,
21,1,21,1,21,1,22,1,22,1,22,1,22,1,22,1,22,1,23,1,23,1,23,1,23,1,
23,1,23,1,24,1,24,1,24,1,24,1,24,1,24,1,25,1,25,1,25,1,25,1,25,1,
26,1,26,1,26,1,26,1,26,1,26,1,27,1,27,1,27,1,27,1,27,1,27,1,28,1,
28,1,28,1,28,1,29,1,29,1,29,1,29,1,29,1,30,1,30,1,30,1,30,1,30,1,
30,1,31,1,31,1,31,1,31,1,32,1,32,1,32,1,32,1,32,1,33,1,33,1,33,1,
33,1,33,1,33,1,34,1,34,1,34,1,34,1,34,1,34,1,35,1,35,1,35,1,35,1,
35,1,35,1,35,1,35,1,35,1,35,1,35,1,35,1,35,1,35,1,35,3,35,360,8,
35,1,36,1,36,1,36,1,36,1,36,1,37,1,37,1,37,1,37,1,37,1,38,1,38,1,
38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,39,1,39,1,39,1,39,1,
39,1,39,1,40,1,40,1,40,1,40,1,40,1,41,1,41,1,41,1,41,1,41,1,41,1,
41,1,41,1,41,1,42,1,42,1,42,1,42,1,42,1,43,1,43,1,43,1,43,1,43,1,
44,1,44,1,44,1,44,1,45,1,45,1,45,1,45,1,45,1,45,1,45,1,45,1,45,1,
45,1,45,1,45,1,45,1,45,1,45,1,45,1,45,1,45,1,45,3,45,436,8,45,1,
46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,1,
46,1,46,3,46,453,8,46,1,47,1,47,1,47,1,47,1,47,1,48,1,48,1,48,1,
48,1,48,1,48,1,48,1,48,1,48,1,48,1,48,3,48,471,8,48,1,49,1,49,1,
49,1,49,1,49,1,49,1,49,1,49,1,49,1,49,1,49,3,49,484,8,49,1,50,1,
50,1,50,1,50,1,50,1,50,1,51,1,51,1,51,1,51,1,51,1,52,1,52,1,52,1,
52,1,52,1,53,1,53,1,53,1,53,1,53,1,54,1,54,1,54,1,54,1,55,1,55,1,
55,1,55,1,55,1,56,1,56,1,56,1,56,1,57,1,57,1,57,1,57,1,58,1,58,1,
58,1,58,1,58,1,58,1,58,1,58,1,58,1,59,1,59,1,59,1,59,1,59,1,59,1,
59,1,59,1,59,1,59,1,59,1,59,1,59,1,59,1,59,3,59,548,8,59,1,60,1,
60,1,60,1,60,1,61,1,61,1,62,1,62,1,63,1,63,1,64,1,64,1,65,1,65,1,
66,1,66,1,67,1,67,1,67,1,68,1,68,1,69,1,69,1,69,1,70,1,70,1,71,1,
71,1,71,1,72,1,72,1,72,1,73,1,73,1,74,1,74,1,75,1,75,1,76,1,76,1,
77,1,77,1,78,1,78,1,79,1,79,1,79,1,79,1,79,3,79,599,8,79,1,80,4,
80,602,8,80,11,80,12,80,603,1,80,1,80,4,80,608,8,80,11,80,12,80,
609,3,80,612,8,80,1,81,1,81,5,81,616,8,81,10,81,12,81,619,9,81,1,
82,4,82,622,8,82,11,82,12,82,623,1,82,1,82,0,0,83,1,1,3,2,5,3,7,
4,9,5,11,6,13,7,15,8,17,9,19,10,21,11,23,12,25,13,27,14,29,15,31,
16,33,17,35,18,37,19,39,20,41,21,43,22,45,23,47,24,49,25,51,26,53,
27,55,28,57,29,59,30,61,31,63,32,65,33,67,34,69,35,71,36,73,37,75,
38,77,39,79,40,81,41,83,42,85,43,87,44,89,45,91,46,93,47,95,48,97,
49,99,50,101,51,103,52,105,53,107,54,109,55,111,56,113,57,115,58,
117,59,119,60,121,61,123,62,125,63,127,64,129,65,131,66,133,67,135,
68,137,69,139,70,141,71,143,72,145,73,147,74,149,75,151,76,153,77,
155,78,157,79,159,80,161,81,163,82,165,83,1,0,5,2,0,69,69,101,101,
1,0,48,57,3,0,65,90,95,95,97,122,4,0,48,57,65,90,95,95,97,122,3,
0,9,10,13,13,32,32,639,0,1,1,0,0,0,0,3,1,0,0,0,0,5,1,0,0,0,0,7,1,
0,0,0,0,9,1,0,0,0,0,11,1,0,0,0,0,13,1,0,0,0,0,15,1,0,0,0,0,17,1,
0,0,0,0,19,1,0,0,0,0,21,1,0,0,0,0,23,1,0,0,0,0,25,1,0,0,0,0,27,1,
0,0,0,0,29,1,0,0,0,0,31,1,0,0,0,0,33,1,0,0,0,0,35,1,0,0,0,0,37,1,
0,0,0,0,39,1,0,0,0,0,41,1,0,0,0,0,43,1,0,0,0,0,45,1,0,0,0,0,47,1,
0,0,0,0,49,1,0,0,0,0,51,1,0,0,0,0,53,1,0,0,0,0,55,1,0,0,0,0,57,1,
0,0,0,0,59,1,0,0,0,0,61,1,0,0,0,0,63,1,0,0,0,0,65,1,0,0,0,0,67,1,
0,0,0,0,69,1,0,0,0,0,71,1,0,0,0,0,73,1,0,0,0,0,75,1,0,0,0,0,77,1,
0,0,0,0,79,1,0,0,0,0,81,1,0,0,0,0,83,1,0,0,0,0,85,1,0,0,0,0,87,1,
0,0,0,0,89,1,0,0,0,0,91,1,0,0,0,0,93,1,0,0,0,0,95,1,0,0,0,0,97,1,
0,0,0,0,99,1,0,0,0,0,101,1,0,0,0,0,103,1,0,0,0,0,105,1,0,0,0,0,107,
1,0,0,0,0,109,1,0,0,0,0,111,1,0,0,0,0,113,1,0,0,0,0,115,1,0,0,0,
0,117,1,0,0,0,0,119,1,0,0,0,0,121,1,0,0,0,0,123,1,0,0,0,0,125,1,
0,0,0,0,127,1,0,0,0,0,129,1,0,0,0,0,131,1,0,0,0,0,133,1,0,0,0,0,
135,1,0,0,0,0,137,1,0,0,0,0,139,1,0,0,0,0,141,1,0,0,0,0,143,1,0,
0,0,0,145,1,0,0,0,0,147,1,0,0,0,0,149,1,0,0,0,0,151,1,0,0,0,0,153,
1,0,0,0,0,155,1,0,0,0,0,157,1,0,0,0,0,159,1,0,0,0,0,161,1,0,0,0,
0,163,1,0,0,0,0,165,1,0,0,0,1,167,1,0,0,0,3,171,1,0,0,0,5,175,1,
0,0,0,7,179,1,0,0,0,9,184,1,0,0,0,11,189,1,0,0,0,13,194,1,0,0,0,
15,200,1,0,0,0,17,205,1,0,0,0,19,210,1,0,0,0,21,215,1,0,0,0,23,221,
1,0,0,0,25,227,1,0,0,0,27,233,1,0,0,0,29,237,1,0,0,0,31,242,1,0,
0,0,33,245,1,0,0,0,35,249,1,0,0,0,37,253,1,0,0,0,39,258,1,0,0,0,
41,263,1,0,0,0,43,268,1,0,0,0,45,273,1,0,0,0,47,279,1,0,0,0,49,285,
1,0,0,0,51,291,1,0,0,0,53,296,1,0,0,0,55,302,1,0,0,0,57,308,1,0,
0,0,59,312,1,0,0,0,61,317,1,0,0,0,63,323,1,0,0,0,65,327,1,0,0,0,
67,332,1,0,0,0,69,338,1,0,0,0,71,359,1,0,0,0,73,361,1,0,0,0,75,366,
1,0,0,0,77,371,1,0,0,0,79,382,1,0,0,0,81,388,1,0,0,0,83,393,1,0,
0,0,85,402,1,0,0,0,87,407,1,0,0,0,89,412,1,0,0,0,91,435,1,0,0,0,
93,452,1,0,0,0,95,454,1,0,0,0,97,470,1,0,0,0,99,483,1,0,0,0,101,
485,1,0,0,0,103,491,1,0,0,0,105,496,1,0,0,0,107,501,1,0,0,0,109,
506,1,0,0,0,111,510,1,0,0,0,113,515,1,0,0,0,115,519,1,0,0,0,117,
523,1,0,0,0,119,547,1,0,0,0,121,549,1,0,0,0,123,553,1,0,0,0,125,
555,1,0,0,0,127,557,1,0,0,0,129,559,1,0,0,0,131,561,1,0,0,0,133,
563,1,0,0,0,135,565,1,0,0,0,137,568,1,0,0,0,139,570,1,0,0,0,141,
573,1,0,0,0,143,575,1,0,0,0,145,578,1,0,0,0,147,581,1,0,0,0,149,
583,1,0,0,0,151,585,1,0,0,0,153,587,1,0,0,0,155,589,1,0,0,0,157,
591,1,0,0,0,159,598,1,0,0,0,161,601,1,0,0,0,163,613,1,0,0,0,165,
621,1,0,0,0,167,168,5,115,0,0,168,169,5,105,0,0,169,170,5,110,0,
0,170,2,1,0,0,0,171,172,5,99,0,0,172,173,5,111,0,0,173,174,5,115,
0,0,174,4,1,0,0,0,175,176,5,116,0,0,176,177,5,97,0,0,177,178,5,110,
0,0,178,6,1,0,0,0,179,180,5,97,0,0,180,181,5,115,0,0,181,182,5,105,
0,0,182,183,5,110,0,0,183,8,1,0,0,0,184,185,5,97,0,0,185,186,5,99,
0,0,186,187,5,111,0,0,187,188,5,115,0,0,188,10,1,0,0,0,189,190,5,
97,0,0,190,191,5,116,0,0,191,192,5,97,0,0,192,193,5,110,0,0,193,
12,1,0,0,0,194,195,5,97,0,0,195,196,5,116,0,0,196,197,5,97,0,0,197,
198,5,110,0,0,198,199,5,50,0,0,199,14,1,0,0,0,200,201,5,115,0,0,
201,202,5,105,0,0,202,203,5,110,0,0,203,204,5,104,0,0,204,16,1,0,
0,0,205,206,5,99,0,0,206,207,5,111,0,0,207,208,5,115,0,0,208,209,
5,104,0,0,209,18,1,0,0,0,210,211,5,116,0,0,211,212,5,97,0,0,212,
213,5,110,0,0,213,214,5,104,0,0,214,20,1,0,0,0,215,216,5,97,0,0,
216,217,5,115,0,0,217,218,5,105,0,0,218,219,5,110,0,0,219,220,5,
104,0,0,220,22,1,0,0,0,221,222,5,97,0,0,222,223,5,99,0,0,223,224,
5,111,0,0,224,225,5,115,0,0,225,226,5,104,0,0,226,24,1,0,0,0,227,
228,5,97,0,0,228,229,5,116,0,0,229,230,5,97,0,0,230,231,5,110,0,
0,231,232,5,104,0,0,232,26,1,0,0,0,233,234,5,97,0,0,234,235,5,98,
0,0,235,236,5,115,0,0,236,28,1,0,0,0,237,238,5,115,0,0,238,239,5,
113,0,0,239,240,5,114,0,0,240,241,5,116,0,0,241,30,1,0,0,0,242,243,
5,108,0,0,243,244,5,110,0,0,244,32,1,0,0,0,245,246,5,108,0,0,246,
247,5,111,0,0,247,248,5,103,0,0,248,34,1,0,0,0,249,250,5,101,0,0,
250,251,5,120,0,0,251,252,5,112,0,0,252,36,1,0,0,0,253,254,5,115,
0,0,254,255,5,109,0,0,255,256,5,105,0,0,256,257,5,110,0,0,257,38,
1,0,0,0,258,259,5,115,0,0,259,260,5,109,0,0,260,261,5,97,0,0,261,
262,5,120,0,0,262,40,1,0,0,0,263,264,5,116,0,0,264,265,5,109,0,0,
265,266,5,105,0,0,266,267,5,110,0,0,267,42,1,0,0,0,268,269,5,116,
0,0,269,270,5,109,0,0,270,271,5,97,0,0,271,272,5,120,0,0,272,44,
1,0,0,0,273,274,5,116,0,0,274,275,5,110,0,0,275,276,5,111,0,0,276,
277,5,114,0,0,277,278,5,109,0,0,278,46,1,0,0,0,279,280,5,115,0,0,
280,281,5,110,0,0,281,282,5,111,0,0,282,283,5,114,0,0,283,284,5,
109,0,0,284,48,1,0,0,0,285,286,5,102,0,0,286,287,5,108,0,0,287,288,
5,111,0,0,288,289,5,111,0,0,289,290,5,114,0,0,290,50,1,0,0,0,291,
292,5,99,0,0,292,293,5,101,0,0,293,294,5,105,0,0,294,295,5,108,0,
0,295,52,1,0,0,0,296,297,5,114,0,0,297,298,5,111,0,0,298,299,5,117,
0,0,299,300,5,110,0,0,300,301,5,100,0,0,301,54,1,0,0,0,302,303,5,
103,0,0,303,304,5,97,0,0,304,305,5,109,0,0,305,306,5,109,0,0,306,
307,5,97,0,0,307,56,1,0,0,0,308,309,5,112,0,0,309,310,5,111,0,0,
310,311,5,119,0,0,311,58,1,0,0,0,312,313,5,115,0,0,313,314,5,105,
0,0,314,315,5,103,0,0,315,316,5,109,0,0,316,60,1,0,0,0,317,318,5,
99,0,0,318,319,5,108,0,0,319,320,5,97,0,0,320,321,5,109,0,0,321,
322,5,112,0,0,322,62,1,0,0,0,323,324,5,102,0,0,324,325,5,102,0,0,
325,326,5,116,0,0,326,64,1,0,0,0,327,328,5,105,0,0,328,329,5,102,
0,0,329,330,5,102,0,0,330,331,5,116,0,0,331,66,1,0,0,0,332,333,5,
97,0,0,333,334,5,110,0,0,334,335,5,103,0,0,335,336,5,108,0,0,336,
337,5,101,0,0,337,68,1,0,0,0,338,339,5,112,0,0,339,340,5,114,0,0,
340,341,5,105,0,0,341,342,5,110,0,0,342,343,5,116,0,0,343,70,1,0,
0,0,344,345,5,112,0,0,345,346,5,114,0,0,346,347,5,105,0,0,347,348,
5,110,0,0,348,349,5,116,0,0,349,350,5,95,0,0,350,351,5,115,0,0,351,
352,5,104,0,0,352,353,5,97,0,0,353,354,5,112,0,0,354,360,5,101,0,
0,355,356,5,112,0,0,356,357,5,115,0,0,357,358,5,104,0,0,358,360,
5,112,0,0,359,344,1,0,0,0,359,355,1,0,0,0,360,72,1,0,0,0,361,362,
5,108,0,0,362,363,5,101,0,0,363,364,5,114,0,0,364,365,5,112,0,0,
365,74,1,0,0,0,366,367,5,115,0,0,367,368,5,116,0,0,368,369,5,101,
0,0,369,370,5,112,0,0,370,76,1,0,0,0,371,372,5,115,0,0,372,373,5,
109,0,0,373,374,5,111,0,0,374,375,5,111,0,0,375,376,5,116,0,0,376,
377,5,104,0,0,377,378,5,115,0,0,378,379,5,116,0,0,379,380,5,101,
0,0,380,381,5,112,0,0,381,78,1,0,0,0,382,383,5,102,0,0,383,384,5,
114,0,0,384,385,5,97,0,0,385,386,5,99,0,0,386,387,5,116,0,0,387,
80,1,0,0,0,388,389,5,114,0,0,389,390,5,101,0,0,390,391,5,108,0,0,
391,392,5,117,0,0,392,82,1,0,0,0,393,394,5,115,0,0,394,395,5,111,
0,0,395,396,5,102,0,0,396,397,5,116,0,0,397,398,5,112,0,0,398,399,
5,108,0,0,399,400,5,117,0,0,400,401,5,115,0,0,401,84,1,0,0,0,402,
403,5,103,0,0,403,404,5,101,0,0,404,405,5,108,0,0,405,406,5,117,
0,0,406,86,1,0,0,0,407,408,5,115,0,0,408,409,5,105,0,0,409,410,5,
103,0,0,410,411,5,110,0,0,411,88,1,0,0,0,412,413,5,109,0,0,413,414,
5,97,0,0,414,415,5,112,0,0,415,90,1,0,0,0,416,417,5,101,0,0,417,
418,5,122,0,0,418,419,5,99,0,0,419,420,5,111,0,0,420,421,5,110,0,
0,421,422,5,118,0,0,422,423,5,111,0,0,423,424,5,108,0,0,424,425,
5,117,0,0,425,426,5,116,0,0,426,427,5,105,0,0,427,428,5,111,0,0,
428,436,5,110,0,0,429,430,5,101,0,0,430,431,5,122,0,0,431,432,5,
99,0,0,432,433,5,111,0,0,433,434,5,110,0,0,434,436,5,118,0,0,435,
416,1,0,0,0,435,429,1,0,0,0,436,92,1,0,0,0,437,438,5,99,0,0,438,
439,5,111,0,0,439,440,5,110,0,0,440,441,5,118,0,0,441,442,5,111,
0,0,442,443,5,108,0,0,443,444,5,117,0,0,444,445,5,116,0,0,445,446,
5,105,0,0,446,447,5,111,0,0,447,453,5,110,0,0,448,449,5,99,0,0,449,
450,5,111,0,0,450,451,5,110,0,0,451,453,5,118,0,0,452,437,1,0,0,
0,452,448,1,0,0,0,453,94,1,0,0,0,454,455,5,115,0,0,455,456,5,119,
0,0,456,457,5,97,0,0,457,458,5,112,0,0,458,96,1,0,0,0,459,460,5,
112,0,0,460,461,5,101,0,0,461,462,5,114,0,0,462,463,5,109,0,0,463,
464,5,117,0,0,464,465,5,116,0,0,465,471,5,101,0,0,466,467,5,112,
0,0,467,468,5,101,0,0,468,469,5,114,0,0,469,471,5,109,0,0,470,459,
1,0,0,0,470,466,1,0,0,0,471,98,1,0,0,0,472,473,5,114,0,0,473,474,
5,101,0,0,474,475,5,115,0,0,475,476,5,104,0,0,476,477,5,97,0,0,477,
478,5,112,0,0,478,484,5,101,0,0,479,480,5,114,0,0,480,481,5,115,
0,0,481,482,5,104,0,0,482,484,5,112,0,0,483,472,1,0,0,0,483,479,
1,0,0,0,484,100,1,0,0,0,485,486,5,114,0,0,486,487,5,97,0,0,487,488,
5,110,0,0,488,489,5,103,0,0,489,490,5,101,0,0,490,102,1,0,0,0,491,
492,5,116,0,0,492,493,5,111,0,0,493,494,5,112,0,0,494,495,5,107,
0,0,495,104,1,0,0,0,496,497,5,98,0,0,497,498,5,111,0,0,498,499,5,
116,0,0,499,500,5,107,0,0,500,106,1,0,0,0,501,502,5,112,0,0,502,
503,5,105,0,0,503,504,5,110,0,0,504,505,5,118,0,0,505,108,1,0,0,
0,506,507,5,115,0,0,507,508,5,117,0,0,508,509,5,109,0,0,509,110,
1,0,0,0,510,511,5,109,0,0,511,512,5,101,0,0,512,513,5,97,0,0,513,
514,5,110,0,0,514,112,1,0,0,0,515,516,5,115,0,0,516,517,5,116,0,
0,517,518,5,100,0,0,518,114,1,0,0,0,519,520,5,118,0,0,520,521,5,
97,0,0,521,522,5,114,0,0,522,116,1,0,0,0,523,524,5,113,0,0,524,525,
5,117,0,0,525,526,5,97,0,0,526,527,5,114,0,0,527,528,5,116,0,0,528,
529,5,105,0,0,529,530,5,108,0,0,530,531,5,101,0,0,531,118,1,0,0,
0,532,533,5,112,0,0,533,534,5,101,0,0,534,535,5,114,0,0,535,536,
5,99,0,0,536,537,5,101,0,0,537,538,5,110,0,0,538,539,5,116,0,0,539,
540,5,105,0,0,540,541,5,108,0,0,541,548,5,101,0,0,542,543,5,112,
0,0,543,544,5,114,0,0,544,545,5,99,0,0,545,546,5,110,0,0,546,548,
5,116,0,0,547,532,1,0,0,0,547,542,1,0,0,0,548,120,1,0,0,0,549,550,
5,100,0,0,550,551,5,111,0,0,551,552,5,116,0,0,552,122,1,0,0,0,553,
554,5,43,0,0,554,124,1,0,0,0,555,556,5,45,0,0,556,126,1,0,0,0,557,
558,5,42,0,0,558,128,1,0,0,0,559,560,5,47,0,0,560,130,1,0,0,0,561,
562,5,37,0,0,562,132,1,0,0,0,563,564,5,94,0,0,564,134,1,0,0,0,565,
566,5,62,0,0,566,567,5,61,0,0,567,136,1,0,0,0,568,569,5,62,0,0,569,
138,1,0,0,0,570,571,5,60,0,0,571,572,5,61,0,0,572,140,1,0,0,0,573,
574,5,60,0,0,574,142,1,0,0,0,575,576,5,61,0,0,576,577,5,61,0,0,577,
144,1,0,0,0,578,579,5,33,0,0,579,580,5,61,0,0,580,146,1,0,0,0,581,
582,5,124,0,0,582,148,1,0,0,0,583,584,5,40,0,0,584,150,1,0,0,0,585,
586,5,41,0,0,586,152,1,0,0,0,587,588,5,44,0,0,588,154,1,0,0,0,589,
590,5,91,0,0,590,156,1,0,0,0,591,592,5,93,0,0,592,158,1,0,0,0,593,
594,5,112,0,0,594,599,5,105,0,0,595,596,5,80,0,0,596,599,5,73,0,
0,597,599,7,0,0,0,598,593,1,0,0,0,598,595,1,0,0,0,598,597,1,0,0,
0,599,160,1,0,0,0,600,602,7,1,0,0,601,600,1,0,0,0,602,603,1,0,0,
0,603,601,1,0,0,0,603,604,1,0,0,0,604,611,1,0,0,0,605,607,5,46,0,
0,606,608,7,1,0,0,607,606,1,0,0,0,608,609,1,0,0,0,609,607,1,0,0,
0,609,610,1,0,0,0,610,612,1,0,0,0,611,605,1,0,0,0,611,612,1,0,0,
0,612,162,1,0,0,0,613,617,7,2,0,0,614,616,7,3,0,0,615,614,1,0,0,
0,616,619,1,0,0,0,617,615,1,0,0,0,617,618,1,0,0,0,618,164,1,0,0,
0,619,617,1,0,0,0,620,622,7,4,0,0,621,620,1,0,0,0,622,623,1,0,0,
0,623,621,1,0,0,0,623,624,1,0,0,0,624,625,1,0,0,0,625,626,6,82,0,
0,626,166,1,0,0,0,13,0,359,435,452,470,483,547,598,603,609,611,617,
623,1,6,0,0
]
class MathExprLexer(Lexer):
@@ -218,98 +240,106 @@ class MathExprLexer(Lexer):
decisionsToDFA = [ DFA(ds, i) for i, ds in enumerate(atn.decisionToState) ]
T__0 = 1
T__1 = 2
T__2 = 3
T__3 = 4
T__4 = 5
SIN = 6
COS = 7
TAN = 8
ASIN = 9
ACOS = 10
ATAN = 11
ATAN2 = 12
SINH = 13
COSH = 14
TANH = 15
ASINH = 16
ACOSH = 17
ATANH = 18
ABS = 19
SQRT = 20
LN = 21
LOG = 22
EXP = 23
SMIN = 24
SMAX = 25
TMIN = 26
TMAX = 27
TNORM = 28
SNORM = 29
FLOOR = 30
CEIL = 31
ROUND = 32
GAMMA = 33
POWE = 34
SIGM = 35
CLAMP = 36
SFFT = 37
SIFFT = 38
ANGL = 39
PRNT = 40
PRINT_SHAPE = 41
LERP = 42
STEP = 43
SMOOTHSTEP = 44
FRACT = 45
RELU = 46
SOFTPLUS = 47
GELU = 48
SIGN = 49
MAP = 50
EZCONV = 51
CONV = 52
SWAP = 53
PERM = 54
RESHAPE = 55
RANGE = 56
TOPK = 57
BOTK = 58
PINV = 59
PLUS = 60
MINUS = 61
MULT = 62
DIV = 63
MOD = 64
POW = 65
GE = 66
GT = 67
LE = 68
LT = 69
EQ = 70
NE = 71
PIPE = 72
CONSTANT = 73
NUMBER = 74
VARIABLE = 75
WS = 76
SIN = 1
COS = 2
TAN = 3
ASIN = 4
ACOS = 5
ATAN = 6
ATAN2 = 7
SINH = 8
COSH = 9
TANH = 10
ASINH = 11
ACOSH = 12
ATANH = 13
ABS = 14
SQRT = 15
LN = 16
LOG = 17
EXP = 18
SMIN = 19
SMAX = 20
TMIN = 21
TMAX = 22
TNORM = 23
SNORM = 24
FLOOR = 25
CEIL = 26
ROUND = 27
GAMMA = 28
POWE = 29
SIGM = 30
CLAMP = 31
SFFT = 32
SIFFT = 33
ANGL = 34
PRNT = 35
PRINT_SHAPE = 36
LERP = 37
STEP = 38
SMOOTHSTEP = 39
FRACT = 40
RELU = 41
SOFTPLUS = 42
GELU = 43
SIGN = 44
MAP = 45
EZCONV = 46
CONV = 47
SWAP = 48
PERM = 49
RESHAPE = 50
RANGE = 51
TOPK = 52
BOTK = 53
PINV = 54
SUM = 55
MEAN = 56
STD = 57
VAR = 58
QUARTILE = 59
PERCENTILE = 60
DOT = 61
PLUS = 62
MINUS = 63
MULT = 64
DIV = 65
MOD = 66
POW = 67
GE = 68
GT = 69
LE = 70
LT = 71
EQ = 72
NE = 73
PIPE = 74
LPAREN = 75
RPAREN = 76
COMMA = 77
LBRACKET = 78
RBRACKET = 79
CONSTANT = 80
NUMBER = 81
VARIABLE = 82
WS = 83
channelNames = [ u"DEFAULT_TOKEN_CHANNEL", u"HIDDEN" ]
modeNames = [ "DEFAULT_MODE" ]
literalNames = [ "<INVALID>",
"'('", "')'", "'['", "','", "']'", "'sin'", "'cos'", "'tan'",
"'asin'", "'acos'", "'atan'", "'atan2'", "'sinh'", "'cosh'",
"'tanh'", "'asinh'", "'acosh'", "'atanh'", "'abs'", "'sqrt'",
"'ln'", "'log'", "'exp'", "'smin'", "'smax'", "'tmin'", "'tmax'",
"'tnorm'", "'snorm'", "'floor'", "'ceil'", "'round'", "'gamma'",
"'pow'", "'sigm'", "'clamp'", "'fft'", "'ifft'", "'angle'",
"'print'", "'lerp'", "'step'", "'smoothstep'", "'fract'", "'relu'",
"'softplus'", "'gelu'", "'sign'", "'map'", "'swap'", "'range'",
"'topk'", "'botk'", "'pinv'", "'+'", "'-'", "'*'", "'/'", "'%'",
"'^'", "'>='", "'>'", "'<='", "'<'", "'=='", "'!='", "'|'" ]
"'sin'", "'cos'", "'tan'", "'asin'", "'acos'", "'atan'", "'atan2'",
"'sinh'", "'cosh'", "'tanh'", "'asinh'", "'acosh'", "'atanh'",
"'abs'", "'sqrt'", "'ln'", "'log'", "'exp'", "'smin'", "'smax'",
"'tmin'", "'tmax'", "'tnorm'", "'snorm'", "'floor'", "'ceil'",
"'round'", "'gamma'", "'pow'", "'sigm'", "'clamp'", "'fft'",
"'ifft'", "'angle'", "'print'", "'lerp'", "'step'", "'smoothstep'",
"'fract'", "'relu'", "'softplus'", "'gelu'", "'sign'", "'map'",
"'swap'", "'range'", "'topk'", "'botk'", "'pinv'", "'sum'",
"'mean'", "'std'", "'var'", "'quartile'", "'dot'", "'+'", "'-'",
"'*'", "'/'", "'%'", "'^'", "'>='", "'>'", "'<='", "'<'", "'=='",
"'!='", "'|'", "'('", "')'", "','", "'['", "']'" ]
symbolicNames = [ "<INVALID>",
"SIN", "COS", "TAN", "ASIN", "ACOS", "ATAN", "ATAN2", "SINH",
@@ -319,21 +349,24 @@ class MathExprLexer(Lexer):
"SFFT", "SIFFT", "ANGL", "PRNT", "PRINT_SHAPE", "LERP", "STEP",
"SMOOTHSTEP", "FRACT", "RELU", "SOFTPLUS", "GELU", "SIGN", "MAP",
"EZCONV", "CONV", "SWAP", "PERM", "RESHAPE", "RANGE", "TOPK",
"BOTK", "PINV", "PLUS", "MINUS", "MULT", "DIV", "MOD", "POW",
"GE", "GT", "LE", "LT", "EQ", "NE", "PIPE", "CONSTANT", "NUMBER",
"VARIABLE", "WS" ]
"BOTK", "PINV", "SUM", "MEAN", "STD", "VAR", "QUARTILE", "PERCENTILE",
"DOT", "PLUS", "MINUS", "MULT", "DIV", "MOD", "POW", "GE", "GT",
"LE", "LT", "EQ", "NE", "PIPE", "LPAREN", "RPAREN", "COMMA",
"LBRACKET", "RBRACKET", "CONSTANT", "NUMBER", "VARIABLE", "WS" ]
ruleNames = [ "T__0", "T__1", "T__2", "T__3", "T__4", "SIN", "COS",
"TAN", "ASIN", "ACOS", "ATAN", "ATAN2", "SINH", "COSH",
"TANH", "ASINH", "ACOSH", "ATANH", "ABS", "SQRT", "LN",
"LOG", "EXP", "SMIN", "SMAX", "TMIN", "TMAX", "TNORM",
"SNORM", "FLOOR", "CEIL", "ROUND", "GAMMA", "POWE", "SIGM",
"CLAMP", "SFFT", "SIFFT", "ANGL", "PRNT", "PRINT_SHAPE",
ruleNames = [ "SIN", "COS", "TAN", "ASIN", "ACOS", "ATAN", "ATAN2",
"SINH", "COSH", "TANH", "ASINH", "ACOSH", "ATANH", "ABS",
"SQRT", "LN", "LOG", "EXP", "SMIN", "SMAX", "TMIN", "TMAX",
"TNORM", "SNORM", "FLOOR", "CEIL", "ROUND", "GAMMA", "POWE",
"SIGM", "CLAMP", "SFFT", "SIFFT", "ANGL", "PRNT", "PRINT_SHAPE",
"LERP", "STEP", "SMOOTHSTEP", "FRACT", "RELU", "SOFTPLUS",
"GELU", "SIGN", "MAP", "EZCONV", "CONV", "SWAP", "PERM",
"RESHAPE", "RANGE", "TOPK", "BOTK", "PINV", "PLUS", "MINUS",
"MULT", "DIV", "MOD", "POW", "GE", "GT", "LE", "LT", "EQ",
"NE", "PIPE", "CONSTANT", "NUMBER", "VARIABLE", "WS" ]
"RESHAPE", "RANGE", "TOPK", "BOTK", "PINV", "SUM", "MEAN",
"STD", "VAR", "QUARTILE", "PERCENTILE", "DOT", "PLUS",
"MINUS", "MULT", "DIV", "MOD", "POW", "GE", "GT", "LE",
"LT", "EQ", "NE", "PIPE", "LPAREN", "RPAREN", "COMMA",
"LBRACKET", "RBRACKET", "CONSTANT", "NUMBER", "VARIABLE",
"WS" ]
grammarFileName = "MathExpr.g4"
+156 -143
View File
@@ -1,143 +1,156 @@
T__0=1
T__1=2
T__2=3
T__3=4
T__4=5
SIN=6
COS=7
TAN=8
ASIN=9
ACOS=10
ATAN=11
ATAN2=12
SINH=13
COSH=14
TANH=15
ASINH=16
ACOSH=17
ATANH=18
ABS=19
SQRT=20
LN=21
LOG=22
EXP=23
SMIN=24
SMAX=25
TMIN=26
TMAX=27
TNORM=28
SNORM=29
FLOOR=30
CEIL=31
ROUND=32
GAMMA=33
POWE=34
SIGM=35
CLAMP=36
SFFT=37
SIFFT=38
ANGL=39
PRNT=40
PRINT_SHAPE=41
LERP=42
STEP=43
SMOOTHSTEP=44
FRACT=45
RELU=46
SOFTPLUS=47
GELU=48
SIGN=49
MAP=50
EZCONV=51
CONV=52
SWAP=53
PERM=54
RESHAPE=55
RANGE=56
TOPK=57
BOTK=58
PINV=59
PLUS=60
MINUS=61
MULT=62
DIV=63
MOD=64
POW=65
GE=66
GT=67
LE=68
LT=69
EQ=70
NE=71
PIPE=72
CONSTANT=73
NUMBER=74
VARIABLE=75
WS=76
'('=1
')'=2
'['=3
','=4
']'=5
'sin'=6
'cos'=7
'tan'=8
'asin'=9
'acos'=10
'atan'=11
'atan2'=12
'sinh'=13
'cosh'=14
'tanh'=15
'asinh'=16
'acosh'=17
'atanh'=18
'abs'=19
'sqrt'=20
'ln'=21
'log'=22
'exp'=23
'smin'=24
'smax'=25
'tmin'=26
'tmax'=27
'tnorm'=28
'snorm'=29
'floor'=30
'ceil'=31
'round'=32
'gamma'=33
'pow'=34
'sigm'=35
'clamp'=36
'fft'=37
'ifft'=38
'angle'=39
'print'=40
'lerp'=42
'step'=43
'smoothstep'=44
'fract'=45
'relu'=46
'softplus'=47
'gelu'=48
'sign'=49
'map'=50
'swap'=53
'range'=56
'topk'=57
'botk'=58
'pinv'=59
'+'=60
'-'=61
'*'=62
'/'=63
'%'=64
'^'=65
'>='=66
'>'=67
'<='=68
'<'=69
'=='=70
'!='=71
'|'=72
SIN=1
COS=2
TAN=3
ASIN=4
ACOS=5
ATAN=6
ATAN2=7
SINH=8
COSH=9
TANH=10
ASINH=11
ACOSH=12
ATANH=13
ABS=14
SQRT=15
LN=16
LOG=17
EXP=18
SMIN=19
SMAX=20
TMIN=21
TMAX=22
TNORM=23
SNORM=24
FLOOR=25
CEIL=26
ROUND=27
GAMMA=28
POWE=29
SIGM=30
CLAMP=31
SFFT=32
SIFFT=33
ANGL=34
PRNT=35
PRINT_SHAPE=36
LERP=37
STEP=38
SMOOTHSTEP=39
FRACT=40
RELU=41
SOFTPLUS=42
GELU=43
SIGN=44
MAP=45
EZCONV=46
CONV=47
SWAP=48
PERM=49
RESHAPE=50
RANGE=51
TOPK=52
BOTK=53
PINV=54
SUM=55
MEAN=56
STD=57
VAR=58
QUARTILE=59
PERCENTILE=60
DOT=61
PLUS=62
MINUS=63
MULT=64
DIV=65
MOD=66
POW=67
GE=68
GT=69
LE=70
LT=71
EQ=72
NE=73
PIPE=74
LPAREN=75
RPAREN=76
COMMA=77
LBRACKET=78
RBRACKET=79
CONSTANT=80
NUMBER=81
VARIABLE=82
WS=83
'sin'=1
'cos'=2
'tan'=3
'asin'=4
'acos'=5
'atan'=6
'atan2'=7
'sinh'=8
'cosh'=9
'tanh'=10
'asinh'=11
'acosh'=12
'atanh'=13
'abs'=14
'sqrt'=15
'ln'=16
'log'=17
'exp'=18
'smin'=19
'smax'=20
'tmin'=21
'tmax'=22
'tnorm'=23
'snorm'=24
'floor'=25
'ceil'=26
'round'=27
'gamma'=28
'pow'=29
'sigm'=30
'clamp'=31
'fft'=32
'ifft'=33
'angle'=34
'print'=35
'lerp'=37
'step'=38
'smoothstep'=39
'fract'=40
'relu'=41
'softplus'=42
'gelu'=43
'sign'=44
'map'=45
'swap'=48
'range'=51
'topk'=52
'botk'=53
'pinv'=54
'sum'=55
'mean'=56
'std'=57
'var'=58
'quartile'=59
'dot'=61
'+'=62
'-'=63
'*'=64
'/'=65
'%'=66
'^'=67
'>='=68
'>'=69
'<='=70
'<'=71
'=='=72
'!='=73
'|'=74
'('=75
')'=76
','=77
'['=78
']'=79
+72
View File
@@ -602,6 +602,42 @@ class MathExprListener(ParseTreeListener):
pass
# Enter a parse tree produced by MathExprParser#SumFunc.
def enterSumFunc(self, ctx:MathExprParser.SumFuncContext):
pass
# Exit a parse tree produced by MathExprParser#SumFunc.
def exitSumFunc(self, ctx:MathExprParser.SumFuncContext):
pass
# Enter a parse tree produced by MathExprParser#MeanFunc.
def enterMeanFunc(self, ctx:MathExprParser.MeanFuncContext):
pass
# Exit a parse tree produced by MathExprParser#MeanFunc.
def exitMeanFunc(self, ctx:MathExprParser.MeanFuncContext):
pass
# Enter a parse tree produced by MathExprParser#StdFunc.
def enterStdFunc(self, ctx:MathExprParser.StdFuncContext):
pass
# Exit a parse tree produced by MathExprParser#StdFunc.
def exitStdFunc(self, ctx:MathExprParser.StdFuncContext):
pass
# Enter a parse tree produced by MathExprParser#VarFunc.
def enterVarFunc(self, ctx:MathExprParser.VarFuncContext):
pass
# Exit a parse tree produced by MathExprParser#VarFunc.
def exitVarFunc(self, ctx:MathExprParser.VarFuncContext):
pass
# Enter a parse tree produced by MathExprParser#PowFunc.
def enterPowFunc(self, ctx:MathExprParser.PowFuncContext):
pass
@@ -665,6 +701,33 @@ class MathExprListener(ParseTreeListener):
pass
# Enter a parse tree produced by MathExprParser#QuartileFunc.
def enterQuartileFunc(self, ctx:MathExprParser.QuartileFuncContext):
pass
# Exit a parse tree produced by MathExprParser#QuartileFunc.
def exitQuartileFunc(self, ctx:MathExprParser.QuartileFuncContext):
pass
# Enter a parse tree produced by MathExprParser#PercentileFunc.
def enterPercentileFunc(self, ctx:MathExprParser.PercentileFuncContext):
pass
# Exit a parse tree produced by MathExprParser#PercentileFunc.
def exitPercentileFunc(self, ctx:MathExprParser.PercentileFuncContext):
pass
# Enter a parse tree produced by MathExprParser#DotFunc.
def enterDotFunc(self, ctx:MathExprParser.DotFuncContext):
pass
# Exit a parse tree produced by MathExprParser#DotFunc.
def exitDotFunc(self, ctx:MathExprParser.DotFuncContext):
pass
# Enter a parse tree produced by MathExprParser#ClampFunc.
def enterClampFunc(self, ctx:MathExprParser.ClampFuncContext):
pass
@@ -737,6 +800,15 @@ class MathExprListener(ParseTreeListener):
pass
# Enter a parse tree produced by MathExprParser#EzConvFunc.
def enterEzConvFunc(self, ctx:MathExprParser.EzConvFuncContext):
pass
# Exit a parse tree produced by MathExprParser#EzConvFunc.
def exitEzConvFunc(self, ctx:MathExprParser.EzConvFuncContext):
pass
# Enter a parse tree produced by MathExprParser#ConvFunc.
def enterConvFunc(self, ctx:MathExprParser.ConvFuncContext):
pass
File diff suppressed because it is too large Load Diff
+36 -1
View File
@@ -1,4 +1,4 @@
# Generated from MathExpr.g4 by ANTLR 4.13.2
# Generated from ./MathExpr.g4 by ANTLR 4.13.2
from antlr4 import *
if "." in __name__:
from .MathExprParser import MathExprParser
@@ -339,6 +339,26 @@ class MathExprVisitor(ParseTreeVisitor):
return self.visitChildren(ctx)
# Visit a parse tree produced by MathExprParser#SumFunc.
def visitSumFunc(self, ctx:MathExprParser.SumFuncContext):
return self.visitChildren(ctx)
# Visit a parse tree produced by MathExprParser#MeanFunc.
def visitMeanFunc(self, ctx:MathExprParser.MeanFuncContext):
return self.visitChildren(ctx)
# Visit a parse tree produced by MathExprParser#StdFunc.
def visitStdFunc(self, ctx:MathExprParser.StdFuncContext):
return self.visitChildren(ctx)
# Visit a parse tree produced by MathExprParser#VarFunc.
def visitVarFunc(self, ctx:MathExprParser.VarFuncContext):
return self.visitChildren(ctx)
# Visit a parse tree produced by MathExprParser#PowFunc.
def visitPowFunc(self, ctx:MathExprParser.PowFuncContext):
return self.visitChildren(ctx)
@@ -374,6 +394,21 @@ class MathExprVisitor(ParseTreeVisitor):
return self.visitChildren(ctx)
# Visit a parse tree produced by MathExprParser#QuartileFunc.
def visitQuartileFunc(self, ctx:MathExprParser.QuartileFuncContext):
return self.visitChildren(ctx)
# Visit a parse tree produced by MathExprParser#PercentileFunc.
def visitPercentileFunc(self, ctx:MathExprParser.PercentileFuncContext):
return self.visitChildren(ctx)
# Visit a parse tree produced by MathExprParser#DotFunc.
def visitDotFunc(self, ctx:MathExprParser.DotFuncContext):
return self.visitChildren(ctx)
# Visit a parse tree produced by MathExprParser#ClampFunc.
def visitClampFunc(self, ctx:MathExprParser.ClampFuncContext):
return self.visitChildren(ctx)
+93
View File
@@ -62,6 +62,13 @@ class UnifiedMathVisitor(MathExprVisitor):
return torch_op(a).contiguous() if torch_op else scalar_op(a)
return scalar_op(a)
def _reduction_op(self, val, torch_op, list_op):
if self._is_tensor(val):
return torch_op(val)
if self._is_list(val):
return list_op(val)
return val
# ========================
# Visitors
# ========================
@@ -587,6 +594,92 @@ class UnifiedMathVisitor(MathExprVisitor):
return (coord / (size - 1)) * 2.0 - 1.0
return torch.zeros_like(coord)
def visitSumFunc(self, ctx):
return self._reduction_op(self.visit(ctx.expr()), torch.sum, sum)
def visitMeanFunc(self, ctx):
return self._reduction_op(
self.visit(ctx.expr()), lambda x: torch.mean(x.float()), lambda x: sum(x) / len(x) if x else 0.0
)
def visitStdFunc(self, ctx):
def list_std(val):
if len(val) < 2:
return 0.0
mean = sum(val) / len(val)
variance = sum((x - mean) ** 2 for x in val) / (len(val) - 1)
return math.sqrt(variance)
return self._reduction_op(self.visit(ctx.expr()), lambda x: torch.std(x.float()), list_std)
def visitVarFunc(self, ctx):
def list_var(val):
if len(val) < 2:
return 0.0
mean = sum(val) / len(val)
return sum((x - mean) ** 2 for x in val) / (len(val) - 1)
return self._reduction_op(self.visit(ctx.expr()), lambda x: torch.var(x.float()), list_var)
def _quartile_helper(self, val, q):
if self._is_tensor(val):
return torch.quantile(val.float(), q)
if self._is_list(val):
if not val:
return 0.0
sorted_data = sorted(val)
n = len(val)
pos = (n - 1) * q
whole = int(pos)
frac = pos - whole
if whole + 1 < n:
return sorted_data[whole] + (sorted_data[whole + 1] - sorted_data[whole]) * frac
else:
return sorted_data[whole]
return val
def visitQuartileFunc(self, ctx):
val = self.visit(ctx.expr(0))
k = self.visit(ctx.expr(1))
if self._is_tensor(k):
k_val = torch.tensor([self._quartile_helper(val,int(k.flatten()[x].item())/4.0) for x in range(0,k.flatten().shape[0])])
return k_val.reshape(k.shape)
if self._is_list(k):
return [self._quartile_helper(val,int(k[x])/4.0) for x in range(0,k.size)]
else:
k_val = int(k)
q = 0.5
if 0 <= k_val <= 4:
q = k_val * 0.25
else:
if k_val < 0: q = 0.0
if k_val > 4: q = 1.0
return self._quartile_helper(val, q)
def visitPercentileFunc(self, ctx):
val = self.visit(ctx.expr(0))
p_raw = self.visit(ctx.expr(1))
if self._is_tensor(p_raw):
k_val = torch.tensor([self._quartile_helper(val,p_raw.flatten()[x].item()) for x in range(0,p_raw.flatten().shape[0])])
return k_val.reshape(p_raw.shape)
if self._is_list(p_raw):
return [self._quartile_helper(val,p_raw[x]) for x in range(0,p_raw.size)]
else:
p = float(p_raw)
q = max(0.0, min(1.0, p))
return self._quartile_helper(val, q)
def visitDotFunc(self, ctx):
a = self._promote_to_tensor(self.visit(ctx.expr(0)))
b = self._promote_to_tensor(self.visit(ctx.expr(1)))
return torch.dot(a.flatten(), b.flatten())
def visitMapFunc(self, ctx):
tensor = self._promote_to_tensor(self.visit(ctx.expr(0)))
coords = [self._promote_to_tensor(self.visit(ctx.expr(i))) for i in range(1, len(ctx.expr()))]