AI: more functions 2

This commit is contained in:
mcDandy
2026-10-13 21:50:07 +02:00
parent 7761afd3e6
commit a113adba1d
22 changed files with 12649 additions and 11392 deletions
+10 -1
View File
@@ -105,6 +105,7 @@ You can also get the node from comfy manager under the name of More math.
- `sqrt(x)`: square root.
- `ln(x)`: natural logarithm.
- `log(x)`: base-10 logarithm.
- `log2(x)`: base-2 logarithm.
- `exp(x)`: exponential `e^x`.
- `log1p(x)`: numerically stable `ln(1 + x)`.
- `expm1(x)`: numerically stable `exp(x) - 1`.
@@ -123,6 +124,7 @@ You can also get the node from comfy manager under the name of More math.
- `clamp(x, min, max)`: clamp to interval.
- `step(x, edge)`: returns `1` when `x >= edge`, otherwise `0`.
- `dist(x1, y1, x2, y2)` / `distance`: Euclidean distance between 2D points.
- `hypot(x, y)`: element-wise Euclidean distance from the origin, computed robustly as `sqrt(x*x + y*y)`.
#### 1.2 Trigonometric
- `sin(x)`: sine in radians.
@@ -132,6 +134,8 @@ You can also get the node from comfy manager under the name of More math.
- `acos(x)`: inverse cosine.
- `atan(x)`: inverse tangent.
- `atan2(y, x)`: quadrant-aware inverse tangent.
- `degrees(x)`: convert radians to degrees.
- `radians(x)`: convert degrees to radians.
#### 1.3 Hyperbolic
- `sinh(x)`: hyperbolic sine.
@@ -151,7 +155,12 @@ You can also get the node from comfy manager under the name of More math.
- `erf(x)`: error function.
- `erfinv(x)`: inverse error function.
#### 1.5 Interpolation & Remap
#### 1.5 Logical
- `logical_not(x)`: element-wise logical NOT; returns `1.0` where `x` is zero and `0.0` otherwise.
- `logical_and(x, y)`: element-wise logical AND; returns `1.0` where both values are non-zero and `0.0` otherwise.
- `logical_or(x, y)`: element-wise logical OR; returns `1.0` where either value is non-zero and `0.0` otherwise.
#### 1.6 Interpolation & Remap
- `lerp(a, b, t)`: linear interpolation.
- `smoothstep(x, e0, e1)`: 3rd-order smooth transition.
- `smootherstep(x, e0, e1)`: 5th-order smoother transition.
+35
View File
@@ -201,6 +201,10 @@ func1:
log(x) - applies base 10 logarithm to value (per element). Negative numbers return NaN (not a number)
*/
| LOG LPAREN expr RPAREN # LogFunc
/**
log2(x) - applies base 2 logarithm to value (per element). Negative numbers return NaN (not a number)
*/
| LOG2 LPAREN expr RPAREN # Log2Func
/**
exp(x) - applies e^x to value (per element)
*/
@@ -278,6 +282,18 @@ func1:
*/
| SIGN LPAREN expr RPAREN # SignFunc
/**
degrees(x) - converts radians to degrees (per element)
*/
| DEGREES LPAREN expr RPAREN # DegreesFunc
/**
radians(x) - converts degrees to radians (per element)
*/
| RADIANS LPAREN expr RPAREN # RadiansFunc
/**
logical_not(x) - returns 1.0 where x is zero and 0.0 otherwise
*/
| LOGICAL_NOT LPAREN expr RPAREN # LogicalNotFunc
/**
print_shape(x) - prints the shape of the tensor x
*/
| PRINT_SHAPE LPAREN expr RPAREN # PrintShapeFunc
@@ -503,6 +519,18 @@ func2:
atan2(y, x) - computes the arc tangent of y/x, using the signs of both arguments to determine the quadrant
*/
| ATAN2 LPAREN expr COMMA expr RPAREN # Atan2Func
/**
hypot(x, y) - computes the element-wise Euclidean distance from the origin
*/
| HYPOT LPAREN expr COMMA expr RPAREN # HypotFunc
/**
logical_and(x, y) - returns 1.0 if both values are non-zero, else 0.0
*/
| LOGICAL_AND LPAREN expr COMMA expr RPAREN # LogicalAndFunc
/**
logical_or(x, y) - returns 1.0 if either value is non-zero, else 0.0
*/
| LOGICAL_OR LPAREN expr COMMA expr RPAREN # LogicalOrFunc
/**
isclose(a, b, [rtol], [atol]) - elementwise approximate equality test
*/
@@ -998,6 +1026,7 @@ ABS: 'abs';
SQRT: 'sqrt';
LN: 'ln';
LOG: 'log';
LOG2: 'log2';
EXP: 'exp';
LOG1P: 'log1p';
EXPM1: 'expm1';
@@ -1031,6 +1060,12 @@ RELU: 'relu';
SOFTPLUS: 'softplus';
GELU: 'gelu';
SIGN: 'sign';
DEGREES: 'degrees';
RADIANS: 'radians';
LOGICAL_NOT: 'logical_not';
LOGICAL_AND: 'logical_and';
LOGICAL_OR: 'logical_or';
HYPOT: 'hypot';
MAP: 'map';
EZCONV: 'ezconvolution' | 'ezconv';
CONV: 'convolution' | 'conv';
+37
View File
@@ -1036,6 +1036,9 @@ class UnifiedMathVisitor(MathExprVisitor):
def visitLogFunc(self, ctx):
return self._unary_op((yield ctx.expr()), torch.log10, math.log10)
def visitLog2Func(self, ctx):
return self._unary_op((yield ctx.expr()), torch.log2, math.log2)
def visitExpFunc(self, ctx):
return self._unary_op((yield ctx.expr()), torch.exp, math.exp)
@@ -1066,6 +1069,19 @@ class UnifiedMathVisitor(MathExprVisitor):
def visitSignFunc(self, ctx):
return self._unary_op((yield ctx.expr()), torch.sign, lambda x: (1.0 if x > 0 else (-1.0 if x < 0 else 0.0)))
def visitDegreesFunc(self, ctx):
return self._unary_op((yield ctx.expr()), torch.rad2deg, math.degrees)
def visitRadiansFunc(self, ctx):
return self._unary_op((yield ctx.expr()), torch.deg2rad, math.radians)
def visitLogicalNotFunc(self, ctx):
return self._unary_op(
(yield ctx.expr()),
lambda x: torch.logical_not(x).to(torch.float32),
lambda x: 0.0 if bool(x) else 1.0,
)
def visitFractFunc(self, ctx):
return self._unary_op((yield ctx.expr()), lambda x: x - torch.floor(x), lambda x: x - math.floor(x))
@@ -1127,6 +1143,27 @@ class UnifiedMathVisitor(MathExprVisitor):
def visitAtan2Func(self, ctx):
return self._bin_op((yield ctx.expr(0)), (yield ctx.expr(1)), torch.atan2, math.atan2,ctx)
def visitHypotFunc(self, ctx):
return self._bin_op((yield ctx.expr(0)), (yield ctx.expr(1)), torch.hypot, math.hypot, ctx)
def visitLogicalAndFunc(self, ctx):
return self._bin_op(
(yield ctx.expr(0)),
(yield ctx.expr(1)),
lambda a, b: torch.logical_and(a, b).to(torch.float32),
lambda a, b: 1.0 if bool(a) and bool(b) else 0.0,
ctx,
)
def visitLogicalOrFunc(self, ctx):
return self._bin_op(
(yield ctx.expr(0)),
(yield ctx.expr(1)),
lambda a, b: torch.logical_or(a, b).to(torch.float32),
lambda a, b: 1.0 if bool(a) or bool(b) else 0.0,
ctx,
)
def visitIscloseFunc(self, ctx):
a = yield ctx.expr(0)
b = yield ctx.expr(1)
File diff suppressed because one or more lines are too long
+419 -405
View File
@@ -15,244 +15,251 @@ ABS=14
SQRT=15
LN=16
LOG=17
EXP=18
LOG1P=19
EXPM1=20
ISNAN=21
ISINF=22
ISFINITE=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
NVL=42
LERP=43
STEP=44
SMOOTHSTEP=45
FRACT=46
RELU=47
SOFTPLUS=48
GELU=49
SIGN=50
MAP=51
EZCONV=52
CONV=53
SWAP=54
TRANSPOSE=55
PERM=56
RESHAPE=57
RANGE=58
LINSPACE=59
LOGSPACE=60
TOPK=61
BOTK=62
PINV=63
SUM=64
MEAN=65
STD=66
VAR=67
PROD=68
ISCLOSE=69
ALLCLOSE=70
QUARTILE=71
PERCENTILE=72
QUANTILE=73
DOT=74
MOMENT=75
ERF=76
ERFINV=77
ANY=78
ALL=79
EDGE=80
GAUSSIAN=81
MEDIAN=82
MODE=83
CUMSUM=84
CUMPROD=85
TOPK_IND=86
BOTK_IND=87
CUBIC_EASE=88
ELASTIC_EASE=89
SINE_EASE=90
SMOOTHERSTEP=91
DIST=92
REMAP=93
COSSIM=94
COUNT=95
KEYS=96
ENABLE_TRACKING=97
DISABLE_TRACKING=98
RESET_TRACKING=99
GET_CHANGED_KEYS=100
GET_ADDED_KEYS=101
GET_REMOVED_KEYS=102
GET_UNCHANGED_KEYS=103
REPEAT=104
FLATTEN=105
APPEND=106
GET_VALUE=107
FLOW_APPLY=108
BATCH_SHUFFLE=109
MOTION_MASK=110
FLOW_TO_IMAGE=111
FLOW_MAG=112
FLOW_ANG=113
WHERE=114
HISTOGRAM=115
OVERLAY=116
PAD=117
CROSS=118
MATMUL=119
RIFE=120
BNOT=121
BITCOUNT=122
SHAPE=123
BAND=124
XOR=125
BOR=126
TENSOR=127
ADD_KEY=128
REMOVE_KEY=129
PUSH=130
POP=131
CLEAR=132
HAS=133
GET=134
CONCAT=135
STACK=136
NONZERO=137
INT=138
FLOAT=139
UPPER=140
LOWER=141
TRIM=142
SPLIT=143
JOIN=144
SUBSTRING=145
FIND=146
REPLACE=147
DILATE=148
ERODE=149
MORPH_OPEN=150
MORPH_CLOSE=151
RGB_TO_OKLAB=152
RGB_TO_CIELAB=153
OKLAB_TO_RGB=154
CIELAB_TO_RGB=155
RGB_TO_HSV=156
HSV_TO_RGB=157
INT_TO_RGB=158
RGB_TO_INT=159
INTERPOLATE_LINEAR=160
INTERPOLATE_AREA=161
INTERPOLATE_NEAREST=162
TEXT_IMAGE=163
AS_NESTED=164
SVD=165
DIAG=166
IF=167
ELSE=168
WHILE=169
FOR=170
IN=171
BREAK=172
CONTINUE=173
RETURN=174
TIMESTAMP=175
SORT=176
ARGSORT=177
ARGMIN=178
ARGMAX=179
SOFTMAX=180
SOFTMIN=181
UNIQUE=182
FLIP=183
STARTSWITH=184
ENDSWITH=185
SQUEEZE=186
UNSQUEEZE=187
ROLL=188
COV=189
CORR=190
ENTROPY=191
CROP=192
NONE=193
COORDS=194
GATHER=195
SCATTER=196
SCATTER_ADD=197
NOISE=198
RAND=199
CAUCHY=200
EXPONENTIAL=201
LOGNORMAL=202
BERNOULLI=203
POISSON=204
GAMMADIST=205
BETADIST=206
LAPLACEDIST=207
GUMBELDIST=208
WEIBULLDIST=209
CHI2DIST=210
STUDENTTDIST=211
PERLIN=212
CELLULAR=213
PLASMA=214
RIDGED=215
DOMAIN_WARP=216
PLUS=217
MINUS=218
MULT=219
DIV=220
MOD=221
POW=222
LSHIFT=223
RSHIFT=224
GE=225
GT=226
LE=227
LT=228
EQ=229
EQUEALS=230
PLUS_EQ=231
MINUS_EQ=232
MULT_EQ=233
DIV_EQ=234
MOD_EQ=235
NE=236
PIPE=237
LPAREN=238
RPAREN=239
COMMA=240
SEMICOLON=241
ARROW=242
LBRACKET=243
RBRACKET=244
QUESTION=245
COLON=246
LBRACE=247
RBRACE=248
NUMBER=249
CONSTANT=250
STRING=251
VARIABLE=252
SL_COMMENT=253
ML_COMMENT=254
WS=255
LOG2=18
EXP=19
LOG1P=20
EXPM1=21
ISNAN=22
ISINF=23
ISFINITE=24
SMIN=25
SMAX=26
TMIN=27
TMAX=28
TNORM=29
SNORM=30
FLOOR=31
CEIL=32
ROUND=33
GAMMA=34
POWE=35
SIGM=36
CLAMP=37
SFFT=38
SIFFT=39
ANGL=40
PRNT=41
PRINT_SHAPE=42
NVL=43
LERP=44
STEP=45
SMOOTHSTEP=46
FRACT=47
RELU=48
SOFTPLUS=49
GELU=50
SIGN=51
DEGREES=52
RADIANS=53
LOGICAL_NOT=54
LOGICAL_AND=55
LOGICAL_OR=56
HYPOT=57
MAP=58
EZCONV=59
CONV=60
SWAP=61
TRANSPOSE=62
PERM=63
RESHAPE=64
RANGE=65
LINSPACE=66
LOGSPACE=67
TOPK=68
BOTK=69
PINV=70
SUM=71
MEAN=72
STD=73
VAR=74
PROD=75
ISCLOSE=76
ALLCLOSE=77
QUARTILE=78
PERCENTILE=79
QUANTILE=80
DOT=81
MOMENT=82
ERF=83
ERFINV=84
ANY=85
ALL=86
EDGE=87
GAUSSIAN=88
MEDIAN=89
MODE=90
CUMSUM=91
CUMPROD=92
TOPK_IND=93
BOTK_IND=94
CUBIC_EASE=95
ELASTIC_EASE=96
SINE_EASE=97
SMOOTHERSTEP=98
DIST=99
REMAP=100
COSSIM=101
COUNT=102
KEYS=103
ENABLE_TRACKING=104
DISABLE_TRACKING=105
RESET_TRACKING=106
GET_CHANGED_KEYS=107
GET_ADDED_KEYS=108
GET_REMOVED_KEYS=109
GET_UNCHANGED_KEYS=110
REPEAT=111
FLATTEN=112
APPEND=113
GET_VALUE=114
FLOW_APPLY=115
BATCH_SHUFFLE=116
MOTION_MASK=117
FLOW_TO_IMAGE=118
FLOW_MAG=119
FLOW_ANG=120
WHERE=121
HISTOGRAM=122
OVERLAY=123
PAD=124
CROSS=125
MATMUL=126
RIFE=127
BNOT=128
BITCOUNT=129
SHAPE=130
BAND=131
XOR=132
BOR=133
TENSOR=134
ADD_KEY=135
REMOVE_KEY=136
PUSH=137
POP=138
CLEAR=139
HAS=140
GET=141
CONCAT=142
STACK=143
NONZERO=144
INT=145
FLOAT=146
UPPER=147
LOWER=148
TRIM=149
SPLIT=150
JOIN=151
SUBSTRING=152
FIND=153
REPLACE=154
DILATE=155
ERODE=156
MORPH_OPEN=157
MORPH_CLOSE=158
RGB_TO_OKLAB=159
RGB_TO_CIELAB=160
OKLAB_TO_RGB=161
CIELAB_TO_RGB=162
RGB_TO_HSV=163
HSV_TO_RGB=164
INT_TO_RGB=165
RGB_TO_INT=166
INTERPOLATE_LINEAR=167
INTERPOLATE_AREA=168
INTERPOLATE_NEAREST=169
TEXT_IMAGE=170
AS_NESTED=171
SVD=172
DIAG=173
IF=174
ELSE=175
WHILE=176
FOR=177
IN=178
BREAK=179
CONTINUE=180
RETURN=181
TIMESTAMP=182
SORT=183
ARGSORT=184
ARGMIN=185
ARGMAX=186
SOFTMAX=187
SOFTMIN=188
UNIQUE=189
FLIP=190
STARTSWITH=191
ENDSWITH=192
SQUEEZE=193
UNSQUEEZE=194
ROLL=195
COV=196
CORR=197
ENTROPY=198
CROP=199
NONE=200
COORDS=201
GATHER=202
SCATTER=203
SCATTER_ADD=204
NOISE=205
RAND=206
CAUCHY=207
EXPONENTIAL=208
LOGNORMAL=209
BERNOULLI=210
POISSON=211
GAMMADIST=212
BETADIST=213
LAPLACEDIST=214
GUMBELDIST=215
WEIBULLDIST=216
CHI2DIST=217
STUDENTTDIST=218
PERLIN=219
CELLULAR=220
PLASMA=221
RIDGED=222
DOMAIN_WARP=223
PLUS=224
MINUS=225
MULT=226
DIV=227
MOD=228
POW=229
LSHIFT=230
RSHIFT=231
GE=232
GT=233
LE=234
LT=235
EQ=236
EQUEALS=237
PLUS_EQ=238
MINUS_EQ=239
MULT_EQ=240
DIV_EQ=241
MOD_EQ=242
NE=243
PIPE=244
LPAREN=245
RPAREN=246
COMMA=247
SEMICOLON=248
ARROW=249
LBRACKET=250
RBRACKET=251
QUESTION=252
COLON=253
LBRACE=254
RBRACE=255
NUMBER=256
CONSTANT=257
STRING=258
VARIABLE=259
SL_COMMENT=260
ML_COMMENT=261
WS=262
'sin'=1
'cos'=2
'tan'=3
@@ -270,170 +277,177 @@ WS=255
'sqrt'=15
'ln'=16
'log'=17
'exp'=18
'log1p'=19
'expm1'=20
'isnan'=21
'isinf'=22
'isfinite'=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'=43
'step'=44
'smoothstep'=45
'fract'=46
'relu'=47
'softplus'=48
'gelu'=49
'sign'=50
'map'=51
'swap'=54
'range'=58
'linspace'=59
'logspace'=60
'topk'=61
'botk'=62
'pinv'=63
'sum'=64
'mean'=65
'std'=66
'var'=67
'prod'=68
'isclose'=69
'allclose'=70
'quantile'=73
'dot'=74
'moment'=75
'erf'=76
'erfinv'=77
'any'=78
'all'=79
'edge'=80
'median'=82
'mode'=83
'cumsum'=84
'cumprod'=85
'smootherstep'=91
'remap'=93
'keys'=96
'repeat'=104
'flatten'=105
'append'=106
'get_value'=107
'flow_apply'=108
'motion_mask'=110
'flow_to_image'=111
'where'=114
'overlay'=116
'pad'=117
'cross'=118
'matmul'=119
'rife'=120
'shape'=123
'tensor'=127
'add_key'=128
'stack_push'=130
'stack_pop'=131
'stack_clear'=132
'stack_has'=133
'stack_get'=134
'stack'=136
'nonzero'=137
'int'=138
'float'=139
'upper'=140
'lower'=141
'trim'=142
'split'=143
'join'=144
'find'=146
'replace'=147
'dilate'=148
'erode'=149
'morph_open'=150
'morph_close'=151
'rgb_to_oklab'=152
'rgb_to_cielab'=153
'oklab_to_rgb'=154
'cielab_to_rgb'=155
'rgb_to_hsv'=156
'hsv_to_rgb'=157
'int_to_rgb'=158
'rgb_to_int'=159
'interpolate_linear'=160
'interpolate_area'=161
'text_image'=163
'if'=167
'else'=168
'while'=169
'for'=170
'in'=171
'break'=172
'continue'=173
'return'=174
'sort'=176
'argsort'=177
'argmin'=178
'argmax'=179
'softmax'=180
'softmin'=181
'unique'=182
'flip'=183
'startswith'=184
'endswith'=185
'squeeze'=186
'unsqueeze'=187
'roll'=188
'cov'=189
'entropy'=191
'crop'=192
'gather'=195
'scatter'=196
'scatter_add'=197
'+'=217
'-'=218
'*'=219
'/'=220
'%'=221
'^'=222
'<<'=223
'>>'=224
'>='=225
'>'=226
'<='=227
'<'=228
'=='=229
'='=230
'+='=231
'-='=232
'*='=233
'/='=234
'%='=235
'!='=236
'|'=237
'('=238
')'=239
','=240
';'=241
'->'=242
'['=243
']'=244
'?'=245
':'=246
'{'=247
'}'=248
'log2'=18
'exp'=19
'log1p'=20
'expm1'=21
'isnan'=22
'isinf'=23
'isfinite'=24
'smin'=25
'smax'=26
'tmin'=27
'tmax'=28
'tnorm'=29
'snorm'=30
'floor'=31
'ceil'=32
'round'=33
'gamma'=34
'pow'=35
'sigm'=36
'clamp'=37
'fft'=38
'ifft'=39
'angle'=40
'print'=41
'lerp'=44
'step'=45
'smoothstep'=46
'fract'=47
'relu'=48
'softplus'=49
'gelu'=50
'sign'=51
'degrees'=52
'radians'=53
'logical_not'=54
'logical_and'=55
'logical_or'=56
'hypot'=57
'map'=58
'swap'=61
'range'=65
'linspace'=66
'logspace'=67
'topk'=68
'botk'=69
'pinv'=70
'sum'=71
'mean'=72
'std'=73
'var'=74
'prod'=75
'isclose'=76
'allclose'=77
'quantile'=80
'dot'=81
'moment'=82
'erf'=83
'erfinv'=84
'any'=85
'all'=86
'edge'=87
'median'=89
'mode'=90
'cumsum'=91
'cumprod'=92
'smootherstep'=98
'remap'=100
'keys'=103
'repeat'=111
'flatten'=112
'append'=113
'get_value'=114
'flow_apply'=115
'motion_mask'=117
'flow_to_image'=118
'where'=121
'overlay'=123
'pad'=124
'cross'=125
'matmul'=126
'rife'=127
'shape'=130
'tensor'=134
'add_key'=135
'stack_push'=137
'stack_pop'=138
'stack_clear'=139
'stack_has'=140
'stack_get'=141
'stack'=143
'nonzero'=144
'int'=145
'float'=146
'upper'=147
'lower'=148
'trim'=149
'split'=150
'join'=151
'find'=153
'replace'=154
'dilate'=155
'erode'=156
'morph_open'=157
'morph_close'=158
'rgb_to_oklab'=159
'rgb_to_cielab'=160
'oklab_to_rgb'=161
'cielab_to_rgb'=162
'rgb_to_hsv'=163
'hsv_to_rgb'=164
'int_to_rgb'=165
'rgb_to_int'=166
'interpolate_linear'=167
'interpolate_area'=168
'text_image'=170
'if'=174
'else'=175
'while'=176
'for'=177
'in'=178
'break'=179
'continue'=180
'return'=181
'sort'=183
'argsort'=184
'argmin'=185
'argmax'=186
'softmax'=187
'softmin'=188
'unique'=189
'flip'=190
'startswith'=191
'endswith'=192
'squeeze'=193
'unsqueeze'=194
'roll'=195
'cov'=196
'entropy'=198
'crop'=199
'gather'=202
'scatter'=203
'scatter_add'=204
'+'=224
'-'=225
'*'=226
'/'=227
'%'=228
'^'=229
'<<'=230
'>>'=231
'>='=232
'>'=233
'<='=234
'<'=235
'=='=236
'='=237
'+='=238
'-='=239
'*='=240
'/='=241
'%='=242
'!='=243
'|'=244
'('=245
')'=246
','=247
';'=248
'->'=249
'['=250
']'=251
'?'=252
':'=253
'{'=254
'}'=255
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
+419 -405
View File
@@ -15,244 +15,251 @@ ABS=14
SQRT=15
LN=16
LOG=17
EXP=18
LOG1P=19
EXPM1=20
ISNAN=21
ISINF=22
ISFINITE=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
NVL=42
LERP=43
STEP=44
SMOOTHSTEP=45
FRACT=46
RELU=47
SOFTPLUS=48
GELU=49
SIGN=50
MAP=51
EZCONV=52
CONV=53
SWAP=54
TRANSPOSE=55
PERM=56
RESHAPE=57
RANGE=58
LINSPACE=59
LOGSPACE=60
TOPK=61
BOTK=62
PINV=63
SUM=64
MEAN=65
STD=66
VAR=67
PROD=68
ISCLOSE=69
ALLCLOSE=70
QUARTILE=71
PERCENTILE=72
QUANTILE=73
DOT=74
MOMENT=75
ERF=76
ERFINV=77
ANY=78
ALL=79
EDGE=80
GAUSSIAN=81
MEDIAN=82
MODE=83
CUMSUM=84
CUMPROD=85
TOPK_IND=86
BOTK_IND=87
CUBIC_EASE=88
ELASTIC_EASE=89
SINE_EASE=90
SMOOTHERSTEP=91
DIST=92
REMAP=93
COSSIM=94
COUNT=95
KEYS=96
ENABLE_TRACKING=97
DISABLE_TRACKING=98
RESET_TRACKING=99
GET_CHANGED_KEYS=100
GET_ADDED_KEYS=101
GET_REMOVED_KEYS=102
GET_UNCHANGED_KEYS=103
REPEAT=104
FLATTEN=105
APPEND=106
GET_VALUE=107
FLOW_APPLY=108
BATCH_SHUFFLE=109
MOTION_MASK=110
FLOW_TO_IMAGE=111
FLOW_MAG=112
FLOW_ANG=113
WHERE=114
HISTOGRAM=115
OVERLAY=116
PAD=117
CROSS=118
MATMUL=119
RIFE=120
BNOT=121
BITCOUNT=122
SHAPE=123
BAND=124
XOR=125
BOR=126
TENSOR=127
ADD_KEY=128
REMOVE_KEY=129
PUSH=130
POP=131
CLEAR=132
HAS=133
GET=134
CONCAT=135
STACK=136
NONZERO=137
INT=138
FLOAT=139
UPPER=140
LOWER=141
TRIM=142
SPLIT=143
JOIN=144
SUBSTRING=145
FIND=146
REPLACE=147
DILATE=148
ERODE=149
MORPH_OPEN=150
MORPH_CLOSE=151
RGB_TO_OKLAB=152
RGB_TO_CIELAB=153
OKLAB_TO_RGB=154
CIELAB_TO_RGB=155
RGB_TO_HSV=156
HSV_TO_RGB=157
INT_TO_RGB=158
RGB_TO_INT=159
INTERPOLATE_LINEAR=160
INTERPOLATE_AREA=161
INTERPOLATE_NEAREST=162
TEXT_IMAGE=163
AS_NESTED=164
SVD=165
DIAG=166
IF=167
ELSE=168
WHILE=169
FOR=170
IN=171
BREAK=172
CONTINUE=173
RETURN=174
TIMESTAMP=175
SORT=176
ARGSORT=177
ARGMIN=178
ARGMAX=179
SOFTMAX=180
SOFTMIN=181
UNIQUE=182
FLIP=183
STARTSWITH=184
ENDSWITH=185
SQUEEZE=186
UNSQUEEZE=187
ROLL=188
COV=189
CORR=190
ENTROPY=191
CROP=192
NONE=193
COORDS=194
GATHER=195
SCATTER=196
SCATTER_ADD=197
NOISE=198
RAND=199
CAUCHY=200
EXPONENTIAL=201
LOGNORMAL=202
BERNOULLI=203
POISSON=204
GAMMADIST=205
BETADIST=206
LAPLACEDIST=207
GUMBELDIST=208
WEIBULLDIST=209
CHI2DIST=210
STUDENTTDIST=211
PERLIN=212
CELLULAR=213
PLASMA=214
RIDGED=215
DOMAIN_WARP=216
PLUS=217
MINUS=218
MULT=219
DIV=220
MOD=221
POW=222
LSHIFT=223
RSHIFT=224
GE=225
GT=226
LE=227
LT=228
EQ=229
EQUEALS=230
PLUS_EQ=231
MINUS_EQ=232
MULT_EQ=233
DIV_EQ=234
MOD_EQ=235
NE=236
PIPE=237
LPAREN=238
RPAREN=239
COMMA=240
SEMICOLON=241
ARROW=242
LBRACKET=243
RBRACKET=244
QUESTION=245
COLON=246
LBRACE=247
RBRACE=248
NUMBER=249
CONSTANT=250
STRING=251
VARIABLE=252
SL_COMMENT=253
ML_COMMENT=254
WS=255
LOG2=18
EXP=19
LOG1P=20
EXPM1=21
ISNAN=22
ISINF=23
ISFINITE=24
SMIN=25
SMAX=26
TMIN=27
TMAX=28
TNORM=29
SNORM=30
FLOOR=31
CEIL=32
ROUND=33
GAMMA=34
POWE=35
SIGM=36
CLAMP=37
SFFT=38
SIFFT=39
ANGL=40
PRNT=41
PRINT_SHAPE=42
NVL=43
LERP=44
STEP=45
SMOOTHSTEP=46
FRACT=47
RELU=48
SOFTPLUS=49
GELU=50
SIGN=51
DEGREES=52
RADIANS=53
LOGICAL_NOT=54
LOGICAL_AND=55
LOGICAL_OR=56
HYPOT=57
MAP=58
EZCONV=59
CONV=60
SWAP=61
TRANSPOSE=62
PERM=63
RESHAPE=64
RANGE=65
LINSPACE=66
LOGSPACE=67
TOPK=68
BOTK=69
PINV=70
SUM=71
MEAN=72
STD=73
VAR=74
PROD=75
ISCLOSE=76
ALLCLOSE=77
QUARTILE=78
PERCENTILE=79
QUANTILE=80
DOT=81
MOMENT=82
ERF=83
ERFINV=84
ANY=85
ALL=86
EDGE=87
GAUSSIAN=88
MEDIAN=89
MODE=90
CUMSUM=91
CUMPROD=92
TOPK_IND=93
BOTK_IND=94
CUBIC_EASE=95
ELASTIC_EASE=96
SINE_EASE=97
SMOOTHERSTEP=98
DIST=99
REMAP=100
COSSIM=101
COUNT=102
KEYS=103
ENABLE_TRACKING=104
DISABLE_TRACKING=105
RESET_TRACKING=106
GET_CHANGED_KEYS=107
GET_ADDED_KEYS=108
GET_REMOVED_KEYS=109
GET_UNCHANGED_KEYS=110
REPEAT=111
FLATTEN=112
APPEND=113
GET_VALUE=114
FLOW_APPLY=115
BATCH_SHUFFLE=116
MOTION_MASK=117
FLOW_TO_IMAGE=118
FLOW_MAG=119
FLOW_ANG=120
WHERE=121
HISTOGRAM=122
OVERLAY=123
PAD=124
CROSS=125
MATMUL=126
RIFE=127
BNOT=128
BITCOUNT=129
SHAPE=130
BAND=131
XOR=132
BOR=133
TENSOR=134
ADD_KEY=135
REMOVE_KEY=136
PUSH=137
POP=138
CLEAR=139
HAS=140
GET=141
CONCAT=142
STACK=143
NONZERO=144
INT=145
FLOAT=146
UPPER=147
LOWER=148
TRIM=149
SPLIT=150
JOIN=151
SUBSTRING=152
FIND=153
REPLACE=154
DILATE=155
ERODE=156
MORPH_OPEN=157
MORPH_CLOSE=158
RGB_TO_OKLAB=159
RGB_TO_CIELAB=160
OKLAB_TO_RGB=161
CIELAB_TO_RGB=162
RGB_TO_HSV=163
HSV_TO_RGB=164
INT_TO_RGB=165
RGB_TO_INT=166
INTERPOLATE_LINEAR=167
INTERPOLATE_AREA=168
INTERPOLATE_NEAREST=169
TEXT_IMAGE=170
AS_NESTED=171
SVD=172
DIAG=173
IF=174
ELSE=175
WHILE=176
FOR=177
IN=178
BREAK=179
CONTINUE=180
RETURN=181
TIMESTAMP=182
SORT=183
ARGSORT=184
ARGMIN=185
ARGMAX=186
SOFTMAX=187
SOFTMIN=188
UNIQUE=189
FLIP=190
STARTSWITH=191
ENDSWITH=192
SQUEEZE=193
UNSQUEEZE=194
ROLL=195
COV=196
CORR=197
ENTROPY=198
CROP=199
NONE=200
COORDS=201
GATHER=202
SCATTER=203
SCATTER_ADD=204
NOISE=205
RAND=206
CAUCHY=207
EXPONENTIAL=208
LOGNORMAL=209
BERNOULLI=210
POISSON=211
GAMMADIST=212
BETADIST=213
LAPLACEDIST=214
GUMBELDIST=215
WEIBULLDIST=216
CHI2DIST=217
STUDENTTDIST=218
PERLIN=219
CELLULAR=220
PLASMA=221
RIDGED=222
DOMAIN_WARP=223
PLUS=224
MINUS=225
MULT=226
DIV=227
MOD=228
POW=229
LSHIFT=230
RSHIFT=231
GE=232
GT=233
LE=234
LT=235
EQ=236
EQUEALS=237
PLUS_EQ=238
MINUS_EQ=239
MULT_EQ=240
DIV_EQ=241
MOD_EQ=242
NE=243
PIPE=244
LPAREN=245
RPAREN=246
COMMA=247
SEMICOLON=248
ARROW=249
LBRACKET=250
RBRACKET=251
QUESTION=252
COLON=253
LBRACE=254
RBRACE=255
NUMBER=256
CONSTANT=257
STRING=258
VARIABLE=259
SL_COMMENT=260
ML_COMMENT=261
WS=262
'sin'=1
'cos'=2
'tan'=3
@@ -270,170 +277,177 @@ WS=255
'sqrt'=15
'ln'=16
'log'=17
'exp'=18
'log1p'=19
'expm1'=20
'isnan'=21
'isinf'=22
'isfinite'=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'=43
'step'=44
'smoothstep'=45
'fract'=46
'relu'=47
'softplus'=48
'gelu'=49
'sign'=50
'map'=51
'swap'=54
'range'=58
'linspace'=59
'logspace'=60
'topk'=61
'botk'=62
'pinv'=63
'sum'=64
'mean'=65
'std'=66
'var'=67
'prod'=68
'isclose'=69
'allclose'=70
'quantile'=73
'dot'=74
'moment'=75
'erf'=76
'erfinv'=77
'any'=78
'all'=79
'edge'=80
'median'=82
'mode'=83
'cumsum'=84
'cumprod'=85
'smootherstep'=91
'remap'=93
'keys'=96
'repeat'=104
'flatten'=105
'append'=106
'get_value'=107
'flow_apply'=108
'motion_mask'=110
'flow_to_image'=111
'where'=114
'overlay'=116
'pad'=117
'cross'=118
'matmul'=119
'rife'=120
'shape'=123
'tensor'=127
'add_key'=128
'stack_push'=130
'stack_pop'=131
'stack_clear'=132
'stack_has'=133
'stack_get'=134
'stack'=136
'nonzero'=137
'int'=138
'float'=139
'upper'=140
'lower'=141
'trim'=142
'split'=143
'join'=144
'find'=146
'replace'=147
'dilate'=148
'erode'=149
'morph_open'=150
'morph_close'=151
'rgb_to_oklab'=152
'rgb_to_cielab'=153
'oklab_to_rgb'=154
'cielab_to_rgb'=155
'rgb_to_hsv'=156
'hsv_to_rgb'=157
'int_to_rgb'=158
'rgb_to_int'=159
'interpolate_linear'=160
'interpolate_area'=161
'text_image'=163
'if'=167
'else'=168
'while'=169
'for'=170
'in'=171
'break'=172
'continue'=173
'return'=174
'sort'=176
'argsort'=177
'argmin'=178
'argmax'=179
'softmax'=180
'softmin'=181
'unique'=182
'flip'=183
'startswith'=184
'endswith'=185
'squeeze'=186
'unsqueeze'=187
'roll'=188
'cov'=189
'entropy'=191
'crop'=192
'gather'=195
'scatter'=196
'scatter_add'=197
'+'=217
'-'=218
'*'=219
'/'=220
'%'=221
'^'=222
'<<'=223
'>>'=224
'>='=225
'>'=226
'<='=227
'<'=228
'=='=229
'='=230
'+='=231
'-='=232
'*='=233
'/='=234
'%='=235
'!='=236
'|'=237
'('=238
')'=239
','=240
';'=241
'->'=242
'['=243
']'=244
'?'=245
':'=246
'{'=247
'}'=248
'log2'=18
'exp'=19
'log1p'=20
'expm1'=21
'isnan'=22
'isinf'=23
'isfinite'=24
'smin'=25
'smax'=26
'tmin'=27
'tmax'=28
'tnorm'=29
'snorm'=30
'floor'=31
'ceil'=32
'round'=33
'gamma'=34
'pow'=35
'sigm'=36
'clamp'=37
'fft'=38
'ifft'=39
'angle'=40
'print'=41
'lerp'=44
'step'=45
'smoothstep'=46
'fract'=47
'relu'=48
'softplus'=49
'gelu'=50
'sign'=51
'degrees'=52
'radians'=53
'logical_not'=54
'logical_and'=55
'logical_or'=56
'hypot'=57
'map'=58
'swap'=61
'range'=65
'linspace'=66
'logspace'=67
'topk'=68
'botk'=69
'pinv'=70
'sum'=71
'mean'=72
'std'=73
'var'=74
'prod'=75
'isclose'=76
'allclose'=77
'quantile'=80
'dot'=81
'moment'=82
'erf'=83
'erfinv'=84
'any'=85
'all'=86
'edge'=87
'median'=89
'mode'=90
'cumsum'=91
'cumprod'=92
'smootherstep'=98
'remap'=100
'keys'=103
'repeat'=111
'flatten'=112
'append'=113
'get_value'=114
'flow_apply'=115
'motion_mask'=117
'flow_to_image'=118
'where'=121
'overlay'=123
'pad'=124
'cross'=125
'matmul'=126
'rife'=127
'shape'=130
'tensor'=134
'add_key'=135
'stack_push'=137
'stack_pop'=138
'stack_clear'=139
'stack_has'=140
'stack_get'=141
'stack'=143
'nonzero'=144
'int'=145
'float'=146
'upper'=147
'lower'=148
'trim'=149
'split'=150
'join'=151
'find'=153
'replace'=154
'dilate'=155
'erode'=156
'morph_open'=157
'morph_close'=158
'rgb_to_oklab'=159
'rgb_to_cielab'=160
'oklab_to_rgb'=161
'cielab_to_rgb'=162
'rgb_to_hsv'=163
'hsv_to_rgb'=164
'int_to_rgb'=165
'rgb_to_int'=166
'interpolate_linear'=167
'interpolate_area'=168
'text_image'=170
'if'=174
'else'=175
'while'=176
'for'=177
'in'=178
'break'=179
'continue'=180
'return'=181
'sort'=183
'argsort'=184
'argmin'=185
'argmax'=186
'softmax'=187
'softmin'=188
'unique'=189
'flip'=190
'startswith'=191
'endswith'=192
'squeeze'=193
'unsqueeze'=194
'roll'=195
'cov'=196
'entropy'=198
'crop'=199
'gather'=202
'scatter'=203
'scatter_add'=204
'+'=224
'-'=225
'*'=226
'/'=227
'%'=228
'^'=229
'<<'=230
'>>'=231
'>='=232
'>'=233
'<='=234
'<'=235
'=='=236
'='=237
'+='=238
'-='=239
'*='=240
'/='=241
'%='=242
'!='=243
'|'=244
'('=245
')'=246
','=247
';'=248
'->'=249
'['=250
']'=251
'?'=252
':'=253
'{'=254
'}'=255
@@ -881,6 +881,15 @@ class MathExprListener(ParseTreeListener):
pass
# Enter a parse tree produced by MathExprParser#Log2Func.
def enterLog2Func(self, ctx:MathExprParser.Log2FuncContext):
pass
# Exit a parse tree produced by MathExprParser#Log2Func.
def exitLog2Func(self, ctx:MathExprParser.Log2FuncContext):
pass
# Enter a parse tree produced by MathExprParser#ExpFunc.
def enterExpFunc(self, ctx:MathExprParser.ExpFuncContext):
pass
@@ -1052,6 +1061,33 @@ class MathExprListener(ParseTreeListener):
pass
# Enter a parse tree produced by MathExprParser#DegreesFunc.
def enterDegreesFunc(self, ctx:MathExprParser.DegreesFuncContext):
pass
# Exit a parse tree produced by MathExprParser#DegreesFunc.
def exitDegreesFunc(self, ctx:MathExprParser.DegreesFuncContext):
pass
# Enter a parse tree produced by MathExprParser#RadiansFunc.
def enterRadiansFunc(self, ctx:MathExprParser.RadiansFuncContext):
pass
# Exit a parse tree produced by MathExprParser#RadiansFunc.
def exitRadiansFunc(self, ctx:MathExprParser.RadiansFuncContext):
pass
# Enter a parse tree produced by MathExprParser#LogicalNotFunc.
def enterLogicalNotFunc(self, ctx:MathExprParser.LogicalNotFuncContext):
pass
# Exit a parse tree produced by MathExprParser#LogicalNotFunc.
def exitLogicalNotFunc(self, ctx:MathExprParser.LogicalNotFuncContext):
pass
# Enter a parse tree produced by MathExprParser#PrintShapeFunc.
def enterPrintShapeFunc(self, ctx:MathExprParser.PrintShapeFuncContext):
pass
@@ -1556,6 +1592,33 @@ class MathExprListener(ParseTreeListener):
pass
# Enter a parse tree produced by MathExprParser#HypotFunc.
def enterHypotFunc(self, ctx:MathExprParser.HypotFuncContext):
pass
# Exit a parse tree produced by MathExprParser#HypotFunc.
def exitHypotFunc(self, ctx:MathExprParser.HypotFuncContext):
pass
# Enter a parse tree produced by MathExprParser#LogicalAndFunc.
def enterLogicalAndFunc(self, ctx:MathExprParser.LogicalAndFuncContext):
pass
# Exit a parse tree produced by MathExprParser#LogicalAndFunc.
def exitLogicalAndFunc(self, ctx:MathExprParser.LogicalAndFuncContext):
pass
# Enter a parse tree produced by MathExprParser#LogicalOrFunc.
def enterLogicalOrFunc(self, ctx:MathExprParser.LogicalOrFuncContext):
pass
# Exit a parse tree produced by MathExprParser#LogicalOrFunc.
def exitLogicalOrFunc(self, ctx:MathExprParser.LogicalOrFuncContext):
pass
# Enter a parse tree produced by MathExprParser#IscloseFunc.
def enterIscloseFunc(self, ctx:MathExprParser.IscloseFuncContext):
pass
File diff suppressed because it is too large Load Diff
@@ -494,6 +494,11 @@ class MathExprVisitor(ParseTreeVisitor):
return self.visitChildren(ctx)
# Visit a parse tree produced by MathExprParser#Log2Func.
def visitLog2Func(self, ctx:MathExprParser.Log2FuncContext):
return self.visitChildren(ctx)
# Visit a parse tree produced by MathExprParser#ExpFunc.
def visitExpFunc(self, ctx:MathExprParser.ExpFuncContext):
return self.visitChildren(ctx)
@@ -589,6 +594,21 @@ class MathExprVisitor(ParseTreeVisitor):
return self.visitChildren(ctx)
# Visit a parse tree produced by MathExprParser#DegreesFunc.
def visitDegreesFunc(self, ctx:MathExprParser.DegreesFuncContext):
return self.visitChildren(ctx)
# Visit a parse tree produced by MathExprParser#RadiansFunc.
def visitRadiansFunc(self, ctx:MathExprParser.RadiansFuncContext):
return self.visitChildren(ctx)
# Visit a parse tree produced by MathExprParser#LogicalNotFunc.
def visitLogicalNotFunc(self, ctx:MathExprParser.LogicalNotFuncContext):
return self.visitChildren(ctx)
# Visit a parse tree produced by MathExprParser#PrintShapeFunc.
def visitPrintShapeFunc(self, ctx:MathExprParser.PrintShapeFuncContext):
return self.visitChildren(ctx)
@@ -869,6 +889,21 @@ class MathExprVisitor(ParseTreeVisitor):
return self.visitChildren(ctx)
# Visit a parse tree produced by MathExprParser#HypotFunc.
def visitHypotFunc(self, ctx:MathExprParser.HypotFuncContext):
return self.visitChildren(ctx)
# Visit a parse tree produced by MathExprParser#LogicalAndFunc.
def visitLogicalAndFunc(self, ctx:MathExprParser.LogicalAndFuncContext):
return self.visitChildren(ctx)
# Visit a parse tree produced by MathExprParser#LogicalOrFunc.
def visitLogicalOrFunc(self, ctx:MathExprParser.LogicalOrFuncContext):
return self.visitChildren(ctx)
# Visit a parse tree produced by MathExprParser#IscloseFunc.
def visitIscloseFunc(self, ctx:MathExprParser.IscloseFuncContext):
return self.visitChildren(ctx)
+8 -1
View File
@@ -6,7 +6,7 @@ INBUILT_CONSTANTS = {
'e', 'pi'
}
INBUILT_FUNCTIONS = {
'abs', 'acos', 'acosh', 'add_key', 'added_keys', 'all', 'allclose', 'angle', 'any', 'append', 'argmax', 'argmin', 'argsort', 'as_nested', 'as_nested_tensor', 'asin', 'asinh', 'atan', 'atan2', 'atanh', 'band', 'batch_shuffle', 'bitcount', 'bitwise_and', 'bitwise_not', 'bitwise_or', 'bitwise_xor', 'blur', 'bnot', 'bor', 'botk', 'botk_ind', 'botk_indices', 'bxor', 'cat', 'ceil', 'cellular', 'cellular_noise', 'cielab_to_rgb', 'clamp', 'cnt', 'concat', 'concatenate', 'conv', 'convolution', 'coordinates', 'coords', 'corr', 'correlation', 'cos', 'cosh', 'cosine_similarity', 'cossim', 'count', 'cov', 'crop', 'cross', 'cubic', 'cubic_ease', 'cumprod', 'cumsum', 'diag', 'diagonal_matrix', 'dilate', 'disable_tracking', 'dist', 'distance', 'domain_warp', 'domain_warp_noise', 'dot', 'edge', 'elastic', 'elastic_ease', 'enable_tracking', 'endswith', 'entropy', 'erf', 'erfinv', 'erode', 'exp', 'expm1', 'ezconv', 'ezconvolution', 'fft', 'find', 'flatten', 'flip', 'float', 'floor', 'flow_ang', 'flow_angle', 'flow_apply', 'flow_mag', 'flow_magnitude', 'flow_to_image', 'fract', 'gamma', 'gather', 'gaussian', 'gelu', 'get_added_keys', 'get_changed_keys', 'get_removed_keys', 'get_unchanged_keys', 'get_value', 'hist', 'histogram', 'hsv_to_rgb', 'changed_keys', 'ifft', 'int', 'int_to_rgb', 'interpolate_area', 'interpolate_linear', 'interpolate_nearest', 'interpolate_nearest_exact', 'isclose', 'isfinite', 'isinf', 'isnan', 'join', 'keys', 'length', 'lerp', 'linspace', 'ln', 'log', 'log1p', 'logspace', 'lower', 'map', 'matmul', 'mean', 'median', 'mode', 'moment', 'morph_close', 'morph_open', 'motion_mask', 'nan_to_num', 'noise', 'nonzero', 'now', 'nvl', 'oklab_to_rgb', 'overlay', 'pad', 'percentile', 'perlin', 'perlin_noise', 'perm', 'permute', 'pinv', 'plasma', 'plasma_noise', 'popcnt', 'popcount', 'pow', 'prcnt', 'print', 'print_shape', 'prod', 'pshp', 'quantile', 'quartil', 'quartile', 'rand', 'randb', 'randbeta', 'randc', 'rande', 'randg', 'randgumbel', 'randchi2', 'randl', 'randln', 'randn', 'random_bernoulli', 'random_beta', 'random_cauchy', 'random_exponential', 'random_gamma', 'random_gumbel', 'random_chi2', 'random_laplace', 'random_log_normal', 'random_normal', 'random_poisson', 'random_studentt', 'random_uniform', 'random_weibull', 'randp', 'randt', 'randu', 'randw', 'range', 'relu', 'remap', 'remove_key', 'removed_keys', 'repeat', 'replace', 'reset_tracking', 'reshape', 'rgb_to_cielab', 'rgb_to_hsv', 'rgb_to_int', 'rgb_to_oklab', 'ridged', 'ridged_noise', 'rife', 'rm_key', 'roll', 'round', 'rshp', 'scatter', 'scatter_add', 'select', 'shape', 'shuffle', 'sigm', 'sign', 'sin', 'sine', 'sine_ease', 'singular_value_decomposition', 'sinh', 'smax', 'smin', 'smootherstep', 'smoothstep', 'snorm', 'softmax', 'softmin', 'softplus', 'sort', 'split', 'sqrt', 'squeeze', 'stack', 'stack_clear', 'stack_get', 'stack_has', 'stack_pop', 'stack_push', 'startswith', 'std', 'step', 'substr', 'substring', 'sum', 'svd', 'swap', 'swapaxes', 'tan', 'tanh', 'tensor', 'text_image', 'timestamp', 'tmax', 'tmin', 'tnorm', 'topk', 'topk_ind', 'topk_indices', 'track_off', 'track_on', 'track_reset', 'transpose', 'trim', 'turbulence', 'unchanged_keys', 'unique', 'unsqueeze', 'upper', 'var', 'voronoi', 'voronoi_noise', 'where', 'worley'
'abs', 'acos', 'acosh', 'add_key', 'added_keys', 'all', 'allclose', 'angle', 'any', 'append', 'argmax', 'argmin', 'argsort', 'as_nested', 'as_nested_tensor', 'asin', 'asinh', 'atan', 'atan2', 'atanh', 'band', 'batch_shuffle', 'bitcount', 'bitwise_and', 'bitwise_not', 'bitwise_or', 'bitwise_xor', 'blur', 'bnot', 'bor', 'botk', 'botk_ind', 'botk_indices', 'bxor', 'cat', 'ceil', 'cellular', 'cellular_noise', 'cielab_to_rgb', 'clamp', 'cnt', 'concat', 'concatenate', 'conv', 'convolution', 'coordinates', 'coords', 'corr', 'correlation', 'cos', 'cosh', 'cosine_similarity', 'cossim', 'count', 'cov', 'crop', 'cross', 'cubic', 'cubic_ease', 'cumprod', 'cumsum', 'degrees', 'diag', 'diagonal_matrix', 'dilate', 'disable_tracking', 'dist', 'distance', 'domain_warp', 'domain_warp_noise', 'dot', 'edge', 'elastic', 'elastic_ease', 'enable_tracking', 'endswith', 'entropy', 'erf', 'erfinv', 'erode', 'exp', 'expm1', 'ezconv', 'ezconvolution', 'fft', 'find', 'flatten', 'flip', 'float', 'floor', 'flow_ang', 'flow_angle', 'flow_apply', 'flow_mag', 'flow_magnitude', 'flow_to_image', 'fract', 'gamma', 'gather', 'gaussian', 'gelu', 'get_added_keys', 'get_changed_keys', 'get_removed_keys', 'get_unchanged_keys', 'get_value', 'hist', 'histogram', 'hsv_to_rgb', 'hypot', 'changed_keys', 'ifft', 'int', 'int_to_rgb', 'interpolate_area', 'interpolate_linear', 'interpolate_nearest', 'interpolate_nearest_exact', 'isclose', 'isfinite', 'isinf', 'isnan', 'join', 'keys', 'length', 'lerp', 'linspace', 'ln', 'log', 'log1p', 'log2', 'logical_and', 'logical_not', 'logical_or', 'logspace', 'lower', 'map', 'matmul', 'mean', 'median', 'mode', 'moment', 'morph_close', 'morph_open', 'motion_mask', 'nan_to_num', 'noise', 'nonzero', 'now', 'nvl', 'oklab_to_rgb', 'overlay', 'pad', 'percentile', 'perlin', 'perlin_noise', 'perm', 'permute', 'pinv', 'plasma', 'plasma_noise', 'popcnt', 'popcount', 'pow', 'prcnt', 'print', 'print_shape', 'prod', 'pshp', 'quantile', 'quartil', 'quartile', 'radians', 'rand', 'randb', 'randbeta', 'randc', 'rande', 'randg', 'randgumbel', 'randchi2', 'randl', 'randln', 'randn', 'random_bernoulli', 'random_beta', 'random_cauchy', 'random_exponential', 'random_gamma', 'random_gumbel', 'random_chi2', 'random_laplace', 'random_log_normal', 'random_normal', 'random_poisson', 'random_studentt', 'random_uniform', 'random_weibull', 'randp', 'randt', 'randu', 'randw', 'range', 'relu', 'remap', 'remove_key', 'removed_keys', 'repeat', 'replace', 'reset_tracking', 'reshape', 'rgb_to_cielab', 'rgb_to_hsv', 'rgb_to_int', 'rgb_to_oklab', 'ridged', 'ridged_noise', 'rife', 'rm_key', 'roll', 'round', 'rshp', 'scatter', 'scatter_add', 'select', 'shape', 'shuffle', 'sigm', 'sign', 'sin', 'sine', 'sine_ease', 'singular_value_decomposition', 'sinh', 'smax', 'smin', 'smootherstep', 'smoothstep', 'snorm', 'softmax', 'softmin', 'softplus', 'sort', 'split', 'sqrt', 'squeeze', 'stack', 'stack_clear', 'stack_get', 'stack_has', 'stack_pop', 'stack_push', 'startswith', 'std', 'step', 'substr', 'substring', 'sum', 'svd', 'swap', 'swapaxes', 'tan', 'tanh', 'tensor', 'text_image', 'timestamp', 'tmax', 'tmin', 'tnorm', 'topk', 'topk_ind', 'topk_indices', 'track_off', 'track_on', 'track_reset', 'transpose', 'trim', 'turbulence', 'unchanged_keys', 'unique', 'unsqueeze', 'upper', 'var', 'voronoi', 'voronoi_noise', 'where', 'worley'
}
INBUILT_FUNCTION_META = {
@@ -27,6 +27,7 @@ INBUILT_FUNCTION_META = {
'sqrt': {'min_args': 1, 'max_args': 1, 'snippet': 'sqrt(x)', 'description': 'applies sqere root per element. Negative numbers return NaN (not a number)'},
'ln': {'min_args': 1, 'max_args': 1, 'snippet': 'ln(x)', 'description': 'applies natural logarithm to value (per element). Negative numbers return NaN (not a number)'},
'log': {'min_args': 1, 'max_args': 1, 'snippet': 'log(x)', 'description': 'applies base 10 logarithm to value (per element). Negative numbers return NaN (not a number)'},
'log2': {'min_args': 1, 'max_args': 1, 'snippet': 'log2(x)', 'description': 'applies base 2 logarithm to value (per element). Negative numbers return NaN (not a number)'},
'exp': {'min_args': 1, 'max_args': 1, 'snippet': 'exp(x)', 'description': 'applies e^x to value (per element)'},
'log1p': {'min_args': 1, 'max_args': 1, 'snippet': 'log1p(x)', 'description': 'applies ln(1+x) accurately for values near zero'},
'expm1': {'min_args': 1, 'max_args': 1, 'snippet': 'expm1(x)', 'description': 'applies exp(x)-1 accurately for values near zero'},
@@ -62,6 +63,12 @@ INBUILT_FUNCTION_META = {
'softplus': {'min_args': 1, 'max_args': 1, 'snippet': 'softplus(x)', 'description': 'applies the softplus function: ln(1 + exp(x))'},
'gelu': {'min_args': 1, 'max_args': 1, 'snippet': 'gelu(x)', 'description': 'applies the Gaussian Error Linear Unit (GELU) activation function'},
'sign': {'min_args': 1, 'max_args': 1, 'snippet': 'sign(x)', 'description': 'returns the sign of x: -1, 0, or 1'},
'degrees': {'min_args': 1, 'max_args': 1, 'snippet': 'degrees(x)', 'description': 'converts radians to degrees (per element)'},
'radians': {'min_args': 1, 'max_args': 1, 'snippet': 'radians(x)', 'description': 'converts degrees to radians (per element)'},
'logical_not': {'min_args': 1, 'max_args': 1, 'snippet': 'logical_not(x)', 'description': 'returns 1.0 where x is zero and 0.0 otherwise'},
'logical_and': {'min_args': 2, 'max_args': 2, 'snippet': 'logical_and(x, y)', 'description': 'returns 1.0 if both values are non-zero, else 0.0'},
'logical_or': {'min_args': 2, 'max_args': 2, 'snippet': 'logical_or(x, y)', 'description': 'returns 1.0 if either value is non-zero, else 0.0'},
'hypot': {'min_args': 2, 'max_args': 2, 'snippet': 'hypot(x, y)', 'description': 'computes the element-wise Euclidean distance from the origin'},
'map': {'min_args': 2, 'max_args': 4, 'snippet': 'map(tensor, coord1, coord2, coord3)', 'description': 'samples/remaps input tensor using coordinates'},
'ezconvolution': {'min_args': 2, 'max_args': 3, 'snippet': 'ezconvolution(tensor, kernel_sizes..., kernel)', 'description': 'applies convolution with kernel. Attempts to correctly convolve over size dimensions.'},
'ezconv': {'min_args': 2, 'max_args': 3, 'snippet': 'ezconv(tensor, kernel_sizes..., kernel)', 'description': 'applies convolution with kernel. Attempts to correctly convolve over size dimensions.'},
File diff suppressed because one or more lines are too long
+419 -405
View File
@@ -15,244 +15,251 @@ ABS=14
SQRT=15
LN=16
LOG=17
EXP=18
LOG1P=19
EXPM1=20
ISNAN=21
ISINF=22
ISFINITE=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
NVL=42
LERP=43
STEP=44
SMOOTHSTEP=45
FRACT=46
RELU=47
SOFTPLUS=48
GELU=49
SIGN=50
MAP=51
EZCONV=52
CONV=53
SWAP=54
TRANSPOSE=55
PERM=56
RESHAPE=57
RANGE=58
LINSPACE=59
LOGSPACE=60
TOPK=61
BOTK=62
PINV=63
SUM=64
MEAN=65
STD=66
VAR=67
PROD=68
ISCLOSE=69
ALLCLOSE=70
QUARTILE=71
PERCENTILE=72
QUANTILE=73
DOT=74
MOMENT=75
ERF=76
ERFINV=77
ANY=78
ALL=79
EDGE=80
GAUSSIAN=81
MEDIAN=82
MODE=83
CUMSUM=84
CUMPROD=85
TOPK_IND=86
BOTK_IND=87
CUBIC_EASE=88
ELASTIC_EASE=89
SINE_EASE=90
SMOOTHERSTEP=91
DIST=92
REMAP=93
COSSIM=94
COUNT=95
KEYS=96
ENABLE_TRACKING=97
DISABLE_TRACKING=98
RESET_TRACKING=99
GET_CHANGED_KEYS=100
GET_ADDED_KEYS=101
GET_REMOVED_KEYS=102
GET_UNCHANGED_KEYS=103
REPEAT=104
FLATTEN=105
APPEND=106
GET_VALUE=107
FLOW_APPLY=108
BATCH_SHUFFLE=109
MOTION_MASK=110
FLOW_TO_IMAGE=111
FLOW_MAG=112
FLOW_ANG=113
WHERE=114
HISTOGRAM=115
OVERLAY=116
PAD=117
CROSS=118
MATMUL=119
RIFE=120
BNOT=121
BITCOUNT=122
SHAPE=123
BAND=124
XOR=125
BOR=126
TENSOR=127
ADD_KEY=128
REMOVE_KEY=129
PUSH=130
POP=131
CLEAR=132
HAS=133
GET=134
CONCAT=135
STACK=136
NONZERO=137
INT=138
FLOAT=139
UPPER=140
LOWER=141
TRIM=142
SPLIT=143
JOIN=144
SUBSTRING=145
FIND=146
REPLACE=147
DILATE=148
ERODE=149
MORPH_OPEN=150
MORPH_CLOSE=151
RGB_TO_OKLAB=152
RGB_TO_CIELAB=153
OKLAB_TO_RGB=154
CIELAB_TO_RGB=155
RGB_TO_HSV=156
HSV_TO_RGB=157
INT_TO_RGB=158
RGB_TO_INT=159
INTERPOLATE_LINEAR=160
INTERPOLATE_AREA=161
INTERPOLATE_NEAREST=162
TEXT_IMAGE=163
AS_NESTED=164
SVD=165
DIAG=166
IF=167
ELSE=168
WHILE=169
FOR=170
IN=171
BREAK=172
CONTINUE=173
RETURN=174
TIMESTAMP=175
SORT=176
ARGSORT=177
ARGMIN=178
ARGMAX=179
SOFTMAX=180
SOFTMIN=181
UNIQUE=182
FLIP=183
STARTSWITH=184
ENDSWITH=185
SQUEEZE=186
UNSQUEEZE=187
ROLL=188
COV=189
CORR=190
ENTROPY=191
CROP=192
NONE=193
COORDS=194
GATHER=195
SCATTER=196
SCATTER_ADD=197
NOISE=198
RAND=199
CAUCHY=200
EXPONENTIAL=201
LOGNORMAL=202
BERNOULLI=203
POISSON=204
GAMMADIST=205
BETADIST=206
LAPLACEDIST=207
GUMBELDIST=208
WEIBULLDIST=209
CHI2DIST=210
STUDENTTDIST=211
PERLIN=212
CELLULAR=213
PLASMA=214
RIDGED=215
DOMAIN_WARP=216
PLUS=217
MINUS=218
MULT=219
DIV=220
MOD=221
POW=222
LSHIFT=223
RSHIFT=224
GE=225
GT=226
LE=227
LT=228
EQ=229
EQUEALS=230
PLUS_EQ=231
MINUS_EQ=232
MULT_EQ=233
DIV_EQ=234
MOD_EQ=235
NE=236
PIPE=237
LPAREN=238
RPAREN=239
COMMA=240
SEMICOLON=241
ARROW=242
LBRACKET=243
RBRACKET=244
QUESTION=245
COLON=246
LBRACE=247
RBRACE=248
NUMBER=249
CONSTANT=250
STRING=251
VARIABLE=252
SL_COMMENT=253
ML_COMMENT=254
WS=255
LOG2=18
EXP=19
LOG1P=20
EXPM1=21
ISNAN=22
ISINF=23
ISFINITE=24
SMIN=25
SMAX=26
TMIN=27
TMAX=28
TNORM=29
SNORM=30
FLOOR=31
CEIL=32
ROUND=33
GAMMA=34
POWE=35
SIGM=36
CLAMP=37
SFFT=38
SIFFT=39
ANGL=40
PRNT=41
PRINT_SHAPE=42
NVL=43
LERP=44
STEP=45
SMOOTHSTEP=46
FRACT=47
RELU=48
SOFTPLUS=49
GELU=50
SIGN=51
DEGREES=52
RADIANS=53
LOGICAL_NOT=54
LOGICAL_AND=55
LOGICAL_OR=56
HYPOT=57
MAP=58
EZCONV=59
CONV=60
SWAP=61
TRANSPOSE=62
PERM=63
RESHAPE=64
RANGE=65
LINSPACE=66
LOGSPACE=67
TOPK=68
BOTK=69
PINV=70
SUM=71
MEAN=72
STD=73
VAR=74
PROD=75
ISCLOSE=76
ALLCLOSE=77
QUARTILE=78
PERCENTILE=79
QUANTILE=80
DOT=81
MOMENT=82
ERF=83
ERFINV=84
ANY=85
ALL=86
EDGE=87
GAUSSIAN=88
MEDIAN=89
MODE=90
CUMSUM=91
CUMPROD=92
TOPK_IND=93
BOTK_IND=94
CUBIC_EASE=95
ELASTIC_EASE=96
SINE_EASE=97
SMOOTHERSTEP=98
DIST=99
REMAP=100
COSSIM=101
COUNT=102
KEYS=103
ENABLE_TRACKING=104
DISABLE_TRACKING=105
RESET_TRACKING=106
GET_CHANGED_KEYS=107
GET_ADDED_KEYS=108
GET_REMOVED_KEYS=109
GET_UNCHANGED_KEYS=110
REPEAT=111
FLATTEN=112
APPEND=113
GET_VALUE=114
FLOW_APPLY=115
BATCH_SHUFFLE=116
MOTION_MASK=117
FLOW_TO_IMAGE=118
FLOW_MAG=119
FLOW_ANG=120
WHERE=121
HISTOGRAM=122
OVERLAY=123
PAD=124
CROSS=125
MATMUL=126
RIFE=127
BNOT=128
BITCOUNT=129
SHAPE=130
BAND=131
XOR=132
BOR=133
TENSOR=134
ADD_KEY=135
REMOVE_KEY=136
PUSH=137
POP=138
CLEAR=139
HAS=140
GET=141
CONCAT=142
STACK=143
NONZERO=144
INT=145
FLOAT=146
UPPER=147
LOWER=148
TRIM=149
SPLIT=150
JOIN=151
SUBSTRING=152
FIND=153
REPLACE=154
DILATE=155
ERODE=156
MORPH_OPEN=157
MORPH_CLOSE=158
RGB_TO_OKLAB=159
RGB_TO_CIELAB=160
OKLAB_TO_RGB=161
CIELAB_TO_RGB=162
RGB_TO_HSV=163
HSV_TO_RGB=164
INT_TO_RGB=165
RGB_TO_INT=166
INTERPOLATE_LINEAR=167
INTERPOLATE_AREA=168
INTERPOLATE_NEAREST=169
TEXT_IMAGE=170
AS_NESTED=171
SVD=172
DIAG=173
IF=174
ELSE=175
WHILE=176
FOR=177
IN=178
BREAK=179
CONTINUE=180
RETURN=181
TIMESTAMP=182
SORT=183
ARGSORT=184
ARGMIN=185
ARGMAX=186
SOFTMAX=187
SOFTMIN=188
UNIQUE=189
FLIP=190
STARTSWITH=191
ENDSWITH=192
SQUEEZE=193
UNSQUEEZE=194
ROLL=195
COV=196
CORR=197
ENTROPY=198
CROP=199
NONE=200
COORDS=201
GATHER=202
SCATTER=203
SCATTER_ADD=204
NOISE=205
RAND=206
CAUCHY=207
EXPONENTIAL=208
LOGNORMAL=209
BERNOULLI=210
POISSON=211
GAMMADIST=212
BETADIST=213
LAPLACEDIST=214
GUMBELDIST=215
WEIBULLDIST=216
CHI2DIST=217
STUDENTTDIST=218
PERLIN=219
CELLULAR=220
PLASMA=221
RIDGED=222
DOMAIN_WARP=223
PLUS=224
MINUS=225
MULT=226
DIV=227
MOD=228
POW=229
LSHIFT=230
RSHIFT=231
GE=232
GT=233
LE=234
LT=235
EQ=236
EQUEALS=237
PLUS_EQ=238
MINUS_EQ=239
MULT_EQ=240
DIV_EQ=241
MOD_EQ=242
NE=243
PIPE=244
LPAREN=245
RPAREN=246
COMMA=247
SEMICOLON=248
ARROW=249
LBRACKET=250
RBRACKET=251
QUESTION=252
COLON=253
LBRACE=254
RBRACE=255
NUMBER=256
CONSTANT=257
STRING=258
VARIABLE=259
SL_COMMENT=260
ML_COMMENT=261
WS=262
'sin'=1
'cos'=2
'tan'=3
@@ -270,170 +277,177 @@ WS=255
'sqrt'=15
'ln'=16
'log'=17
'exp'=18
'log1p'=19
'expm1'=20
'isnan'=21
'isinf'=22
'isfinite'=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'=43
'step'=44
'smoothstep'=45
'fract'=46
'relu'=47
'softplus'=48
'gelu'=49
'sign'=50
'map'=51
'swap'=54
'range'=58
'linspace'=59
'logspace'=60
'topk'=61
'botk'=62
'pinv'=63
'sum'=64
'mean'=65
'std'=66
'var'=67
'prod'=68
'isclose'=69
'allclose'=70
'quantile'=73
'dot'=74
'moment'=75
'erf'=76
'erfinv'=77
'any'=78
'all'=79
'edge'=80
'median'=82
'mode'=83
'cumsum'=84
'cumprod'=85
'smootherstep'=91
'remap'=93
'keys'=96
'repeat'=104
'flatten'=105
'append'=106
'get_value'=107
'flow_apply'=108
'motion_mask'=110
'flow_to_image'=111
'where'=114
'overlay'=116
'pad'=117
'cross'=118
'matmul'=119
'rife'=120
'shape'=123
'tensor'=127
'add_key'=128
'stack_push'=130
'stack_pop'=131
'stack_clear'=132
'stack_has'=133
'stack_get'=134
'stack'=136
'nonzero'=137
'int'=138
'float'=139
'upper'=140
'lower'=141
'trim'=142
'split'=143
'join'=144
'find'=146
'replace'=147
'dilate'=148
'erode'=149
'morph_open'=150
'morph_close'=151
'rgb_to_oklab'=152
'rgb_to_cielab'=153
'oklab_to_rgb'=154
'cielab_to_rgb'=155
'rgb_to_hsv'=156
'hsv_to_rgb'=157
'int_to_rgb'=158
'rgb_to_int'=159
'interpolate_linear'=160
'interpolate_area'=161
'text_image'=163
'if'=167
'else'=168
'while'=169
'for'=170
'in'=171
'break'=172
'continue'=173
'return'=174
'sort'=176
'argsort'=177
'argmin'=178
'argmax'=179
'softmax'=180
'softmin'=181
'unique'=182
'flip'=183
'startswith'=184
'endswith'=185
'squeeze'=186
'unsqueeze'=187
'roll'=188
'cov'=189
'entropy'=191
'crop'=192
'gather'=195
'scatter'=196
'scatter_add'=197
'+'=217
'-'=218
'*'=219
'/'=220
'%'=221
'^'=222
'<<'=223
'>>'=224
'>='=225
'>'=226
'<='=227
'<'=228
'=='=229
'='=230
'+='=231
'-='=232
'*='=233
'/='=234
'%='=235
'!='=236
'|'=237
'('=238
')'=239
','=240
';'=241
'->'=242
'['=243
']'=244
'?'=245
':'=246
'{'=247
'}'=248
'log2'=18
'exp'=19
'log1p'=20
'expm1'=21
'isnan'=22
'isinf'=23
'isfinite'=24
'smin'=25
'smax'=26
'tmin'=27
'tmax'=28
'tnorm'=29
'snorm'=30
'floor'=31
'ceil'=32
'round'=33
'gamma'=34
'pow'=35
'sigm'=36
'clamp'=37
'fft'=38
'ifft'=39
'angle'=40
'print'=41
'lerp'=44
'step'=45
'smoothstep'=46
'fract'=47
'relu'=48
'softplus'=49
'gelu'=50
'sign'=51
'degrees'=52
'radians'=53
'logical_not'=54
'logical_and'=55
'logical_or'=56
'hypot'=57
'map'=58
'swap'=61
'range'=65
'linspace'=66
'logspace'=67
'topk'=68
'botk'=69
'pinv'=70
'sum'=71
'mean'=72
'std'=73
'var'=74
'prod'=75
'isclose'=76
'allclose'=77
'quantile'=80
'dot'=81
'moment'=82
'erf'=83
'erfinv'=84
'any'=85
'all'=86
'edge'=87
'median'=89
'mode'=90
'cumsum'=91
'cumprod'=92
'smootherstep'=98
'remap'=100
'keys'=103
'repeat'=111
'flatten'=112
'append'=113
'get_value'=114
'flow_apply'=115
'motion_mask'=117
'flow_to_image'=118
'where'=121
'overlay'=123
'pad'=124
'cross'=125
'matmul'=126
'rife'=127
'shape'=130
'tensor'=134
'add_key'=135
'stack_push'=137
'stack_pop'=138
'stack_clear'=139
'stack_has'=140
'stack_get'=141
'stack'=143
'nonzero'=144
'int'=145
'float'=146
'upper'=147
'lower'=148
'trim'=149
'split'=150
'join'=151
'find'=153
'replace'=154
'dilate'=155
'erode'=156
'morph_open'=157
'morph_close'=158
'rgb_to_oklab'=159
'rgb_to_cielab'=160
'oklab_to_rgb'=161
'cielab_to_rgb'=162
'rgb_to_hsv'=163
'hsv_to_rgb'=164
'int_to_rgb'=165
'rgb_to_int'=166
'interpolate_linear'=167
'interpolate_area'=168
'text_image'=170
'if'=174
'else'=175
'while'=176
'for'=177
'in'=178
'break'=179
'continue'=180
'return'=181
'sort'=183
'argsort'=184
'argmin'=185
'argmax'=186
'softmax'=187
'softmin'=188
'unique'=189
'flip'=190
'startswith'=191
'endswith'=192
'squeeze'=193
'unsqueeze'=194
'roll'=195
'cov'=196
'entropy'=198
'crop'=199
'gather'=202
'scatter'=203
'scatter_add'=204
'+'=224
'-'=225
'*'=226
'/'=227
'%'=228
'^'=229
'<<'=230
'>>'=231
'>='=232
'>'=233
'<='=234
'<'=235
'=='=236
'='=237
'+='=238
'-='=239
'*='=240
'/='=241
'%='=242
'!='=243
'|'=244
'('=245
')'=246
','=247
';'=248
'->'=249
'['=250
']'=251
'?'=252
':'=253
'{'=254
'}'=255
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
+419 -405
View File
@@ -15,244 +15,251 @@ ABS=14
SQRT=15
LN=16
LOG=17
EXP=18
LOG1P=19
EXPM1=20
ISNAN=21
ISINF=22
ISFINITE=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
NVL=42
LERP=43
STEP=44
SMOOTHSTEP=45
FRACT=46
RELU=47
SOFTPLUS=48
GELU=49
SIGN=50
MAP=51
EZCONV=52
CONV=53
SWAP=54
TRANSPOSE=55
PERM=56
RESHAPE=57
RANGE=58
LINSPACE=59
LOGSPACE=60
TOPK=61
BOTK=62
PINV=63
SUM=64
MEAN=65
STD=66
VAR=67
PROD=68
ISCLOSE=69
ALLCLOSE=70
QUARTILE=71
PERCENTILE=72
QUANTILE=73
DOT=74
MOMENT=75
ERF=76
ERFINV=77
ANY=78
ALL=79
EDGE=80
GAUSSIAN=81
MEDIAN=82
MODE=83
CUMSUM=84
CUMPROD=85
TOPK_IND=86
BOTK_IND=87
CUBIC_EASE=88
ELASTIC_EASE=89
SINE_EASE=90
SMOOTHERSTEP=91
DIST=92
REMAP=93
COSSIM=94
COUNT=95
KEYS=96
ENABLE_TRACKING=97
DISABLE_TRACKING=98
RESET_TRACKING=99
GET_CHANGED_KEYS=100
GET_ADDED_KEYS=101
GET_REMOVED_KEYS=102
GET_UNCHANGED_KEYS=103
REPEAT=104
FLATTEN=105
APPEND=106
GET_VALUE=107
FLOW_APPLY=108
BATCH_SHUFFLE=109
MOTION_MASK=110
FLOW_TO_IMAGE=111
FLOW_MAG=112
FLOW_ANG=113
WHERE=114
HISTOGRAM=115
OVERLAY=116
PAD=117
CROSS=118
MATMUL=119
RIFE=120
BNOT=121
BITCOUNT=122
SHAPE=123
BAND=124
XOR=125
BOR=126
TENSOR=127
ADD_KEY=128
REMOVE_KEY=129
PUSH=130
POP=131
CLEAR=132
HAS=133
GET=134
CONCAT=135
STACK=136
NONZERO=137
INT=138
FLOAT=139
UPPER=140
LOWER=141
TRIM=142
SPLIT=143
JOIN=144
SUBSTRING=145
FIND=146
REPLACE=147
DILATE=148
ERODE=149
MORPH_OPEN=150
MORPH_CLOSE=151
RGB_TO_OKLAB=152
RGB_TO_CIELAB=153
OKLAB_TO_RGB=154
CIELAB_TO_RGB=155
RGB_TO_HSV=156
HSV_TO_RGB=157
INT_TO_RGB=158
RGB_TO_INT=159
INTERPOLATE_LINEAR=160
INTERPOLATE_AREA=161
INTERPOLATE_NEAREST=162
TEXT_IMAGE=163
AS_NESTED=164
SVD=165
DIAG=166
IF=167
ELSE=168
WHILE=169
FOR=170
IN=171
BREAK=172
CONTINUE=173
RETURN=174
TIMESTAMP=175
SORT=176
ARGSORT=177
ARGMIN=178
ARGMAX=179
SOFTMAX=180
SOFTMIN=181
UNIQUE=182
FLIP=183
STARTSWITH=184
ENDSWITH=185
SQUEEZE=186
UNSQUEEZE=187
ROLL=188
COV=189
CORR=190
ENTROPY=191
CROP=192
NONE=193
COORDS=194
GATHER=195
SCATTER=196
SCATTER_ADD=197
NOISE=198
RAND=199
CAUCHY=200
EXPONENTIAL=201
LOGNORMAL=202
BERNOULLI=203
POISSON=204
GAMMADIST=205
BETADIST=206
LAPLACEDIST=207
GUMBELDIST=208
WEIBULLDIST=209
CHI2DIST=210
STUDENTTDIST=211
PERLIN=212
CELLULAR=213
PLASMA=214
RIDGED=215
DOMAIN_WARP=216
PLUS=217
MINUS=218
MULT=219
DIV=220
MOD=221
POW=222
LSHIFT=223
RSHIFT=224
GE=225
GT=226
LE=227
LT=228
EQ=229
EQUEALS=230
PLUS_EQ=231
MINUS_EQ=232
MULT_EQ=233
DIV_EQ=234
MOD_EQ=235
NE=236
PIPE=237
LPAREN=238
RPAREN=239
COMMA=240
SEMICOLON=241
ARROW=242
LBRACKET=243
RBRACKET=244
QUESTION=245
COLON=246
LBRACE=247
RBRACE=248
NUMBER=249
CONSTANT=250
STRING=251
VARIABLE=252
SL_COMMENT=253
ML_COMMENT=254
WS=255
LOG2=18
EXP=19
LOG1P=20
EXPM1=21
ISNAN=22
ISINF=23
ISFINITE=24
SMIN=25
SMAX=26
TMIN=27
TMAX=28
TNORM=29
SNORM=30
FLOOR=31
CEIL=32
ROUND=33
GAMMA=34
POWE=35
SIGM=36
CLAMP=37
SFFT=38
SIFFT=39
ANGL=40
PRNT=41
PRINT_SHAPE=42
NVL=43
LERP=44
STEP=45
SMOOTHSTEP=46
FRACT=47
RELU=48
SOFTPLUS=49
GELU=50
SIGN=51
DEGREES=52
RADIANS=53
LOGICAL_NOT=54
LOGICAL_AND=55
LOGICAL_OR=56
HYPOT=57
MAP=58
EZCONV=59
CONV=60
SWAP=61
TRANSPOSE=62
PERM=63
RESHAPE=64
RANGE=65
LINSPACE=66
LOGSPACE=67
TOPK=68
BOTK=69
PINV=70
SUM=71
MEAN=72
STD=73
VAR=74
PROD=75
ISCLOSE=76
ALLCLOSE=77
QUARTILE=78
PERCENTILE=79
QUANTILE=80
DOT=81
MOMENT=82
ERF=83
ERFINV=84
ANY=85
ALL=86
EDGE=87
GAUSSIAN=88
MEDIAN=89
MODE=90
CUMSUM=91
CUMPROD=92
TOPK_IND=93
BOTK_IND=94
CUBIC_EASE=95
ELASTIC_EASE=96
SINE_EASE=97
SMOOTHERSTEP=98
DIST=99
REMAP=100
COSSIM=101
COUNT=102
KEYS=103
ENABLE_TRACKING=104
DISABLE_TRACKING=105
RESET_TRACKING=106
GET_CHANGED_KEYS=107
GET_ADDED_KEYS=108
GET_REMOVED_KEYS=109
GET_UNCHANGED_KEYS=110
REPEAT=111
FLATTEN=112
APPEND=113
GET_VALUE=114
FLOW_APPLY=115
BATCH_SHUFFLE=116
MOTION_MASK=117
FLOW_TO_IMAGE=118
FLOW_MAG=119
FLOW_ANG=120
WHERE=121
HISTOGRAM=122
OVERLAY=123
PAD=124
CROSS=125
MATMUL=126
RIFE=127
BNOT=128
BITCOUNT=129
SHAPE=130
BAND=131
XOR=132
BOR=133
TENSOR=134
ADD_KEY=135
REMOVE_KEY=136
PUSH=137
POP=138
CLEAR=139
HAS=140
GET=141
CONCAT=142
STACK=143
NONZERO=144
INT=145
FLOAT=146
UPPER=147
LOWER=148
TRIM=149
SPLIT=150
JOIN=151
SUBSTRING=152
FIND=153
REPLACE=154
DILATE=155
ERODE=156
MORPH_OPEN=157
MORPH_CLOSE=158
RGB_TO_OKLAB=159
RGB_TO_CIELAB=160
OKLAB_TO_RGB=161
CIELAB_TO_RGB=162
RGB_TO_HSV=163
HSV_TO_RGB=164
INT_TO_RGB=165
RGB_TO_INT=166
INTERPOLATE_LINEAR=167
INTERPOLATE_AREA=168
INTERPOLATE_NEAREST=169
TEXT_IMAGE=170
AS_NESTED=171
SVD=172
DIAG=173
IF=174
ELSE=175
WHILE=176
FOR=177
IN=178
BREAK=179
CONTINUE=180
RETURN=181
TIMESTAMP=182
SORT=183
ARGSORT=184
ARGMIN=185
ARGMAX=186
SOFTMAX=187
SOFTMIN=188
UNIQUE=189
FLIP=190
STARTSWITH=191
ENDSWITH=192
SQUEEZE=193
UNSQUEEZE=194
ROLL=195
COV=196
CORR=197
ENTROPY=198
CROP=199
NONE=200
COORDS=201
GATHER=202
SCATTER=203
SCATTER_ADD=204
NOISE=205
RAND=206
CAUCHY=207
EXPONENTIAL=208
LOGNORMAL=209
BERNOULLI=210
POISSON=211
GAMMADIST=212
BETADIST=213
LAPLACEDIST=214
GUMBELDIST=215
WEIBULLDIST=216
CHI2DIST=217
STUDENTTDIST=218
PERLIN=219
CELLULAR=220
PLASMA=221
RIDGED=222
DOMAIN_WARP=223
PLUS=224
MINUS=225
MULT=226
DIV=227
MOD=228
POW=229
LSHIFT=230
RSHIFT=231
GE=232
GT=233
LE=234
LT=235
EQ=236
EQUEALS=237
PLUS_EQ=238
MINUS_EQ=239
MULT_EQ=240
DIV_EQ=241
MOD_EQ=242
NE=243
PIPE=244
LPAREN=245
RPAREN=246
COMMA=247
SEMICOLON=248
ARROW=249
LBRACKET=250
RBRACKET=251
QUESTION=252
COLON=253
LBRACE=254
RBRACE=255
NUMBER=256
CONSTANT=257
STRING=258
VARIABLE=259
SL_COMMENT=260
ML_COMMENT=261
WS=262
'sin'=1
'cos'=2
'tan'=3
@@ -270,170 +277,177 @@ WS=255
'sqrt'=15
'ln'=16
'log'=17
'exp'=18
'log1p'=19
'expm1'=20
'isnan'=21
'isinf'=22
'isfinite'=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'=43
'step'=44
'smoothstep'=45
'fract'=46
'relu'=47
'softplus'=48
'gelu'=49
'sign'=50
'map'=51
'swap'=54
'range'=58
'linspace'=59
'logspace'=60
'topk'=61
'botk'=62
'pinv'=63
'sum'=64
'mean'=65
'std'=66
'var'=67
'prod'=68
'isclose'=69
'allclose'=70
'quantile'=73
'dot'=74
'moment'=75
'erf'=76
'erfinv'=77
'any'=78
'all'=79
'edge'=80
'median'=82
'mode'=83
'cumsum'=84
'cumprod'=85
'smootherstep'=91
'remap'=93
'keys'=96
'repeat'=104
'flatten'=105
'append'=106
'get_value'=107
'flow_apply'=108
'motion_mask'=110
'flow_to_image'=111
'where'=114
'overlay'=116
'pad'=117
'cross'=118
'matmul'=119
'rife'=120
'shape'=123
'tensor'=127
'add_key'=128
'stack_push'=130
'stack_pop'=131
'stack_clear'=132
'stack_has'=133
'stack_get'=134
'stack'=136
'nonzero'=137
'int'=138
'float'=139
'upper'=140
'lower'=141
'trim'=142
'split'=143
'join'=144
'find'=146
'replace'=147
'dilate'=148
'erode'=149
'morph_open'=150
'morph_close'=151
'rgb_to_oklab'=152
'rgb_to_cielab'=153
'oklab_to_rgb'=154
'cielab_to_rgb'=155
'rgb_to_hsv'=156
'hsv_to_rgb'=157
'int_to_rgb'=158
'rgb_to_int'=159
'interpolate_linear'=160
'interpolate_area'=161
'text_image'=163
'if'=167
'else'=168
'while'=169
'for'=170
'in'=171
'break'=172
'continue'=173
'return'=174
'sort'=176
'argsort'=177
'argmin'=178
'argmax'=179
'softmax'=180
'softmin'=181
'unique'=182
'flip'=183
'startswith'=184
'endswith'=185
'squeeze'=186
'unsqueeze'=187
'roll'=188
'cov'=189
'entropy'=191
'crop'=192
'gather'=195
'scatter'=196
'scatter_add'=197
'+'=217
'-'=218
'*'=219
'/'=220
'%'=221
'^'=222
'<<'=223
'>>'=224
'>='=225
'>'=226
'<='=227
'<'=228
'=='=229
'='=230
'+='=231
'-='=232
'*='=233
'/='=234
'%='=235
'!='=236
'|'=237
'('=238
')'=239
','=240
';'=241
'->'=242
'['=243
']'=244
'?'=245
':'=246
'{'=247
'}'=248
'log2'=18
'exp'=19
'log1p'=20
'expm1'=21
'isnan'=22
'isinf'=23
'isfinite'=24
'smin'=25
'smax'=26
'tmin'=27
'tmax'=28
'tnorm'=29
'snorm'=30
'floor'=31
'ceil'=32
'round'=33
'gamma'=34
'pow'=35
'sigm'=36
'clamp'=37
'fft'=38
'ifft'=39
'angle'=40
'print'=41
'lerp'=44
'step'=45
'smoothstep'=46
'fract'=47
'relu'=48
'softplus'=49
'gelu'=50
'sign'=51
'degrees'=52
'radians'=53
'logical_not'=54
'logical_and'=55
'logical_or'=56
'hypot'=57
'map'=58
'swap'=61
'range'=65
'linspace'=66
'logspace'=67
'topk'=68
'botk'=69
'pinv'=70
'sum'=71
'mean'=72
'std'=73
'var'=74
'prod'=75
'isclose'=76
'allclose'=77
'quantile'=80
'dot'=81
'moment'=82
'erf'=83
'erfinv'=84
'any'=85
'all'=86
'edge'=87
'median'=89
'mode'=90
'cumsum'=91
'cumprod'=92
'smootherstep'=98
'remap'=100
'keys'=103
'repeat'=111
'flatten'=112
'append'=113
'get_value'=114
'flow_apply'=115
'motion_mask'=117
'flow_to_image'=118
'where'=121
'overlay'=123
'pad'=124
'cross'=125
'matmul'=126
'rife'=127
'shape'=130
'tensor'=134
'add_key'=135
'stack_push'=137
'stack_pop'=138
'stack_clear'=139
'stack_has'=140
'stack_get'=141
'stack'=143
'nonzero'=144
'int'=145
'float'=146
'upper'=147
'lower'=148
'trim'=149
'split'=150
'join'=151
'find'=153
'replace'=154
'dilate'=155
'erode'=156
'morph_open'=157
'morph_close'=158
'rgb_to_oklab'=159
'rgb_to_cielab'=160
'oklab_to_rgb'=161
'cielab_to_rgb'=162
'rgb_to_hsv'=163
'hsv_to_rgb'=164
'int_to_rgb'=165
'rgb_to_int'=166
'interpolate_linear'=167
'interpolate_area'=168
'text_image'=170
'if'=174
'else'=175
'while'=176
'for'=177
'in'=178
'break'=179
'continue'=180
'return'=181
'sort'=183
'argsort'=184
'argmin'=185
'argmax'=186
'softmax'=187
'softmin'=188
'unique'=189
'flip'=190
'startswith'=191
'endswith'=192
'squeeze'=193
'unsqueeze'=194
'roll'=195
'cov'=196
'entropy'=198
'crop'=199
'gather'=202
'scatter'=203
'scatter_add'=204
'+'=224
'-'=225
'*'=226
'/'=227
'%'=228
'^'=229
'<<'=230
'>>'=231
'>='=232
'>'=233
'<='=234
'<'=235
'=='=236
'='=237
'+='=238
'-='=239
'*='=240
'/='=241
'%='=242
'!='=243
'|'=244
'('=245
')'=246
','=247
';'=248
'->'=249
'['=250
']'=251
'?'=252
':'=253
'{'=254
'}'=255
@@ -881,6 +881,15 @@ class MathExprListener(ParseTreeListener):
pass
# Enter a parse tree produced by MathExprParser#Log2Func.
def enterLog2Func(self, ctx:MathExprParser.Log2FuncContext):
pass
# Exit a parse tree produced by MathExprParser#Log2Func.
def exitLog2Func(self, ctx:MathExprParser.Log2FuncContext):
pass
# Enter a parse tree produced by MathExprParser#ExpFunc.
def enterExpFunc(self, ctx:MathExprParser.ExpFuncContext):
pass
@@ -1052,6 +1061,33 @@ class MathExprListener(ParseTreeListener):
pass
# Enter a parse tree produced by MathExprParser#DegreesFunc.
def enterDegreesFunc(self, ctx:MathExprParser.DegreesFuncContext):
pass
# Exit a parse tree produced by MathExprParser#DegreesFunc.
def exitDegreesFunc(self, ctx:MathExprParser.DegreesFuncContext):
pass
# Enter a parse tree produced by MathExprParser#RadiansFunc.
def enterRadiansFunc(self, ctx:MathExprParser.RadiansFuncContext):
pass
# Exit a parse tree produced by MathExprParser#RadiansFunc.
def exitRadiansFunc(self, ctx:MathExprParser.RadiansFuncContext):
pass
# Enter a parse tree produced by MathExprParser#LogicalNotFunc.
def enterLogicalNotFunc(self, ctx:MathExprParser.LogicalNotFuncContext):
pass
# Exit a parse tree produced by MathExprParser#LogicalNotFunc.
def exitLogicalNotFunc(self, ctx:MathExprParser.LogicalNotFuncContext):
pass
# Enter a parse tree produced by MathExprParser#PrintShapeFunc.
def enterPrintShapeFunc(self, ctx:MathExprParser.PrintShapeFuncContext):
pass
@@ -1556,6 +1592,33 @@ class MathExprListener(ParseTreeListener):
pass
# Enter a parse tree produced by MathExprParser#HypotFunc.
def enterHypotFunc(self, ctx:MathExprParser.HypotFuncContext):
pass
# Exit a parse tree produced by MathExprParser#HypotFunc.
def exitHypotFunc(self, ctx:MathExprParser.HypotFuncContext):
pass
# Enter a parse tree produced by MathExprParser#LogicalAndFunc.
def enterLogicalAndFunc(self, ctx:MathExprParser.LogicalAndFuncContext):
pass
# Exit a parse tree produced by MathExprParser#LogicalAndFunc.
def exitLogicalAndFunc(self, ctx:MathExprParser.LogicalAndFuncContext):
pass
# Enter a parse tree produced by MathExprParser#LogicalOrFunc.
def enterLogicalOrFunc(self, ctx:MathExprParser.LogicalOrFuncContext):
pass
# Exit a parse tree produced by MathExprParser#LogicalOrFunc.
def exitLogicalOrFunc(self, ctx:MathExprParser.LogicalOrFuncContext):
pass
# Enter a parse tree produced by MathExprParser#IscloseFunc.
def enterIscloseFunc(self, ctx:MathExprParser.IscloseFuncContext):
pass
File diff suppressed because one or more lines are too long
@@ -494,6 +494,11 @@ class MathExprVisitor(ParseTreeVisitor):
return self.visitChildren(ctx)
# Visit a parse tree produced by MathExprParser#Log2Func.
def visitLog2Func(self, ctx:MathExprParser.Log2FuncContext):
return self.visitChildren(ctx)
# Visit a parse tree produced by MathExprParser#ExpFunc.
def visitExpFunc(self, ctx:MathExprParser.ExpFuncContext):
return self.visitChildren(ctx)
@@ -589,6 +594,21 @@ class MathExprVisitor(ParseTreeVisitor):
return self.visitChildren(ctx)
# Visit a parse tree produced by MathExprParser#DegreesFunc.
def visitDegreesFunc(self, ctx:MathExprParser.DegreesFuncContext):
return self.visitChildren(ctx)
# Visit a parse tree produced by MathExprParser#RadiansFunc.
def visitRadiansFunc(self, ctx:MathExprParser.RadiansFuncContext):
return self.visitChildren(ctx)
# Visit a parse tree produced by MathExprParser#LogicalNotFunc.
def visitLogicalNotFunc(self, ctx:MathExprParser.LogicalNotFuncContext):
return self.visitChildren(ctx)
# Visit a parse tree produced by MathExprParser#PrintShapeFunc.
def visitPrintShapeFunc(self, ctx:MathExprParser.PrintShapeFuncContext):
return self.visitChildren(ctx)
@@ -869,6 +889,21 @@ class MathExprVisitor(ParseTreeVisitor):
return self.visitChildren(ctx)
# Visit a parse tree produced by MathExprParser#HypotFunc.
def visitHypotFunc(self, ctx:MathExprParser.HypotFuncContext):
return self.visitChildren(ctx)
# Visit a parse tree produced by MathExprParser#LogicalAndFunc.
def visitLogicalAndFunc(self, ctx:MathExprParser.LogicalAndFuncContext):
return self.visitChildren(ctx)
# Visit a parse tree produced by MathExprParser#LogicalOrFunc.
def visitLogicalOrFunc(self, ctx:MathExprParser.LogicalOrFuncContext):
return self.visitChildren(ctx)
# Visit a parse tree produced by MathExprParser#IscloseFunc.
def visitIscloseFunc(self, ctx:MathExprParser.IscloseFuncContext):
return self.visitChildren(ctx)
+28
View File
@@ -1,6 +1,7 @@
import torch
import sys
import os
import math
# Ensure test runner usage (Visual Studio) can import the package regardless of working dir.
_here = os.path.abspath(os.path.dirname(__file__))
@@ -9,6 +10,7 @@ if _project_root not in sys.path:
sys.path.insert(0, _project_root)
from more_math.Parser.UnifiedMathVisitor import UnifiedMathVisitor
from more_math.Parser.inbuilt_symbols import INBUILT_FUNCTIONS
from more_math.helper_functions import parse_expr
def eval_expr(expr, variables={}, shape=(1,)):
@@ -81,6 +83,32 @@ def test_lerp_fix():
# Expected: [5, 15, 25]
assert res2 == [5.0, 15.0, 25.0]
def test_added_math_and_logical_functions():
added_functions = {
"logical_not", "logical_and", "logical_or", "degrees", "radians", "log2", "hypot"
}
assert added_functions <= INBUILT_FUNCTIONS
assert eval_expr("logical_not(0)") == 1.0
assert eval_expr("logical_not(-2)") == 0.0
assert eval_expr("logical_and(2, 1)") == 1.0
assert eval_expr("logical_and(2, 0)") == 0.0
assert eval_expr("logical_or(0, -1)") == 1.0
assert eval_expr("logical_or(0, 0)") == 0.0
assert math.isclose(eval_expr("degrees(pi)"), 180.0, rel_tol=1e-6)
assert math.isclose(eval_expr("radians(180)"), math.pi, rel_tol=1e-6)
assert eval_expr("log2(8)") == 3.0
assert eval_expr("hypot(3, 4)") == 5.0
assert eval_expr("logical_and([1, 0], [1, 1])") == [1.0, 0.0]
assert eval_expr("logical_or([0, 0], [1, 0])") == [1.0, 0.0]
assert eval_expr("logical_not([0, 1])") == [1.0, 0.0]
assert torch.allclose(eval_expr("log2(T)", {"T": torch.tensor([1.0, 2.0, 8.0])}), torch.tensor([0.0, 1.0, 3.0]))
assert torch.allclose(eval_expr("hypot(A, B)", {"A": torch.tensor([3.0, 5.0]), "B": torch.tensor([4.0, 12.0])}), torch.tensor([5.0, 13.0]))
assert torch.allclose(eval_expr("logical_or(A, B)", {"A": torch.tensor([0.0, 1.0]), "B": torch.tensor([0.0, 0.0])}), torch.tensor([0.0, 1.0]))
assert torch.allclose(eval_expr("degrees(T)", {"T": torch.tensor([0.0, math.pi])}), torch.tensor([0.0, 180.0]))
if __name__ == "__main__":
test_logic_functions()
test_spatial_functions()
+8 -1
View File
@@ -9,7 +9,7 @@ export const CONSTANTS = new Set([
]);
export const FUNCTIONS = new Set([
"abs", "acos", "acosh", "add_key", "added_keys", "all", "allclose", "angle", "any", "append", "argmax", "argmin", "argsort", "as_nested", "as_nested_tensor", "asin", "asinh", "atan", "atan2", "atanh", "band", "batch_shuffle", "bitcount", "bitwise_and", "bitwise_not", "bitwise_or", "bitwise_xor", "blur", "bnot", "bor", "botk", "botk_ind", "botk_indices", "bxor", "cat", "ceil", "cellular", "cellular_noise", "cielab_to_rgb", "clamp", "cnt", "concat", "concatenate", "conv", "convolution", "coordinates", "coords", "corr", "correlation", "cos", "cosh", "cosine_similarity", "cossim", "count", "cov", "crop", "cross", "cubic", "cubic_ease", "cumprod", "cumsum", "diag", "diagonal_matrix", "dilate", "disable_tracking", "dist", "distance", "domain_warp", "domain_warp_noise", "dot", "edge", "elastic", "elastic_ease", "enable_tracking", "endswith", "entropy", "erf", "erfinv", "erode", "exp", "expm1", "ezconv", "ezconvolution", "fft", "find", "flatten", "flip", "float", "floor", "flow_ang", "flow_angle", "flow_apply", "flow_mag", "flow_magnitude", "flow_to_image", "fract", "gamma", "gather", "gaussian", "gelu", "get_added_keys", "get_changed_keys", "get_removed_keys", "get_unchanged_keys", "get_value", "hist", "histogram", "hsv_to_rgb", "changed_keys", "ifft", "int", "int_to_rgb", "interpolate_area", "interpolate_linear", "interpolate_nearest", "interpolate_nearest_exact", "isclose", "isfinite", "isinf", "isnan", "join", "keys", "length", "lerp", "linspace", "ln", "log", "log1p", "logspace", "lower", "map", "matmul", "mean", "median", "mode", "moment", "morph_close", "morph_open", "motion_mask", "nan_to_num", "noise", "nonzero", "now", "nvl", "oklab_to_rgb", "overlay", "pad", "percentile", "perlin", "perlin_noise", "perm", "permute", "pinv", "plasma", "plasma_noise", "popcnt", "popcount", "pow", "prcnt", "print", "print_shape", "prod", "pshp", "quantile", "quartil", "quartile", "rand", "randb", "randbeta", "randc", "rande", "randg", "randgumbel", "randchi2", "randl", "randln", "randn", "random_bernoulli", "random_beta", "random_cauchy", "random_exponential", "random_gamma", "random_gumbel", "random_chi2", "random_laplace", "random_log_normal", "random_normal", "random_poisson", "random_studentt", "random_uniform", "random_weibull", "randp", "randt", "randu", "randw", "range", "relu", "remap", "remove_key", "removed_keys", "repeat", "replace", "reset_tracking", "reshape", "rgb_to_cielab", "rgb_to_hsv", "rgb_to_int", "rgb_to_oklab", "ridged", "ridged_noise", "rife", "rm_key", "roll", "round", "rshp", "scatter", "scatter_add", "select", "shape", "shuffle", "sigm", "sign", "sin", "sine", "sine_ease", "singular_value_decomposition", "sinh", "smax", "smin", "smootherstep", "smoothstep", "snorm", "softmax", "softmin", "softplus", "sort", "split", "sqrt", "squeeze", "stack", "stack_clear", "stack_get", "stack_has", "stack_pop", "stack_push", "startswith", "std", "step", "substr", "substring", "sum", "svd", "swap", "swapaxes", "tan", "tanh", "tensor", "text_image", "timestamp", "tmax", "tmin", "tnorm", "topk", "topk_ind", "topk_indices", "track_off", "track_on", "track_reset", "transpose", "trim", "turbulence", "unchanged_keys", "unique", "unsqueeze", "upper", "var", "voronoi", "voronoi_noise", "where", "worley"
"abs", "acos", "acosh", "add_key", "added_keys", "all", "allclose", "angle", "any", "append", "argmax", "argmin", "argsort", "as_nested", "as_nested_tensor", "asin", "asinh", "atan", "atan2", "atanh", "band", "batch_shuffle", "bitcount", "bitwise_and", "bitwise_not", "bitwise_or", "bitwise_xor", "blur", "bnot", "bor", "botk", "botk_ind", "botk_indices", "bxor", "cat", "ceil", "cellular", "cellular_noise", "cielab_to_rgb", "clamp", "cnt", "concat", "concatenate", "conv", "convolution", "coordinates", "coords", "corr", "correlation", "cos", "cosh", "cosine_similarity", "cossim", "count", "cov", "crop", "cross", "cubic", "cubic_ease", "cumprod", "cumsum", "degrees", "diag", "diagonal_matrix", "dilate", "disable_tracking", "dist", "distance", "domain_warp", "domain_warp_noise", "dot", "edge", "elastic", "elastic_ease", "enable_tracking", "endswith", "entropy", "erf", "erfinv", "erode", "exp", "expm1", "ezconv", "ezconvolution", "fft", "find", "flatten", "flip", "float", "floor", "flow_ang", "flow_angle", "flow_apply", "flow_mag", "flow_magnitude", "flow_to_image", "fract", "gamma", "gather", "gaussian", "gelu", "get_added_keys", "get_changed_keys", "get_removed_keys", "get_unchanged_keys", "get_value", "hist", "histogram", "hsv_to_rgb", "hypot", "changed_keys", "ifft", "int", "int_to_rgb", "interpolate_area", "interpolate_linear", "interpolate_nearest", "interpolate_nearest_exact", "isclose", "isfinite", "isinf", "isnan", "join", "keys", "length", "lerp", "linspace", "ln", "log", "log1p", "log2", "logical_and", "logical_not", "logical_or", "logspace", "lower", "map", "matmul", "mean", "median", "mode", "moment", "morph_close", "morph_open", "motion_mask", "nan_to_num", "noise", "nonzero", "now", "nvl", "oklab_to_rgb", "overlay", "pad", "percentile", "perlin", "perlin_noise", "perm", "permute", "pinv", "plasma", "plasma_noise", "popcnt", "popcount", "pow", "prcnt", "print", "print_shape", "prod", "pshp", "quantile", "quartil", "quartile", "radians", "rand", "randb", "randbeta", "randc", "rande", "randg", "randgumbel", "randchi2", "randl", "randln", "randn", "random_bernoulli", "random_beta", "random_cauchy", "random_exponential", "random_gamma", "random_gumbel", "random_chi2", "random_laplace", "random_log_normal", "random_normal", "random_poisson", "random_studentt", "random_uniform", "random_weibull", "randp", "randt", "randu", "randw", "range", "relu", "remap", "remove_key", "removed_keys", "repeat", "replace", "reset_tracking", "reshape", "rgb_to_cielab", "rgb_to_hsv", "rgb_to_int", "rgb_to_oklab", "ridged", "ridged_noise", "rife", "rm_key", "roll", "round", "rshp", "scatter", "scatter_add", "select", "shape", "shuffle", "sigm", "sign", "sin", "sine", "sine_ease", "singular_value_decomposition", "sinh", "smax", "smin", "smootherstep", "smoothstep", "snorm", "softmax", "softmin", "softplus", "sort", "split", "sqrt", "squeeze", "stack", "stack_clear", "stack_get", "stack_has", "stack_pop", "stack_push", "startswith", "std", "step", "substr", "substring", "sum", "svd", "swap", "swapaxes", "tan", "tanh", "tensor", "text_image", "timestamp", "tmax", "tmin", "tnorm", "topk", "topk_ind", "topk_indices", "track_off", "track_on", "track_reset", "transpose", "trim", "turbulence", "unchanged_keys", "unique", "unsqueeze", "upper", "var", "voronoi", "voronoi_noise", "where", "worley"
]);
export const FUNCTION_META = {
@@ -30,6 +30,7 @@ export const FUNCTION_META = {
"sqrt": { minArgs: 1, maxArgs: 1, snippet: "sqrt(x)", description: "applies sqere root per element. Negative numbers return NaN (not a number)" },
"ln": { minArgs: 1, maxArgs: 1, snippet: "ln(x)", description: "applies natural logarithm to value (per element). Negative numbers return NaN (not a number)" },
"log": { minArgs: 1, maxArgs: 1, snippet: "log(x)", description: "applies base 10 logarithm to value (per element). Negative numbers return NaN (not a number)" },
"log2": { minArgs: 1, maxArgs: 1, snippet: "log2(x)", description: "applies base 2 logarithm to value (per element). Negative numbers return NaN (not a number)" },
"exp": { minArgs: 1, maxArgs: 1, snippet: "exp(x)", description: "applies e^x to value (per element)" },
"log1p": { minArgs: 1, maxArgs: 1, snippet: "log1p(x)", description: "applies ln(1+x) accurately for values near zero" },
"expm1": { minArgs: 1, maxArgs: 1, snippet: "expm1(x)", description: "applies exp(x)-1 accurately for values near zero" },
@@ -65,6 +66,12 @@ export const FUNCTION_META = {
"softplus": { minArgs: 1, maxArgs: 1, snippet: "softplus(x)", description: "applies the softplus function: ln(1 + exp(x))" },
"gelu": { minArgs: 1, maxArgs: 1, snippet: "gelu(x)", description: "applies the Gaussian Error Linear Unit (GELU) activation function" },
"sign": { minArgs: 1, maxArgs: 1, snippet: "sign(x)", description: "returns the sign of x: -1, 0, or 1" },
"degrees": { minArgs: 1, maxArgs: 1, snippet: "degrees(x)", description: "converts radians to degrees (per element)" },
"radians": { minArgs: 1, maxArgs: 1, snippet: "radians(x)", description: "converts degrees to radians (per element)" },
"logical_not": { minArgs: 1, maxArgs: 1, snippet: "logical_not(x)", description: "returns 1.0 where x is zero and 0.0 otherwise" },
"logical_and": { minArgs: 2, maxArgs: 2, snippet: "logical_and(x, y)", description: "returns 1.0 if both values are non-zero, else 0.0" },
"logical_or": { minArgs: 2, maxArgs: 2, snippet: "logical_or(x, y)", description: "returns 1.0 if either value is non-zero, else 0.0" },
"hypot": { minArgs: 2, maxArgs: 2, snippet: "hypot(x, y)", description: "computes the element-wise Euclidean distance from the origin" },
"map": { minArgs: 2, maxArgs: 4, snippet: "map(tensor, coord1, coord2, coord3)", description: "samples/remaps input tensor using coordinates" },
"ezconvolution": { minArgs: 2, maxArgs: 3, snippet: "ezconvolution(tensor, kernel_sizes..., kernel)", description: "applies convolution with kernel. Attempts to correctly convolve over size dimensions." },
"ezconv": { minArgs: 2, maxArgs: 3, snippet: "ezconv(tensor, kernel_sizes..., kernel)", description: "applies convolution with kernel. Attempts to correctly convolve over size dimensions." },