AI: add more functions 5

This commit is contained in:
mcDandy
2026-10-14 12:11:11 +02:00
parent 6a972c71c3
commit 36d12fcb8d
23 changed files with 13386 additions and 12859 deletions
+2
View File
@@ -150,6 +150,7 @@ You can also get the node from comfy manager under the name of More math.
#### 1.4 Activation / ML
- `relu(x)`: `max(0, x)`.
- `silu(x)`: Sigmoid Linear Unit, equivalent to `x * sigm(x)`; applied element-wise.
- `gelu(x)`: Gaussian Error Linear Unit.
- `leaky_relu(x, [negative_slope])`: Leaky ReLU; `negative_slope` defaults to `0.01`.
- `softplus(x)`: smooth ReLU-like function.
@@ -159,6 +160,7 @@ You can also get the node from comfy manager under the name of More math.
- `softmin(x, [dim])`: softmin normalization.
- `erf(x)`: error function.
- `erfinv(x)`: inverse error function.
- `group_norm(x, groups, [weight], [bias], [eps])`: PyTorch GroupNorm for channel-first tensors shaped `[N, C, ...]`; `groups` must divide `C`, affine parameters are optional vectors of length `C`, and `eps` defaults to `1e-5`.
#### 1.5 Logical
- `logical_not(x)`: element-wise logical NOT; returns `1.0` where `x` is zero and `0.0` otherwise.
+10
View File
@@ -289,6 +289,10 @@ func1:
gelu(x) - applies the Gaussian Error Linear Unit (GELU) activation function
*/
| GELU LPAREN expr RPAREN # GeluFunc
/**
silu(x) - applies the Sigmoid Linear Unit activation element-wise
*/
| SILU LPAREN expr RPAREN # SiluFunc
/**
sign(x) - returns the sign of x: -1, 0, or 1
*/
@@ -972,6 +976,10 @@ funcN:
normalize(x, [p], [dim], [eps]) - normalizes x along dim using the p-norm (defaults: p=2, dim=-1, eps=1e-12)
*/
| NORMALIZE LPAREN expr (COMMA expr (COMMA expr (COMMA expr)?)?)? RPAREN # NormalizeFunc
/**
group_norm(x, groups, [weight], [bias], [eps]) - applies channel-first GroupNorm to [N, C, ...] input
*/
| GROUP_NORM LPAREN expr COMMA expr (COMMA expr (COMMA expr (COMMA expr)?)?)? RPAREN # GroupNormFunc
/**
smin(x, ...) - computes the minimum of inputs or elements. Tensors must have the same size or be broadcastable to same size. When called as smin(x, dims) with x a tensor/list, reduces x along dims (a single dim or list of dims) instead.
*/
@@ -1148,6 +1156,7 @@ LOGADDEXP: 'logaddexp';
LOGSUMEXP: 'logsumexp';
NORM: 'norm';
NORMALIZE: 'normalize';
GROUP_NORM: 'group_norm';
OUTER: 'outer';
TRACE: 'trace';
DET: 'det';
@@ -1184,6 +1193,7 @@ SOFTSIGN: 'softsign';
LEAKY_RELU: 'leaky_relu';
SOFTPLUS: 'softplus';
GELU: 'gelu';
SILU: 'silu';
SIGN: 'sign';
DEGREES: 'degrees';
RADIANS: 'radians';
+59
View File
@@ -1131,6 +1131,15 @@ class UnifiedMathVisitor(MathExprVisitor):
(yield ctx.expr()), F.gelu, lambda x: 0.5 * x * (1 + math.tanh(math.sqrt(2 / math.pi) * (x + 0.044715 * math.pow(x, 3)))),
)
def visitSiluFunc(self, ctx):
def scalar_silu(x):
if x >= 0:
return x / (1.0 + math.exp(-x))
exp_x = math.exp(x)
return x * exp_x / (1.0 + exp_x)
return self._unary_op((yield ctx.expr()), F.silu, scalar_silu)
def visitAnglFunc(self, ctx):
return self._unary_op((yield ctx.expr()), torch.angle, lambda x: math.atan2(0, x) if x < 0 else 0)
@@ -1185,6 +1194,56 @@ class UnifiedMathVisitor(MathExprVisitor):
result = result.to(original_dtype)
return result.tolist() if return_list else result
def visitGroupNormFunc(self, ctx):
val = self._promote_to_tensor((yield ctx.expr(0)))
if val.ndim < 2:
raise ValueError(f"{ctx.start.line}:{ctx.start.column}: group_norm input must have shape [N, C, ...]")
num_groups = self._to_int((yield ctx.expr(1)), ctx, "group_norm groups", strict=True)
channels = val.shape[1]
if num_groups <= 0 or channels % num_groups != 0:
raise ValueError(f"{ctx.start.line}:{ctx.start.column}: group_norm groups must be positive and divide the channel count {channels}")
original_dtype = val.dtype
float8_dtypes = self._float8_dtypes()
if original_dtype in float8_dtypes:
val = val.to(torch.float32)
weight = None
bias = None
if len(ctx.expr()) > 2:
weight_arg = (yield ctx.expr(2))
if weight_arg is not None:
weight = self._promote_to_tensor(weight_arg).to(device=val.device, dtype=val.dtype)
if weight.ndim != 1 or weight.numel() != channels:
raise ValueError(f"{ctx.start.line}:{ctx.start.column}: group_norm weight must have shape [{channels}]")
if len(ctx.expr()) > 3:
bias_arg = (yield ctx.expr(3))
if bias_arg is not None:
bias = self._promote_to_tensor(bias_arg).to(device=val.device, dtype=val.dtype)
if bias.ndim != 1 or bias.numel() != channels:
raise ValueError(f"{ctx.start.line}:{ctx.start.column}: group_norm bias must have shape [{channels}]")
eps = 1e-5
if len(ctx.expr()) > 4:
eps_arg = (yield ctx.expr(4))
if self._is_tensor(eps_arg):
if eps_arg.numel() != 1:
raise ValueError(f"{ctx.start.line}:{ctx.start.column}: group_norm eps must be a positive scalar")
eps_arg = eps_arg.item()
elif self._is_list(eps_arg):
if len(eps_arg) != 1:
raise ValueError(f"{ctx.start.line}:{ctx.start.column}: group_norm eps must be a positive scalar")
eps_arg = eps_arg[0]
eps = float(eps_arg)
if not math.isfinite(eps) or eps <= 0:
raise ValueError(f"{ctx.start.line}:{ctx.start.column}: group_norm eps must be a positive finite scalar")
result = F.group_norm(val, num_groups, weight=weight, bias=bias, eps=eps)
if original_dtype in float8_dtypes:
result = result.to(original_dtype)
return result
def visitSNormFunc(self, ctx):
val = (yield ctx.expr(0))
if self._is_list(val):
File diff suppressed because one or more lines are too long
+457 -453
View File
@@ -25,269 +25,271 @@ LOGADDEXP=24
LOGSUMEXP=25
NORM=26
NORMALIZE=27
OUTER=28
TRACE=29
DET=30
RFFT=31
IRFFT=32
ISNAN=33
ISINF=34
ISFINITE=35
SMIN=36
SMAX=37
TMIN=38
TMAX=39
TNORM=40
SNORM=41
FLOOR=42
CEIL=43
ROUND=44
GAMMA=45
POWE=46
SIGM=47
CLAMP=48
SFFT=49
SIFFT=50
ANGL=51
PRNT=52
PRINT_SHAPE=53
NVL=54
LERP=55
STEP=56
SMOOTHSTEP=57
FRACT=58
RELU=59
SOFTSIGN=60
LEAKY_RELU=61
SOFTPLUS=62
GELU=63
SIGN=64
DEGREES=65
RADIANS=66
LOGICAL_NOT=67
LOGICAL_AND=68
LOGICAL_OR=69
HYPOT=70
MAP=71
EZCONV=72
CONV=73
SWAP=74
TRANSPOSE=75
PERM=76
RESHAPE=77
RANGE=78
LINSPACE=79
LOGSPACE=80
TOPK=81
BOTK=82
PINV=83
INV=84
SUM=85
MEAN=86
STD=87
VAR=88
PROD=89
ISCLOSE=90
ALLCLOSE=91
QUARTILE=92
PERCENTILE=93
QUANTILE=94
DOT=95
MOMENT=96
ERF=97
ERFINV=98
ANY=99
ALL=100
EDGE=101
GAUSSIAN=102
MEDIAN=103
MODE=104
CUMSUM=105
CUMPROD=106
TOPK_IND=107
BOTK_IND=108
CUBIC_EASE=109
ELASTIC_EASE=110
SINE_EASE=111
SMOOTHERSTEP=112
DIST=113
REMAP=114
COSSIM=115
COUNT=116
KEYS=117
ENABLE_TRACKING=118
DISABLE_TRACKING=119
RESET_TRACKING=120
GET_CHANGED_KEYS=121
GET_ADDED_KEYS=122
GET_REMOVED_KEYS=123
GET_UNCHANGED_KEYS=124
REPEAT=125
FLATTEN=126
APPEND=127
GET_VALUE=128
FLOW_APPLY=129
BATCH_SHUFFLE=130
MOTION_MASK=131
FLOW_TO_IMAGE=132
FLOW_MAG=133
FLOW_ANG=134
WHERE=135
HISTOGRAM=136
OVERLAY=137
PAD=138
CROSS=139
MATMUL=140
SOLVE=141
MATRIX_RANK=142
RIFE=143
BNOT=144
BITCOUNT=145
SHAPE=146
BAND=147
XOR=148
BOR=149
TENSOR=150
ZEROS=151
ONES=152
EYE=153
ONE_HOT=154
MSE=155
MAE=156
PSNR=157
WEIGHTED_MEAN=158
HUBER_LOSS=159
CROSS_ENTROPY=160
ADD_KEY=161
REMOVE_KEY=162
PUSH=163
POP=164
CLEAR=165
HAS=166
GET=167
CONCAT=168
STACK=169
NONZERO=170
INT=171
FLOAT=172
UPPER=173
LOWER=174
TRIM=175
SPLIT=176
JOIN=177
SUBSTRING=178
FIND=179
REPLACE=180
DILATE=181
ERODE=182
MORPH_OPEN=183
MORPH_CLOSE=184
RGB_TO_OKLAB=185
RGB_TO_CIELAB=186
OKLAB_TO_RGB=187
CIELAB_TO_RGB=188
RGB_TO_HSV=189
HSV_TO_RGB=190
INT_TO_RGB=191
RGB_TO_INT=192
INTERPOLATE_LINEAR=193
INTERPOLATE_AREA=194
INTERPOLATE_NEAREST=195
TEXT_IMAGE=196
AS_NESTED=197
SVD=198
DIAG=199
IF=200
ELSE=201
WHILE=202
FOR=203
IN=204
BREAK=205
CONTINUE=206
RETURN=207
TIMESTAMP=208
SORT=209
ARGSORT=210
ARGMIN=211
ARGMAX=212
SOFTMAX=213
SOFTMIN=214
UNIQUE=215
FLIP=216
STARTSWITH=217
ENDSWITH=218
SQUEEZE=219
UNSQUEEZE=220
ROLL=221
COV=222
CORR=223
ENTROPY=224
CROP=225
NONE=226
COORDS=227
GATHER=228
SCATTER=229
SCATTER_ADD=230
NOISE=231
PINK_NOISE=232
BROWN_NOISE=233
RAND=234
CAUCHY=235
EXPONENTIAL=236
LOGNORMAL=237
BERNOULLI=238
POISSON=239
GAMMADIST=240
BETADIST=241
LAPLACEDIST=242
GUMBELDIST=243
WEIBULLDIST=244
CHI2DIST=245
STUDENTTDIST=246
PERLIN=247
CELLULAR=248
PLASMA=249
RIDGED=250
DOMAIN_WARP=251
PLUS=252
MINUS=253
MULT=254
DIV=255
MOD=256
POW=257
LSHIFT=258
RSHIFT=259
GE=260
GT=261
LE=262
LT=263
EQ=264
EQUEALS=265
PLUS_EQ=266
MINUS_EQ=267
MULT_EQ=268
DIV_EQ=269
MOD_EQ=270
NE=271
PIPE=272
LPAREN=273
RPAREN=274
COMMA=275
SEMICOLON=276
ARROW=277
LBRACKET=278
RBRACKET=279
QUESTION=280
COLON=281
LBRACE=282
RBRACE=283
NUMBER=284
CONSTANT=285
STRING=286
VARIABLE=287
SL_COMMENT=288
ML_COMMENT=289
WS=290
GROUP_NORM=28
OUTER=29
TRACE=30
DET=31
RFFT=32
IRFFT=33
ISNAN=34
ISINF=35
ISFINITE=36
SMIN=37
SMAX=38
TMIN=39
TMAX=40
TNORM=41
SNORM=42
FLOOR=43
CEIL=44
ROUND=45
GAMMA=46
POWE=47
SIGM=48
CLAMP=49
SFFT=50
SIFFT=51
ANGL=52
PRNT=53
PRINT_SHAPE=54
NVL=55
LERP=56
STEP=57
SMOOTHSTEP=58
FRACT=59
RELU=60
SOFTSIGN=61
LEAKY_RELU=62
SOFTPLUS=63
GELU=64
SILU=65
SIGN=66
DEGREES=67
RADIANS=68
LOGICAL_NOT=69
LOGICAL_AND=70
LOGICAL_OR=71
HYPOT=72
MAP=73
EZCONV=74
CONV=75
SWAP=76
TRANSPOSE=77
PERM=78
RESHAPE=79
RANGE=80
LINSPACE=81
LOGSPACE=82
TOPK=83
BOTK=84
PINV=85
INV=86
SUM=87
MEAN=88
STD=89
VAR=90
PROD=91
ISCLOSE=92
ALLCLOSE=93
QUARTILE=94
PERCENTILE=95
QUANTILE=96
DOT=97
MOMENT=98
ERF=99
ERFINV=100
ANY=101
ALL=102
EDGE=103
GAUSSIAN=104
MEDIAN=105
MODE=106
CUMSUM=107
CUMPROD=108
TOPK_IND=109
BOTK_IND=110
CUBIC_EASE=111
ELASTIC_EASE=112
SINE_EASE=113
SMOOTHERSTEP=114
DIST=115
REMAP=116
COSSIM=117
COUNT=118
KEYS=119
ENABLE_TRACKING=120
DISABLE_TRACKING=121
RESET_TRACKING=122
GET_CHANGED_KEYS=123
GET_ADDED_KEYS=124
GET_REMOVED_KEYS=125
GET_UNCHANGED_KEYS=126
REPEAT=127
FLATTEN=128
APPEND=129
GET_VALUE=130
FLOW_APPLY=131
BATCH_SHUFFLE=132
MOTION_MASK=133
FLOW_TO_IMAGE=134
FLOW_MAG=135
FLOW_ANG=136
WHERE=137
HISTOGRAM=138
OVERLAY=139
PAD=140
CROSS=141
MATMUL=142
SOLVE=143
MATRIX_RANK=144
RIFE=145
BNOT=146
BITCOUNT=147
SHAPE=148
BAND=149
XOR=150
BOR=151
TENSOR=152
ZEROS=153
ONES=154
EYE=155
ONE_HOT=156
MSE=157
MAE=158
PSNR=159
WEIGHTED_MEAN=160
HUBER_LOSS=161
CROSS_ENTROPY=162
ADD_KEY=163
REMOVE_KEY=164
PUSH=165
POP=166
CLEAR=167
HAS=168
GET=169
CONCAT=170
STACK=171
NONZERO=172
INT=173
FLOAT=174
UPPER=175
LOWER=176
TRIM=177
SPLIT=178
JOIN=179
SUBSTRING=180
FIND=181
REPLACE=182
DILATE=183
ERODE=184
MORPH_OPEN=185
MORPH_CLOSE=186
RGB_TO_OKLAB=187
RGB_TO_CIELAB=188
OKLAB_TO_RGB=189
CIELAB_TO_RGB=190
RGB_TO_HSV=191
HSV_TO_RGB=192
INT_TO_RGB=193
RGB_TO_INT=194
INTERPOLATE_LINEAR=195
INTERPOLATE_AREA=196
INTERPOLATE_NEAREST=197
TEXT_IMAGE=198
AS_NESTED=199
SVD=200
DIAG=201
IF=202
ELSE=203
WHILE=204
FOR=205
IN=206
BREAK=207
CONTINUE=208
RETURN=209
TIMESTAMP=210
SORT=211
ARGSORT=212
ARGMIN=213
ARGMAX=214
SOFTMAX=215
SOFTMIN=216
UNIQUE=217
FLIP=218
STARTSWITH=219
ENDSWITH=220
SQUEEZE=221
UNSQUEEZE=222
ROLL=223
COV=224
CORR=225
ENTROPY=226
CROP=227
NONE=228
COORDS=229
GATHER=230
SCATTER=231
SCATTER_ADD=232
NOISE=233
PINK_NOISE=234
BROWN_NOISE=235
RAND=236
CAUCHY=237
EXPONENTIAL=238
LOGNORMAL=239
BERNOULLI=240
POISSON=241
GAMMADIST=242
BETADIST=243
LAPLACEDIST=244
GUMBELDIST=245
WEIBULLDIST=246
CHI2DIST=247
STUDENTTDIST=248
PERLIN=249
CELLULAR=250
PLASMA=251
RIDGED=252
DOMAIN_WARP=253
PLUS=254
MINUS=255
MULT=256
DIV=257
MOD=258
POW=259
LSHIFT=260
RSHIFT=261
GE=262
GT=263
LE=264
LT=265
EQ=266
EQUEALS=267
PLUS_EQ=268
MINUS_EQ=269
MULT_EQ=270
DIV_EQ=271
MOD_EQ=272
NE=273
PIPE=274
LPAREN=275
RPAREN=276
COMMA=277
SEMICOLON=278
ARROW=279
LBRACKET=280
RBRACKET=281
QUESTION=282
COLON=283
LBRACE=284
RBRACE=285
NUMBER=286
CONSTANT=287
STRING=288
VARIABLE=289
SL_COMMENT=290
ML_COMMENT=291
WS=292
'sin'=1
'cos'=2
'tan'=3
@@ -315,193 +317,195 @@ WS=290
'logsumexp'=25
'norm'=26
'normalize'=27
'outer'=28
'trace'=29
'det'=30
'rfft'=31
'irfft'=32
'isnan'=33
'isinf'=34
'isfinite'=35
'smin'=36
'smax'=37
'tmin'=38
'tmax'=39
'tnorm'=40
'snorm'=41
'floor'=42
'ceil'=43
'round'=44
'gamma'=45
'pow'=46
'sigm'=47
'clamp'=48
'fft'=49
'ifft'=50
'angle'=51
'print'=52
'lerp'=55
'step'=56
'smoothstep'=57
'fract'=58
'relu'=59
'softsign'=60
'leaky_relu'=61
'softplus'=62
'gelu'=63
'sign'=64
'degrees'=65
'radians'=66
'logical_not'=67
'logical_and'=68
'logical_or'=69
'hypot'=70
'map'=71
'swap'=74
'range'=78
'linspace'=79
'logspace'=80
'topk'=81
'botk'=82
'pinv'=83
'inv'=84
'sum'=85
'mean'=86
'std'=87
'var'=88
'prod'=89
'isclose'=90
'allclose'=91
'quantile'=94
'dot'=95
'moment'=96
'erf'=97
'erfinv'=98
'any'=99
'all'=100
'edge'=101
'median'=103
'mode'=104
'cumsum'=105
'cumprod'=106
'smootherstep'=112
'remap'=114
'keys'=117
'repeat'=125
'flatten'=126
'append'=127
'get_value'=128
'flow_apply'=129
'motion_mask'=131
'flow_to_image'=132
'where'=135
'overlay'=137
'pad'=138
'cross'=139
'matmul'=140
'solve'=141
'matrix_rank'=142
'rife'=143
'shape'=146
'tensor'=150
'zeros'=151
'ones'=152
'eye'=153
'one_hot'=154
'mse'=155
'mae'=156
'psnr'=157
'weighted_mean'=158
'huber_loss'=159
'cross_entropy'=160
'add_key'=161
'stack_push'=163
'stack_pop'=164
'stack_clear'=165
'stack_has'=166
'stack_get'=167
'stack'=169
'nonzero'=170
'int'=171
'float'=172
'upper'=173
'lower'=174
'trim'=175
'split'=176
'join'=177
'find'=179
'replace'=180
'dilate'=181
'erode'=182
'morph_open'=183
'morph_close'=184
'rgb_to_oklab'=185
'rgb_to_cielab'=186
'oklab_to_rgb'=187
'cielab_to_rgb'=188
'rgb_to_hsv'=189
'hsv_to_rgb'=190
'int_to_rgb'=191
'rgb_to_int'=192
'interpolate_linear'=193
'interpolate_area'=194
'text_image'=196
'if'=200
'else'=201
'while'=202
'for'=203
'in'=204
'break'=205
'continue'=206
'return'=207
'sort'=209
'argsort'=210
'argmin'=211
'argmax'=212
'softmax'=213
'softmin'=214
'unique'=215
'flip'=216
'startswith'=217
'endswith'=218
'squeeze'=219
'unsqueeze'=220
'roll'=221
'cov'=222
'entropy'=224
'crop'=225
'gather'=228
'scatter'=229
'scatter_add'=230
'+'=252
'-'=253
'*'=254
'/'=255
'%'=256
'^'=257
'<<'=258
'>>'=259
'>='=260
'>'=261
'<='=262
'<'=263
'=='=264
'='=265
'+='=266
'-='=267
'*='=268
'/='=269
'%='=270
'!='=271
'|'=272
'('=273
')'=274
','=275
';'=276
'->'=277
'['=278
']'=279
'?'=280
':'=281
'{'=282
'}'=283
'group_norm'=28
'outer'=29
'trace'=30
'det'=31
'rfft'=32
'irfft'=33
'isnan'=34
'isinf'=35
'isfinite'=36
'smin'=37
'smax'=38
'tmin'=39
'tmax'=40
'tnorm'=41
'snorm'=42
'floor'=43
'ceil'=44
'round'=45
'gamma'=46
'pow'=47
'sigm'=48
'clamp'=49
'fft'=50
'ifft'=51
'angle'=52
'print'=53
'lerp'=56
'step'=57
'smoothstep'=58
'fract'=59
'relu'=60
'softsign'=61
'leaky_relu'=62
'softplus'=63
'gelu'=64
'silu'=65
'sign'=66
'degrees'=67
'radians'=68
'logical_not'=69
'logical_and'=70
'logical_or'=71
'hypot'=72
'map'=73
'swap'=76
'range'=80
'linspace'=81
'logspace'=82
'topk'=83
'botk'=84
'pinv'=85
'inv'=86
'sum'=87
'mean'=88
'std'=89
'var'=90
'prod'=91
'isclose'=92
'allclose'=93
'quantile'=96
'dot'=97
'moment'=98
'erf'=99
'erfinv'=100
'any'=101
'all'=102
'edge'=103
'median'=105
'mode'=106
'cumsum'=107
'cumprod'=108
'smootherstep'=114
'remap'=116
'keys'=119
'repeat'=127
'flatten'=128
'append'=129
'get_value'=130
'flow_apply'=131
'motion_mask'=133
'flow_to_image'=134
'where'=137
'overlay'=139
'pad'=140
'cross'=141
'matmul'=142
'solve'=143
'matrix_rank'=144
'rife'=145
'shape'=148
'tensor'=152
'zeros'=153
'ones'=154
'eye'=155
'one_hot'=156
'mse'=157
'mae'=158
'psnr'=159
'weighted_mean'=160
'huber_loss'=161
'cross_entropy'=162
'add_key'=163
'stack_push'=165
'stack_pop'=166
'stack_clear'=167
'stack_has'=168
'stack_get'=169
'stack'=171
'nonzero'=172
'int'=173
'float'=174
'upper'=175
'lower'=176
'trim'=177
'split'=178
'join'=179
'find'=181
'replace'=182
'dilate'=183
'erode'=184
'morph_open'=185
'morph_close'=186
'rgb_to_oklab'=187
'rgb_to_cielab'=188
'oklab_to_rgb'=189
'cielab_to_rgb'=190
'rgb_to_hsv'=191
'hsv_to_rgb'=192
'int_to_rgb'=193
'rgb_to_int'=194
'interpolate_linear'=195
'interpolate_area'=196
'text_image'=198
'if'=202
'else'=203
'while'=204
'for'=205
'in'=206
'break'=207
'continue'=208
'return'=209
'sort'=211
'argsort'=212
'argmin'=213
'argmax'=214
'softmax'=215
'softmin'=216
'unique'=217
'flip'=218
'startswith'=219
'endswith'=220
'squeeze'=221
'unsqueeze'=222
'roll'=223
'cov'=224
'entropy'=226
'crop'=227
'gather'=230
'scatter'=231
'scatter_add'=232
'+'=254
'-'=255
'*'=256
'/'=257
'%'=258
'^'=259
'<<'=260
'>>'=261
'>='=262
'>'=263
'<='=264
'<'=265
'=='=266
'='=267
'+='=268
'-='=269
'*='=270
'/='=271
'%='=272
'!='=273
'|'=274
'('=275
')'=276
','=277
';'=278
'->'=279
'['=280
']'=281
'?'=282
':'=283
'{'=284
'}'=285
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
+457 -453
View File
@@ -25,269 +25,271 @@ LOGADDEXP=24
LOGSUMEXP=25
NORM=26
NORMALIZE=27
OUTER=28
TRACE=29
DET=30
RFFT=31
IRFFT=32
ISNAN=33
ISINF=34
ISFINITE=35
SMIN=36
SMAX=37
TMIN=38
TMAX=39
TNORM=40
SNORM=41
FLOOR=42
CEIL=43
ROUND=44
GAMMA=45
POWE=46
SIGM=47
CLAMP=48
SFFT=49
SIFFT=50
ANGL=51
PRNT=52
PRINT_SHAPE=53
NVL=54
LERP=55
STEP=56
SMOOTHSTEP=57
FRACT=58
RELU=59
SOFTSIGN=60
LEAKY_RELU=61
SOFTPLUS=62
GELU=63
SIGN=64
DEGREES=65
RADIANS=66
LOGICAL_NOT=67
LOGICAL_AND=68
LOGICAL_OR=69
HYPOT=70
MAP=71
EZCONV=72
CONV=73
SWAP=74
TRANSPOSE=75
PERM=76
RESHAPE=77
RANGE=78
LINSPACE=79
LOGSPACE=80
TOPK=81
BOTK=82
PINV=83
INV=84
SUM=85
MEAN=86
STD=87
VAR=88
PROD=89
ISCLOSE=90
ALLCLOSE=91
QUARTILE=92
PERCENTILE=93
QUANTILE=94
DOT=95
MOMENT=96
ERF=97
ERFINV=98
ANY=99
ALL=100
EDGE=101
GAUSSIAN=102
MEDIAN=103
MODE=104
CUMSUM=105
CUMPROD=106
TOPK_IND=107
BOTK_IND=108
CUBIC_EASE=109
ELASTIC_EASE=110
SINE_EASE=111
SMOOTHERSTEP=112
DIST=113
REMAP=114
COSSIM=115
COUNT=116
KEYS=117
ENABLE_TRACKING=118
DISABLE_TRACKING=119
RESET_TRACKING=120
GET_CHANGED_KEYS=121
GET_ADDED_KEYS=122
GET_REMOVED_KEYS=123
GET_UNCHANGED_KEYS=124
REPEAT=125
FLATTEN=126
APPEND=127
GET_VALUE=128
FLOW_APPLY=129
BATCH_SHUFFLE=130
MOTION_MASK=131
FLOW_TO_IMAGE=132
FLOW_MAG=133
FLOW_ANG=134
WHERE=135
HISTOGRAM=136
OVERLAY=137
PAD=138
CROSS=139
MATMUL=140
SOLVE=141
MATRIX_RANK=142
RIFE=143
BNOT=144
BITCOUNT=145
SHAPE=146
BAND=147
XOR=148
BOR=149
TENSOR=150
ZEROS=151
ONES=152
EYE=153
ONE_HOT=154
MSE=155
MAE=156
PSNR=157
WEIGHTED_MEAN=158
HUBER_LOSS=159
CROSS_ENTROPY=160
ADD_KEY=161
REMOVE_KEY=162
PUSH=163
POP=164
CLEAR=165
HAS=166
GET=167
CONCAT=168
STACK=169
NONZERO=170
INT=171
FLOAT=172
UPPER=173
LOWER=174
TRIM=175
SPLIT=176
JOIN=177
SUBSTRING=178
FIND=179
REPLACE=180
DILATE=181
ERODE=182
MORPH_OPEN=183
MORPH_CLOSE=184
RGB_TO_OKLAB=185
RGB_TO_CIELAB=186
OKLAB_TO_RGB=187
CIELAB_TO_RGB=188
RGB_TO_HSV=189
HSV_TO_RGB=190
INT_TO_RGB=191
RGB_TO_INT=192
INTERPOLATE_LINEAR=193
INTERPOLATE_AREA=194
INTERPOLATE_NEAREST=195
TEXT_IMAGE=196
AS_NESTED=197
SVD=198
DIAG=199
IF=200
ELSE=201
WHILE=202
FOR=203
IN=204
BREAK=205
CONTINUE=206
RETURN=207
TIMESTAMP=208
SORT=209
ARGSORT=210
ARGMIN=211
ARGMAX=212
SOFTMAX=213
SOFTMIN=214
UNIQUE=215
FLIP=216
STARTSWITH=217
ENDSWITH=218
SQUEEZE=219
UNSQUEEZE=220
ROLL=221
COV=222
CORR=223
ENTROPY=224
CROP=225
NONE=226
COORDS=227
GATHER=228
SCATTER=229
SCATTER_ADD=230
NOISE=231
PINK_NOISE=232
BROWN_NOISE=233
RAND=234
CAUCHY=235
EXPONENTIAL=236
LOGNORMAL=237
BERNOULLI=238
POISSON=239
GAMMADIST=240
BETADIST=241
LAPLACEDIST=242
GUMBELDIST=243
WEIBULLDIST=244
CHI2DIST=245
STUDENTTDIST=246
PERLIN=247
CELLULAR=248
PLASMA=249
RIDGED=250
DOMAIN_WARP=251
PLUS=252
MINUS=253
MULT=254
DIV=255
MOD=256
POW=257
LSHIFT=258
RSHIFT=259
GE=260
GT=261
LE=262
LT=263
EQ=264
EQUEALS=265
PLUS_EQ=266
MINUS_EQ=267
MULT_EQ=268
DIV_EQ=269
MOD_EQ=270
NE=271
PIPE=272
LPAREN=273
RPAREN=274
COMMA=275
SEMICOLON=276
ARROW=277
LBRACKET=278
RBRACKET=279
QUESTION=280
COLON=281
LBRACE=282
RBRACE=283
NUMBER=284
CONSTANT=285
STRING=286
VARIABLE=287
SL_COMMENT=288
ML_COMMENT=289
WS=290
GROUP_NORM=28
OUTER=29
TRACE=30
DET=31
RFFT=32
IRFFT=33
ISNAN=34
ISINF=35
ISFINITE=36
SMIN=37
SMAX=38
TMIN=39
TMAX=40
TNORM=41
SNORM=42
FLOOR=43
CEIL=44
ROUND=45
GAMMA=46
POWE=47
SIGM=48
CLAMP=49
SFFT=50
SIFFT=51
ANGL=52
PRNT=53
PRINT_SHAPE=54
NVL=55
LERP=56
STEP=57
SMOOTHSTEP=58
FRACT=59
RELU=60
SOFTSIGN=61
LEAKY_RELU=62
SOFTPLUS=63
GELU=64
SILU=65
SIGN=66
DEGREES=67
RADIANS=68
LOGICAL_NOT=69
LOGICAL_AND=70
LOGICAL_OR=71
HYPOT=72
MAP=73
EZCONV=74
CONV=75
SWAP=76
TRANSPOSE=77
PERM=78
RESHAPE=79
RANGE=80
LINSPACE=81
LOGSPACE=82
TOPK=83
BOTK=84
PINV=85
INV=86
SUM=87
MEAN=88
STD=89
VAR=90
PROD=91
ISCLOSE=92
ALLCLOSE=93
QUARTILE=94
PERCENTILE=95
QUANTILE=96
DOT=97
MOMENT=98
ERF=99
ERFINV=100
ANY=101
ALL=102
EDGE=103
GAUSSIAN=104
MEDIAN=105
MODE=106
CUMSUM=107
CUMPROD=108
TOPK_IND=109
BOTK_IND=110
CUBIC_EASE=111
ELASTIC_EASE=112
SINE_EASE=113
SMOOTHERSTEP=114
DIST=115
REMAP=116
COSSIM=117
COUNT=118
KEYS=119
ENABLE_TRACKING=120
DISABLE_TRACKING=121
RESET_TRACKING=122
GET_CHANGED_KEYS=123
GET_ADDED_KEYS=124
GET_REMOVED_KEYS=125
GET_UNCHANGED_KEYS=126
REPEAT=127
FLATTEN=128
APPEND=129
GET_VALUE=130
FLOW_APPLY=131
BATCH_SHUFFLE=132
MOTION_MASK=133
FLOW_TO_IMAGE=134
FLOW_MAG=135
FLOW_ANG=136
WHERE=137
HISTOGRAM=138
OVERLAY=139
PAD=140
CROSS=141
MATMUL=142
SOLVE=143
MATRIX_RANK=144
RIFE=145
BNOT=146
BITCOUNT=147
SHAPE=148
BAND=149
XOR=150
BOR=151
TENSOR=152
ZEROS=153
ONES=154
EYE=155
ONE_HOT=156
MSE=157
MAE=158
PSNR=159
WEIGHTED_MEAN=160
HUBER_LOSS=161
CROSS_ENTROPY=162
ADD_KEY=163
REMOVE_KEY=164
PUSH=165
POP=166
CLEAR=167
HAS=168
GET=169
CONCAT=170
STACK=171
NONZERO=172
INT=173
FLOAT=174
UPPER=175
LOWER=176
TRIM=177
SPLIT=178
JOIN=179
SUBSTRING=180
FIND=181
REPLACE=182
DILATE=183
ERODE=184
MORPH_OPEN=185
MORPH_CLOSE=186
RGB_TO_OKLAB=187
RGB_TO_CIELAB=188
OKLAB_TO_RGB=189
CIELAB_TO_RGB=190
RGB_TO_HSV=191
HSV_TO_RGB=192
INT_TO_RGB=193
RGB_TO_INT=194
INTERPOLATE_LINEAR=195
INTERPOLATE_AREA=196
INTERPOLATE_NEAREST=197
TEXT_IMAGE=198
AS_NESTED=199
SVD=200
DIAG=201
IF=202
ELSE=203
WHILE=204
FOR=205
IN=206
BREAK=207
CONTINUE=208
RETURN=209
TIMESTAMP=210
SORT=211
ARGSORT=212
ARGMIN=213
ARGMAX=214
SOFTMAX=215
SOFTMIN=216
UNIQUE=217
FLIP=218
STARTSWITH=219
ENDSWITH=220
SQUEEZE=221
UNSQUEEZE=222
ROLL=223
COV=224
CORR=225
ENTROPY=226
CROP=227
NONE=228
COORDS=229
GATHER=230
SCATTER=231
SCATTER_ADD=232
NOISE=233
PINK_NOISE=234
BROWN_NOISE=235
RAND=236
CAUCHY=237
EXPONENTIAL=238
LOGNORMAL=239
BERNOULLI=240
POISSON=241
GAMMADIST=242
BETADIST=243
LAPLACEDIST=244
GUMBELDIST=245
WEIBULLDIST=246
CHI2DIST=247
STUDENTTDIST=248
PERLIN=249
CELLULAR=250
PLASMA=251
RIDGED=252
DOMAIN_WARP=253
PLUS=254
MINUS=255
MULT=256
DIV=257
MOD=258
POW=259
LSHIFT=260
RSHIFT=261
GE=262
GT=263
LE=264
LT=265
EQ=266
EQUEALS=267
PLUS_EQ=268
MINUS_EQ=269
MULT_EQ=270
DIV_EQ=271
MOD_EQ=272
NE=273
PIPE=274
LPAREN=275
RPAREN=276
COMMA=277
SEMICOLON=278
ARROW=279
LBRACKET=280
RBRACKET=281
QUESTION=282
COLON=283
LBRACE=284
RBRACE=285
NUMBER=286
CONSTANT=287
STRING=288
VARIABLE=289
SL_COMMENT=290
ML_COMMENT=291
WS=292
'sin'=1
'cos'=2
'tan'=3
@@ -315,193 +317,195 @@ WS=290
'logsumexp'=25
'norm'=26
'normalize'=27
'outer'=28
'trace'=29
'det'=30
'rfft'=31
'irfft'=32
'isnan'=33
'isinf'=34
'isfinite'=35
'smin'=36
'smax'=37
'tmin'=38
'tmax'=39
'tnorm'=40
'snorm'=41
'floor'=42
'ceil'=43
'round'=44
'gamma'=45
'pow'=46
'sigm'=47
'clamp'=48
'fft'=49
'ifft'=50
'angle'=51
'print'=52
'lerp'=55
'step'=56
'smoothstep'=57
'fract'=58
'relu'=59
'softsign'=60
'leaky_relu'=61
'softplus'=62
'gelu'=63
'sign'=64
'degrees'=65
'radians'=66
'logical_not'=67
'logical_and'=68
'logical_or'=69
'hypot'=70
'map'=71
'swap'=74
'range'=78
'linspace'=79
'logspace'=80
'topk'=81
'botk'=82
'pinv'=83
'inv'=84
'sum'=85
'mean'=86
'std'=87
'var'=88
'prod'=89
'isclose'=90
'allclose'=91
'quantile'=94
'dot'=95
'moment'=96
'erf'=97
'erfinv'=98
'any'=99
'all'=100
'edge'=101
'median'=103
'mode'=104
'cumsum'=105
'cumprod'=106
'smootherstep'=112
'remap'=114
'keys'=117
'repeat'=125
'flatten'=126
'append'=127
'get_value'=128
'flow_apply'=129
'motion_mask'=131
'flow_to_image'=132
'where'=135
'overlay'=137
'pad'=138
'cross'=139
'matmul'=140
'solve'=141
'matrix_rank'=142
'rife'=143
'shape'=146
'tensor'=150
'zeros'=151
'ones'=152
'eye'=153
'one_hot'=154
'mse'=155
'mae'=156
'psnr'=157
'weighted_mean'=158
'huber_loss'=159
'cross_entropy'=160
'add_key'=161
'stack_push'=163
'stack_pop'=164
'stack_clear'=165
'stack_has'=166
'stack_get'=167
'stack'=169
'nonzero'=170
'int'=171
'float'=172
'upper'=173
'lower'=174
'trim'=175
'split'=176
'join'=177
'find'=179
'replace'=180
'dilate'=181
'erode'=182
'morph_open'=183
'morph_close'=184
'rgb_to_oklab'=185
'rgb_to_cielab'=186
'oklab_to_rgb'=187
'cielab_to_rgb'=188
'rgb_to_hsv'=189
'hsv_to_rgb'=190
'int_to_rgb'=191
'rgb_to_int'=192
'interpolate_linear'=193
'interpolate_area'=194
'text_image'=196
'if'=200
'else'=201
'while'=202
'for'=203
'in'=204
'break'=205
'continue'=206
'return'=207
'sort'=209
'argsort'=210
'argmin'=211
'argmax'=212
'softmax'=213
'softmin'=214
'unique'=215
'flip'=216
'startswith'=217
'endswith'=218
'squeeze'=219
'unsqueeze'=220
'roll'=221
'cov'=222
'entropy'=224
'crop'=225
'gather'=228
'scatter'=229
'scatter_add'=230
'+'=252
'-'=253
'*'=254
'/'=255
'%'=256
'^'=257
'<<'=258
'>>'=259
'>='=260
'>'=261
'<='=262
'<'=263
'=='=264
'='=265
'+='=266
'-='=267
'*='=268
'/='=269
'%='=270
'!='=271
'|'=272
'('=273
')'=274
','=275
';'=276
'->'=277
'['=278
']'=279
'?'=280
':'=281
'{'=282
'}'=283
'group_norm'=28
'outer'=29
'trace'=30
'det'=31
'rfft'=32
'irfft'=33
'isnan'=34
'isinf'=35
'isfinite'=36
'smin'=37
'smax'=38
'tmin'=39
'tmax'=40
'tnorm'=41
'snorm'=42
'floor'=43
'ceil'=44
'round'=45
'gamma'=46
'pow'=47
'sigm'=48
'clamp'=49
'fft'=50
'ifft'=51
'angle'=52
'print'=53
'lerp'=56
'step'=57
'smoothstep'=58
'fract'=59
'relu'=60
'softsign'=61
'leaky_relu'=62
'softplus'=63
'gelu'=64
'silu'=65
'sign'=66
'degrees'=67
'radians'=68
'logical_not'=69
'logical_and'=70
'logical_or'=71
'hypot'=72
'map'=73
'swap'=76
'range'=80
'linspace'=81
'logspace'=82
'topk'=83
'botk'=84
'pinv'=85
'inv'=86
'sum'=87
'mean'=88
'std'=89
'var'=90
'prod'=91
'isclose'=92
'allclose'=93
'quantile'=96
'dot'=97
'moment'=98
'erf'=99
'erfinv'=100
'any'=101
'all'=102
'edge'=103
'median'=105
'mode'=106
'cumsum'=107
'cumprod'=108
'smootherstep'=114
'remap'=116
'keys'=119
'repeat'=127
'flatten'=128
'append'=129
'get_value'=130
'flow_apply'=131
'motion_mask'=133
'flow_to_image'=134
'where'=137
'overlay'=139
'pad'=140
'cross'=141
'matmul'=142
'solve'=143
'matrix_rank'=144
'rife'=145
'shape'=148
'tensor'=152
'zeros'=153
'ones'=154
'eye'=155
'one_hot'=156
'mse'=157
'mae'=158
'psnr'=159
'weighted_mean'=160
'huber_loss'=161
'cross_entropy'=162
'add_key'=163
'stack_push'=165
'stack_pop'=166
'stack_clear'=167
'stack_has'=168
'stack_get'=169
'stack'=171
'nonzero'=172
'int'=173
'float'=174
'upper'=175
'lower'=176
'trim'=177
'split'=178
'join'=179
'find'=181
'replace'=182
'dilate'=183
'erode'=184
'morph_open'=185
'morph_close'=186
'rgb_to_oklab'=187
'rgb_to_cielab'=188
'oklab_to_rgb'=189
'cielab_to_rgb'=190
'rgb_to_hsv'=191
'hsv_to_rgb'=192
'int_to_rgb'=193
'rgb_to_int'=194
'interpolate_linear'=195
'interpolate_area'=196
'text_image'=198
'if'=202
'else'=203
'while'=204
'for'=205
'in'=206
'break'=207
'continue'=208
'return'=209
'sort'=211
'argsort'=212
'argmin'=213
'argmax'=214
'softmax'=215
'softmin'=216
'unique'=217
'flip'=218
'startswith'=219
'endswith'=220
'squeeze'=221
'unsqueeze'=222
'roll'=223
'cov'=224
'entropy'=226
'crop'=227
'gather'=230
'scatter'=231
'scatter_add'=232
'+'=254
'-'=255
'*'=256
'/'=257
'%'=258
'^'=259
'<<'=260
'>>'=261
'>='=262
'>'=263
'<='=264
'<'=265
'=='=266
'='=267
'+='=268
'-='=269
'*='=270
'/='=271
'%='=272
'!='=273
'|'=274
'('=275
')'=276
','=277
';'=278
'->'=279
'['=280
']'=281
'?'=282
':'=283
'{'=284
'}'=285
@@ -1079,6 +1079,15 @@ class MathExprListener(ParseTreeListener):
pass
# Enter a parse tree produced by MathExprParser#SiluFunc.
def enterSiluFunc(self, ctx:MathExprParser.SiluFuncContext):
pass
# Exit a parse tree produced by MathExprParser#SiluFunc.
def exitSiluFunc(self, ctx:MathExprParser.SiluFuncContext):
pass
# Enter a parse tree produced by MathExprParser#SignFunc.
def enterSignFunc(self, ctx:MathExprParser.SignFuncContext):
pass
@@ -2582,6 +2591,15 @@ class MathExprListener(ParseTreeListener):
pass
# Enter a parse tree produced by MathExprParser#GroupNormFunc.
def enterGroupNormFunc(self, ctx:MathExprParser.GroupNormFuncContext):
pass
# Exit a parse tree produced by MathExprParser#GroupNormFunc.
def exitGroupNormFunc(self, ctx:MathExprParser.GroupNormFuncContext):
pass
# Enter a parse tree produced by MathExprParser#SMinFunc.
def enterSMinFunc(self, ctx:MathExprParser.SMinFuncContext):
pass
File diff suppressed because it is too large Load Diff
@@ -604,6 +604,11 @@ class MathExprVisitor(ParseTreeVisitor):
return self.visitChildren(ctx)
# Visit a parse tree produced by MathExprParser#SiluFunc.
def visitSiluFunc(self, ctx:MathExprParser.SiluFuncContext):
return self.visitChildren(ctx)
# Visit a parse tree produced by MathExprParser#SignFunc.
def visitSignFunc(self, ctx:MathExprParser.SignFuncContext):
return self.visitChildren(ctx)
@@ -1439,6 +1444,11 @@ class MathExprVisitor(ParseTreeVisitor):
return self.visitChildren(ctx)
# Visit a parse tree produced by MathExprParser#GroupNormFunc.
def visitGroupNormFunc(self, ctx:MathExprParser.GroupNormFuncContext):
return self.visitChildren(ctx)
# Visit a parse tree produced by MathExprParser#SMinFunc.
def visitSMinFunc(self, ctx:MathExprParser.SMinFuncContext):
return self.visitChildren(ctx)
+3 -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', 'brown', 'brown_noise', 'bxor', 'cat', 'cbrt', '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', 'cross_entropy', 'cubic', 'cubic_ease', 'cumprod', 'cumsum', 'degrees', 'det', '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', 'eye', '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', 'huber_loss', 'hypot', 'changed_keys', 'ifft', 'int', 'int_to_rgb', 'interpolate_area', 'interpolate_linear', 'interpolate_nearest', 'interpolate_nearest_exact', 'inv', 'irfft', 'isclose', 'isfinite', 'isinf', 'isnan', 'join', 'keys', 'leaky_relu', 'length', 'lerp', 'linspace', 'ln', 'log', 'log1p', 'log2', 'logaddexp', 'logical_and', 'logical_not', 'logical_or', 'logspace', 'logsumexp', 'lower', 'mae', 'map', 'matmul', 'matrix_rank', 'mean', 'median', 'mode', 'moment', 'morph_close', 'morph_open', 'motion_mask', 'mse', 'nan_to_num', 'noise', 'nonzero', 'norm', 'normalize', 'now', 'nvl', 'oklab_to_rgb', 'one_hot', 'ones', 'outer', 'overlay', 'pad', 'percentile', 'perlin', 'perlin_noise', 'perm', 'permute', 'pink', 'pink_noise', 'pinv', 'plasma', 'plasma_noise', 'popcnt', 'popcount', 'pow', 'prcnt', 'print', 'print_shape', 'prod', 'pshp', 'psnr', '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', 'reciprocal', 'relu', 'remap', 'remove_key', 'removed_keys', 'repeat', 'replace', 'reset_tracking', 'reshape', 'rfft', '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', 'softsign', 'solve', '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', 'trace', 'track_off', 'track_on', 'track_reset', 'transpose', 'trim', 'turbulence', 'unchanged_keys', 'unique', 'unsqueeze', 'upper', 'var', 'voronoi', 'voronoi_noise', 'weighted_mean', 'where', 'worley', 'zeros'
'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', 'brown', 'brown_noise', 'bxor', 'cat', 'cbrt', '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', 'cross_entropy', 'cubic', 'cubic_ease', 'cumprod', 'cumsum', 'degrees', 'det', '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', 'eye', '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', 'group_norm', 'hist', 'histogram', 'hsv_to_rgb', 'huber_loss', 'hypot', 'changed_keys', 'ifft', 'int', 'int_to_rgb', 'interpolate_area', 'interpolate_linear', 'interpolate_nearest', 'interpolate_nearest_exact', 'inv', 'irfft', 'isclose', 'isfinite', 'isinf', 'isnan', 'join', 'keys', 'leaky_relu', 'length', 'lerp', 'linspace', 'ln', 'log', 'log1p', 'log2', 'logaddexp', 'logical_and', 'logical_not', 'logical_or', 'logspace', 'logsumexp', 'lower', 'mae', 'map', 'matmul', 'matrix_rank', 'mean', 'median', 'mode', 'moment', 'morph_close', 'morph_open', 'motion_mask', 'mse', 'nan_to_num', 'noise', 'nonzero', 'norm', 'normalize', 'now', 'nvl', 'oklab_to_rgb', 'one_hot', 'ones', 'outer', 'overlay', 'pad', 'percentile', 'perlin', 'perlin_noise', 'perm', 'permute', 'pink', 'pink_noise', 'pinv', 'plasma', 'plasma_noise', 'popcnt', 'popcount', 'pow', 'prcnt', 'print', 'print_shape', 'prod', 'pshp', 'psnr', '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', 'reciprocal', 'relu', 'remap', 'remove_key', 'removed_keys', 'repeat', 'replace', 'reset_tracking', 'reshape', 'rfft', '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', 'silu', 'sin', 'sine', 'sine_ease', 'singular_value_decomposition', 'sinh', 'smax', 'smin', 'smootherstep', 'smoothstep', 'snorm', 'softmax', 'softmin', 'softplus', 'softsign', 'solve', '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', 'trace', 'track_off', 'track_on', 'track_reset', 'transpose', 'trim', 'turbulence', 'unchanged_keys', 'unique', 'unsqueeze', 'upper', 'var', 'voronoi', 'voronoi_noise', 'weighted_mean', 'where', 'worley', 'zeros'
}
INBUILT_FUNCTION_META = {
@@ -37,6 +37,7 @@ INBUILT_FUNCTION_META = {
'logsumexp': {'min_args': 1, 'max_args': 2, 'snippet': 'logsumexp(x, dims)', 'description': 'computes log(sum(exp(x))) stably, optionally reducing along one or more dimensions'},
'norm': {'min_args': 1, 'max_args': 3, 'snippet': 'norm(x, p, dims)', 'description': 'computes the p-norm globally or along one or more dimensions (default p=2)'},
'normalize': {'min_args': 1, 'max_args': 4, 'snippet': 'normalize(x, p, dim, eps)', 'description': 'normalizes x along dim using the p-norm (defaults: p=2, dim=-1, eps=1e-12)'},
'group_norm': {'min_args': 2, 'max_args': 5, 'snippet': 'group_norm(x, groups, weight, bias, eps)', 'description': 'applies channel-first GroupNorm to [N, C, ...] input'},
'outer': {'min_args': 2, 'max_args': 2, 'snippet': 'outer(x, y)', 'description': 'computes the outer product of flattened x and y'},
'trace': {'min_args': 1, 'max_args': 1, 'snippet': 'trace(x)', 'description': 'sums the main diagonal of each square matrix in x'},
'det': {'min_args': 1, 'max_args': 1, 'snippet': 'det(x)', 'description': 'computes the determinant of each square matrix in x'},
@@ -75,6 +76,7 @@ INBUILT_FUNCTION_META = {
'leaky_relu': {'min_args': 1, 'max_args': 2, 'snippet': 'leaky_relu(x, negative_slope)', 'description': 'applies leaky ReLU element-wise; negative_slope defaults to 0.01'},
'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'},
'silu': {'min_args': 1, 'max_args': 1, 'snippet': 'silu(x)', 'description': 'applies the Sigmoid Linear Unit activation element-wise'},
'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)'},
File diff suppressed because one or more lines are too long
+457 -453
View File
@@ -25,269 +25,271 @@ LOGADDEXP=24
LOGSUMEXP=25
NORM=26
NORMALIZE=27
OUTER=28
TRACE=29
DET=30
RFFT=31
IRFFT=32
ISNAN=33
ISINF=34
ISFINITE=35
SMIN=36
SMAX=37
TMIN=38
TMAX=39
TNORM=40
SNORM=41
FLOOR=42
CEIL=43
ROUND=44
GAMMA=45
POWE=46
SIGM=47
CLAMP=48
SFFT=49
SIFFT=50
ANGL=51
PRNT=52
PRINT_SHAPE=53
NVL=54
LERP=55
STEP=56
SMOOTHSTEP=57
FRACT=58
RELU=59
SOFTSIGN=60
LEAKY_RELU=61
SOFTPLUS=62
GELU=63
SIGN=64
DEGREES=65
RADIANS=66
LOGICAL_NOT=67
LOGICAL_AND=68
LOGICAL_OR=69
HYPOT=70
MAP=71
EZCONV=72
CONV=73
SWAP=74
TRANSPOSE=75
PERM=76
RESHAPE=77
RANGE=78
LINSPACE=79
LOGSPACE=80
TOPK=81
BOTK=82
PINV=83
INV=84
SUM=85
MEAN=86
STD=87
VAR=88
PROD=89
ISCLOSE=90
ALLCLOSE=91
QUARTILE=92
PERCENTILE=93
QUANTILE=94
DOT=95
MOMENT=96
ERF=97
ERFINV=98
ANY=99
ALL=100
EDGE=101
GAUSSIAN=102
MEDIAN=103
MODE=104
CUMSUM=105
CUMPROD=106
TOPK_IND=107
BOTK_IND=108
CUBIC_EASE=109
ELASTIC_EASE=110
SINE_EASE=111
SMOOTHERSTEP=112
DIST=113
REMAP=114
COSSIM=115
COUNT=116
KEYS=117
ENABLE_TRACKING=118
DISABLE_TRACKING=119
RESET_TRACKING=120
GET_CHANGED_KEYS=121
GET_ADDED_KEYS=122
GET_REMOVED_KEYS=123
GET_UNCHANGED_KEYS=124
REPEAT=125
FLATTEN=126
APPEND=127
GET_VALUE=128
FLOW_APPLY=129
BATCH_SHUFFLE=130
MOTION_MASK=131
FLOW_TO_IMAGE=132
FLOW_MAG=133
FLOW_ANG=134
WHERE=135
HISTOGRAM=136
OVERLAY=137
PAD=138
CROSS=139
MATMUL=140
SOLVE=141
MATRIX_RANK=142
RIFE=143
BNOT=144
BITCOUNT=145
SHAPE=146
BAND=147
XOR=148
BOR=149
TENSOR=150
ZEROS=151
ONES=152
EYE=153
ONE_HOT=154
MSE=155
MAE=156
PSNR=157
WEIGHTED_MEAN=158
HUBER_LOSS=159
CROSS_ENTROPY=160
ADD_KEY=161
REMOVE_KEY=162
PUSH=163
POP=164
CLEAR=165
HAS=166
GET=167
CONCAT=168
STACK=169
NONZERO=170
INT=171
FLOAT=172
UPPER=173
LOWER=174
TRIM=175
SPLIT=176
JOIN=177
SUBSTRING=178
FIND=179
REPLACE=180
DILATE=181
ERODE=182
MORPH_OPEN=183
MORPH_CLOSE=184
RGB_TO_OKLAB=185
RGB_TO_CIELAB=186
OKLAB_TO_RGB=187
CIELAB_TO_RGB=188
RGB_TO_HSV=189
HSV_TO_RGB=190
INT_TO_RGB=191
RGB_TO_INT=192
INTERPOLATE_LINEAR=193
INTERPOLATE_AREA=194
INTERPOLATE_NEAREST=195
TEXT_IMAGE=196
AS_NESTED=197
SVD=198
DIAG=199
IF=200
ELSE=201
WHILE=202
FOR=203
IN=204
BREAK=205
CONTINUE=206
RETURN=207
TIMESTAMP=208
SORT=209
ARGSORT=210
ARGMIN=211
ARGMAX=212
SOFTMAX=213
SOFTMIN=214
UNIQUE=215
FLIP=216
STARTSWITH=217
ENDSWITH=218
SQUEEZE=219
UNSQUEEZE=220
ROLL=221
COV=222
CORR=223
ENTROPY=224
CROP=225
NONE=226
COORDS=227
GATHER=228
SCATTER=229
SCATTER_ADD=230
NOISE=231
PINK_NOISE=232
BROWN_NOISE=233
RAND=234
CAUCHY=235
EXPONENTIAL=236
LOGNORMAL=237
BERNOULLI=238
POISSON=239
GAMMADIST=240
BETADIST=241
LAPLACEDIST=242
GUMBELDIST=243
WEIBULLDIST=244
CHI2DIST=245
STUDENTTDIST=246
PERLIN=247
CELLULAR=248
PLASMA=249
RIDGED=250
DOMAIN_WARP=251
PLUS=252
MINUS=253
MULT=254
DIV=255
MOD=256
POW=257
LSHIFT=258
RSHIFT=259
GE=260
GT=261
LE=262
LT=263
EQ=264
EQUEALS=265
PLUS_EQ=266
MINUS_EQ=267
MULT_EQ=268
DIV_EQ=269
MOD_EQ=270
NE=271
PIPE=272
LPAREN=273
RPAREN=274
COMMA=275
SEMICOLON=276
ARROW=277
LBRACKET=278
RBRACKET=279
QUESTION=280
COLON=281
LBRACE=282
RBRACE=283
NUMBER=284
CONSTANT=285
STRING=286
VARIABLE=287
SL_COMMENT=288
ML_COMMENT=289
WS=290
GROUP_NORM=28
OUTER=29
TRACE=30
DET=31
RFFT=32
IRFFT=33
ISNAN=34
ISINF=35
ISFINITE=36
SMIN=37
SMAX=38
TMIN=39
TMAX=40
TNORM=41
SNORM=42
FLOOR=43
CEIL=44
ROUND=45
GAMMA=46
POWE=47
SIGM=48
CLAMP=49
SFFT=50
SIFFT=51
ANGL=52
PRNT=53
PRINT_SHAPE=54
NVL=55
LERP=56
STEP=57
SMOOTHSTEP=58
FRACT=59
RELU=60
SOFTSIGN=61
LEAKY_RELU=62
SOFTPLUS=63
GELU=64
SILU=65
SIGN=66
DEGREES=67
RADIANS=68
LOGICAL_NOT=69
LOGICAL_AND=70
LOGICAL_OR=71
HYPOT=72
MAP=73
EZCONV=74
CONV=75
SWAP=76
TRANSPOSE=77
PERM=78
RESHAPE=79
RANGE=80
LINSPACE=81
LOGSPACE=82
TOPK=83
BOTK=84
PINV=85
INV=86
SUM=87
MEAN=88
STD=89
VAR=90
PROD=91
ISCLOSE=92
ALLCLOSE=93
QUARTILE=94
PERCENTILE=95
QUANTILE=96
DOT=97
MOMENT=98
ERF=99
ERFINV=100
ANY=101
ALL=102
EDGE=103
GAUSSIAN=104
MEDIAN=105
MODE=106
CUMSUM=107
CUMPROD=108
TOPK_IND=109
BOTK_IND=110
CUBIC_EASE=111
ELASTIC_EASE=112
SINE_EASE=113
SMOOTHERSTEP=114
DIST=115
REMAP=116
COSSIM=117
COUNT=118
KEYS=119
ENABLE_TRACKING=120
DISABLE_TRACKING=121
RESET_TRACKING=122
GET_CHANGED_KEYS=123
GET_ADDED_KEYS=124
GET_REMOVED_KEYS=125
GET_UNCHANGED_KEYS=126
REPEAT=127
FLATTEN=128
APPEND=129
GET_VALUE=130
FLOW_APPLY=131
BATCH_SHUFFLE=132
MOTION_MASK=133
FLOW_TO_IMAGE=134
FLOW_MAG=135
FLOW_ANG=136
WHERE=137
HISTOGRAM=138
OVERLAY=139
PAD=140
CROSS=141
MATMUL=142
SOLVE=143
MATRIX_RANK=144
RIFE=145
BNOT=146
BITCOUNT=147
SHAPE=148
BAND=149
XOR=150
BOR=151
TENSOR=152
ZEROS=153
ONES=154
EYE=155
ONE_HOT=156
MSE=157
MAE=158
PSNR=159
WEIGHTED_MEAN=160
HUBER_LOSS=161
CROSS_ENTROPY=162
ADD_KEY=163
REMOVE_KEY=164
PUSH=165
POP=166
CLEAR=167
HAS=168
GET=169
CONCAT=170
STACK=171
NONZERO=172
INT=173
FLOAT=174
UPPER=175
LOWER=176
TRIM=177
SPLIT=178
JOIN=179
SUBSTRING=180
FIND=181
REPLACE=182
DILATE=183
ERODE=184
MORPH_OPEN=185
MORPH_CLOSE=186
RGB_TO_OKLAB=187
RGB_TO_CIELAB=188
OKLAB_TO_RGB=189
CIELAB_TO_RGB=190
RGB_TO_HSV=191
HSV_TO_RGB=192
INT_TO_RGB=193
RGB_TO_INT=194
INTERPOLATE_LINEAR=195
INTERPOLATE_AREA=196
INTERPOLATE_NEAREST=197
TEXT_IMAGE=198
AS_NESTED=199
SVD=200
DIAG=201
IF=202
ELSE=203
WHILE=204
FOR=205
IN=206
BREAK=207
CONTINUE=208
RETURN=209
TIMESTAMP=210
SORT=211
ARGSORT=212
ARGMIN=213
ARGMAX=214
SOFTMAX=215
SOFTMIN=216
UNIQUE=217
FLIP=218
STARTSWITH=219
ENDSWITH=220
SQUEEZE=221
UNSQUEEZE=222
ROLL=223
COV=224
CORR=225
ENTROPY=226
CROP=227
NONE=228
COORDS=229
GATHER=230
SCATTER=231
SCATTER_ADD=232
NOISE=233
PINK_NOISE=234
BROWN_NOISE=235
RAND=236
CAUCHY=237
EXPONENTIAL=238
LOGNORMAL=239
BERNOULLI=240
POISSON=241
GAMMADIST=242
BETADIST=243
LAPLACEDIST=244
GUMBELDIST=245
WEIBULLDIST=246
CHI2DIST=247
STUDENTTDIST=248
PERLIN=249
CELLULAR=250
PLASMA=251
RIDGED=252
DOMAIN_WARP=253
PLUS=254
MINUS=255
MULT=256
DIV=257
MOD=258
POW=259
LSHIFT=260
RSHIFT=261
GE=262
GT=263
LE=264
LT=265
EQ=266
EQUEALS=267
PLUS_EQ=268
MINUS_EQ=269
MULT_EQ=270
DIV_EQ=271
MOD_EQ=272
NE=273
PIPE=274
LPAREN=275
RPAREN=276
COMMA=277
SEMICOLON=278
ARROW=279
LBRACKET=280
RBRACKET=281
QUESTION=282
COLON=283
LBRACE=284
RBRACE=285
NUMBER=286
CONSTANT=287
STRING=288
VARIABLE=289
SL_COMMENT=290
ML_COMMENT=291
WS=292
'sin'=1
'cos'=2
'tan'=3
@@ -315,193 +317,195 @@ WS=290
'logsumexp'=25
'norm'=26
'normalize'=27
'outer'=28
'trace'=29
'det'=30
'rfft'=31
'irfft'=32
'isnan'=33
'isinf'=34
'isfinite'=35
'smin'=36
'smax'=37
'tmin'=38
'tmax'=39
'tnorm'=40
'snorm'=41
'floor'=42
'ceil'=43
'round'=44
'gamma'=45
'pow'=46
'sigm'=47
'clamp'=48
'fft'=49
'ifft'=50
'angle'=51
'print'=52
'lerp'=55
'step'=56
'smoothstep'=57
'fract'=58
'relu'=59
'softsign'=60
'leaky_relu'=61
'softplus'=62
'gelu'=63
'sign'=64
'degrees'=65
'radians'=66
'logical_not'=67
'logical_and'=68
'logical_or'=69
'hypot'=70
'map'=71
'swap'=74
'range'=78
'linspace'=79
'logspace'=80
'topk'=81
'botk'=82
'pinv'=83
'inv'=84
'sum'=85
'mean'=86
'std'=87
'var'=88
'prod'=89
'isclose'=90
'allclose'=91
'quantile'=94
'dot'=95
'moment'=96
'erf'=97
'erfinv'=98
'any'=99
'all'=100
'edge'=101
'median'=103
'mode'=104
'cumsum'=105
'cumprod'=106
'smootherstep'=112
'remap'=114
'keys'=117
'repeat'=125
'flatten'=126
'append'=127
'get_value'=128
'flow_apply'=129
'motion_mask'=131
'flow_to_image'=132
'where'=135
'overlay'=137
'pad'=138
'cross'=139
'matmul'=140
'solve'=141
'matrix_rank'=142
'rife'=143
'shape'=146
'tensor'=150
'zeros'=151
'ones'=152
'eye'=153
'one_hot'=154
'mse'=155
'mae'=156
'psnr'=157
'weighted_mean'=158
'huber_loss'=159
'cross_entropy'=160
'add_key'=161
'stack_push'=163
'stack_pop'=164
'stack_clear'=165
'stack_has'=166
'stack_get'=167
'stack'=169
'nonzero'=170
'int'=171
'float'=172
'upper'=173
'lower'=174
'trim'=175
'split'=176
'join'=177
'find'=179
'replace'=180
'dilate'=181
'erode'=182
'morph_open'=183
'morph_close'=184
'rgb_to_oklab'=185
'rgb_to_cielab'=186
'oklab_to_rgb'=187
'cielab_to_rgb'=188
'rgb_to_hsv'=189
'hsv_to_rgb'=190
'int_to_rgb'=191
'rgb_to_int'=192
'interpolate_linear'=193
'interpolate_area'=194
'text_image'=196
'if'=200
'else'=201
'while'=202
'for'=203
'in'=204
'break'=205
'continue'=206
'return'=207
'sort'=209
'argsort'=210
'argmin'=211
'argmax'=212
'softmax'=213
'softmin'=214
'unique'=215
'flip'=216
'startswith'=217
'endswith'=218
'squeeze'=219
'unsqueeze'=220
'roll'=221
'cov'=222
'entropy'=224
'crop'=225
'gather'=228
'scatter'=229
'scatter_add'=230
'+'=252
'-'=253
'*'=254
'/'=255
'%'=256
'^'=257
'<<'=258
'>>'=259
'>='=260
'>'=261
'<='=262
'<'=263
'=='=264
'='=265
'+='=266
'-='=267
'*='=268
'/='=269
'%='=270
'!='=271
'|'=272
'('=273
')'=274
','=275
';'=276
'->'=277
'['=278
']'=279
'?'=280
':'=281
'{'=282
'}'=283
'group_norm'=28
'outer'=29
'trace'=30
'det'=31
'rfft'=32
'irfft'=33
'isnan'=34
'isinf'=35
'isfinite'=36
'smin'=37
'smax'=38
'tmin'=39
'tmax'=40
'tnorm'=41
'snorm'=42
'floor'=43
'ceil'=44
'round'=45
'gamma'=46
'pow'=47
'sigm'=48
'clamp'=49
'fft'=50
'ifft'=51
'angle'=52
'print'=53
'lerp'=56
'step'=57
'smoothstep'=58
'fract'=59
'relu'=60
'softsign'=61
'leaky_relu'=62
'softplus'=63
'gelu'=64
'silu'=65
'sign'=66
'degrees'=67
'radians'=68
'logical_not'=69
'logical_and'=70
'logical_or'=71
'hypot'=72
'map'=73
'swap'=76
'range'=80
'linspace'=81
'logspace'=82
'topk'=83
'botk'=84
'pinv'=85
'inv'=86
'sum'=87
'mean'=88
'std'=89
'var'=90
'prod'=91
'isclose'=92
'allclose'=93
'quantile'=96
'dot'=97
'moment'=98
'erf'=99
'erfinv'=100
'any'=101
'all'=102
'edge'=103
'median'=105
'mode'=106
'cumsum'=107
'cumprod'=108
'smootherstep'=114
'remap'=116
'keys'=119
'repeat'=127
'flatten'=128
'append'=129
'get_value'=130
'flow_apply'=131
'motion_mask'=133
'flow_to_image'=134
'where'=137
'overlay'=139
'pad'=140
'cross'=141
'matmul'=142
'solve'=143
'matrix_rank'=144
'rife'=145
'shape'=148
'tensor'=152
'zeros'=153
'ones'=154
'eye'=155
'one_hot'=156
'mse'=157
'mae'=158
'psnr'=159
'weighted_mean'=160
'huber_loss'=161
'cross_entropy'=162
'add_key'=163
'stack_push'=165
'stack_pop'=166
'stack_clear'=167
'stack_has'=168
'stack_get'=169
'stack'=171
'nonzero'=172
'int'=173
'float'=174
'upper'=175
'lower'=176
'trim'=177
'split'=178
'join'=179
'find'=181
'replace'=182
'dilate'=183
'erode'=184
'morph_open'=185
'morph_close'=186
'rgb_to_oklab'=187
'rgb_to_cielab'=188
'oklab_to_rgb'=189
'cielab_to_rgb'=190
'rgb_to_hsv'=191
'hsv_to_rgb'=192
'int_to_rgb'=193
'rgb_to_int'=194
'interpolate_linear'=195
'interpolate_area'=196
'text_image'=198
'if'=202
'else'=203
'while'=204
'for'=205
'in'=206
'break'=207
'continue'=208
'return'=209
'sort'=211
'argsort'=212
'argmin'=213
'argmax'=214
'softmax'=215
'softmin'=216
'unique'=217
'flip'=218
'startswith'=219
'endswith'=220
'squeeze'=221
'unsqueeze'=222
'roll'=223
'cov'=224
'entropy'=226
'crop'=227
'gather'=230
'scatter'=231
'scatter_add'=232
'+'=254
'-'=255
'*'=256
'/'=257
'%'=258
'^'=259
'<<'=260
'>>'=261
'>='=262
'>'=263
'<='=264
'<'=265
'=='=266
'='=267
'+='=268
'-='=269
'*='=270
'/='=271
'%='=272
'!='=273
'|'=274
'('=275
')'=276
','=277
';'=278
'->'=279
'['=280
']'=281
'?'=282
':'=283
'{'=284
'}'=285
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
+457 -453
View File
@@ -25,269 +25,271 @@ LOGADDEXP=24
LOGSUMEXP=25
NORM=26
NORMALIZE=27
OUTER=28
TRACE=29
DET=30
RFFT=31
IRFFT=32
ISNAN=33
ISINF=34
ISFINITE=35
SMIN=36
SMAX=37
TMIN=38
TMAX=39
TNORM=40
SNORM=41
FLOOR=42
CEIL=43
ROUND=44
GAMMA=45
POWE=46
SIGM=47
CLAMP=48
SFFT=49
SIFFT=50
ANGL=51
PRNT=52
PRINT_SHAPE=53
NVL=54
LERP=55
STEP=56
SMOOTHSTEP=57
FRACT=58
RELU=59
SOFTSIGN=60
LEAKY_RELU=61
SOFTPLUS=62
GELU=63
SIGN=64
DEGREES=65
RADIANS=66
LOGICAL_NOT=67
LOGICAL_AND=68
LOGICAL_OR=69
HYPOT=70
MAP=71
EZCONV=72
CONV=73
SWAP=74
TRANSPOSE=75
PERM=76
RESHAPE=77
RANGE=78
LINSPACE=79
LOGSPACE=80
TOPK=81
BOTK=82
PINV=83
INV=84
SUM=85
MEAN=86
STD=87
VAR=88
PROD=89
ISCLOSE=90
ALLCLOSE=91
QUARTILE=92
PERCENTILE=93
QUANTILE=94
DOT=95
MOMENT=96
ERF=97
ERFINV=98
ANY=99
ALL=100
EDGE=101
GAUSSIAN=102
MEDIAN=103
MODE=104
CUMSUM=105
CUMPROD=106
TOPK_IND=107
BOTK_IND=108
CUBIC_EASE=109
ELASTIC_EASE=110
SINE_EASE=111
SMOOTHERSTEP=112
DIST=113
REMAP=114
COSSIM=115
COUNT=116
KEYS=117
ENABLE_TRACKING=118
DISABLE_TRACKING=119
RESET_TRACKING=120
GET_CHANGED_KEYS=121
GET_ADDED_KEYS=122
GET_REMOVED_KEYS=123
GET_UNCHANGED_KEYS=124
REPEAT=125
FLATTEN=126
APPEND=127
GET_VALUE=128
FLOW_APPLY=129
BATCH_SHUFFLE=130
MOTION_MASK=131
FLOW_TO_IMAGE=132
FLOW_MAG=133
FLOW_ANG=134
WHERE=135
HISTOGRAM=136
OVERLAY=137
PAD=138
CROSS=139
MATMUL=140
SOLVE=141
MATRIX_RANK=142
RIFE=143
BNOT=144
BITCOUNT=145
SHAPE=146
BAND=147
XOR=148
BOR=149
TENSOR=150
ZEROS=151
ONES=152
EYE=153
ONE_HOT=154
MSE=155
MAE=156
PSNR=157
WEIGHTED_MEAN=158
HUBER_LOSS=159
CROSS_ENTROPY=160
ADD_KEY=161
REMOVE_KEY=162
PUSH=163
POP=164
CLEAR=165
HAS=166
GET=167
CONCAT=168
STACK=169
NONZERO=170
INT=171
FLOAT=172
UPPER=173
LOWER=174
TRIM=175
SPLIT=176
JOIN=177
SUBSTRING=178
FIND=179
REPLACE=180
DILATE=181
ERODE=182
MORPH_OPEN=183
MORPH_CLOSE=184
RGB_TO_OKLAB=185
RGB_TO_CIELAB=186
OKLAB_TO_RGB=187
CIELAB_TO_RGB=188
RGB_TO_HSV=189
HSV_TO_RGB=190
INT_TO_RGB=191
RGB_TO_INT=192
INTERPOLATE_LINEAR=193
INTERPOLATE_AREA=194
INTERPOLATE_NEAREST=195
TEXT_IMAGE=196
AS_NESTED=197
SVD=198
DIAG=199
IF=200
ELSE=201
WHILE=202
FOR=203
IN=204
BREAK=205
CONTINUE=206
RETURN=207
TIMESTAMP=208
SORT=209
ARGSORT=210
ARGMIN=211
ARGMAX=212
SOFTMAX=213
SOFTMIN=214
UNIQUE=215
FLIP=216
STARTSWITH=217
ENDSWITH=218
SQUEEZE=219
UNSQUEEZE=220
ROLL=221
COV=222
CORR=223
ENTROPY=224
CROP=225
NONE=226
COORDS=227
GATHER=228
SCATTER=229
SCATTER_ADD=230
NOISE=231
PINK_NOISE=232
BROWN_NOISE=233
RAND=234
CAUCHY=235
EXPONENTIAL=236
LOGNORMAL=237
BERNOULLI=238
POISSON=239
GAMMADIST=240
BETADIST=241
LAPLACEDIST=242
GUMBELDIST=243
WEIBULLDIST=244
CHI2DIST=245
STUDENTTDIST=246
PERLIN=247
CELLULAR=248
PLASMA=249
RIDGED=250
DOMAIN_WARP=251
PLUS=252
MINUS=253
MULT=254
DIV=255
MOD=256
POW=257
LSHIFT=258
RSHIFT=259
GE=260
GT=261
LE=262
LT=263
EQ=264
EQUEALS=265
PLUS_EQ=266
MINUS_EQ=267
MULT_EQ=268
DIV_EQ=269
MOD_EQ=270
NE=271
PIPE=272
LPAREN=273
RPAREN=274
COMMA=275
SEMICOLON=276
ARROW=277
LBRACKET=278
RBRACKET=279
QUESTION=280
COLON=281
LBRACE=282
RBRACE=283
NUMBER=284
CONSTANT=285
STRING=286
VARIABLE=287
SL_COMMENT=288
ML_COMMENT=289
WS=290
GROUP_NORM=28
OUTER=29
TRACE=30
DET=31
RFFT=32
IRFFT=33
ISNAN=34
ISINF=35
ISFINITE=36
SMIN=37
SMAX=38
TMIN=39
TMAX=40
TNORM=41
SNORM=42
FLOOR=43
CEIL=44
ROUND=45
GAMMA=46
POWE=47
SIGM=48
CLAMP=49
SFFT=50
SIFFT=51
ANGL=52
PRNT=53
PRINT_SHAPE=54
NVL=55
LERP=56
STEP=57
SMOOTHSTEP=58
FRACT=59
RELU=60
SOFTSIGN=61
LEAKY_RELU=62
SOFTPLUS=63
GELU=64
SILU=65
SIGN=66
DEGREES=67
RADIANS=68
LOGICAL_NOT=69
LOGICAL_AND=70
LOGICAL_OR=71
HYPOT=72
MAP=73
EZCONV=74
CONV=75
SWAP=76
TRANSPOSE=77
PERM=78
RESHAPE=79
RANGE=80
LINSPACE=81
LOGSPACE=82
TOPK=83
BOTK=84
PINV=85
INV=86
SUM=87
MEAN=88
STD=89
VAR=90
PROD=91
ISCLOSE=92
ALLCLOSE=93
QUARTILE=94
PERCENTILE=95
QUANTILE=96
DOT=97
MOMENT=98
ERF=99
ERFINV=100
ANY=101
ALL=102
EDGE=103
GAUSSIAN=104
MEDIAN=105
MODE=106
CUMSUM=107
CUMPROD=108
TOPK_IND=109
BOTK_IND=110
CUBIC_EASE=111
ELASTIC_EASE=112
SINE_EASE=113
SMOOTHERSTEP=114
DIST=115
REMAP=116
COSSIM=117
COUNT=118
KEYS=119
ENABLE_TRACKING=120
DISABLE_TRACKING=121
RESET_TRACKING=122
GET_CHANGED_KEYS=123
GET_ADDED_KEYS=124
GET_REMOVED_KEYS=125
GET_UNCHANGED_KEYS=126
REPEAT=127
FLATTEN=128
APPEND=129
GET_VALUE=130
FLOW_APPLY=131
BATCH_SHUFFLE=132
MOTION_MASK=133
FLOW_TO_IMAGE=134
FLOW_MAG=135
FLOW_ANG=136
WHERE=137
HISTOGRAM=138
OVERLAY=139
PAD=140
CROSS=141
MATMUL=142
SOLVE=143
MATRIX_RANK=144
RIFE=145
BNOT=146
BITCOUNT=147
SHAPE=148
BAND=149
XOR=150
BOR=151
TENSOR=152
ZEROS=153
ONES=154
EYE=155
ONE_HOT=156
MSE=157
MAE=158
PSNR=159
WEIGHTED_MEAN=160
HUBER_LOSS=161
CROSS_ENTROPY=162
ADD_KEY=163
REMOVE_KEY=164
PUSH=165
POP=166
CLEAR=167
HAS=168
GET=169
CONCAT=170
STACK=171
NONZERO=172
INT=173
FLOAT=174
UPPER=175
LOWER=176
TRIM=177
SPLIT=178
JOIN=179
SUBSTRING=180
FIND=181
REPLACE=182
DILATE=183
ERODE=184
MORPH_OPEN=185
MORPH_CLOSE=186
RGB_TO_OKLAB=187
RGB_TO_CIELAB=188
OKLAB_TO_RGB=189
CIELAB_TO_RGB=190
RGB_TO_HSV=191
HSV_TO_RGB=192
INT_TO_RGB=193
RGB_TO_INT=194
INTERPOLATE_LINEAR=195
INTERPOLATE_AREA=196
INTERPOLATE_NEAREST=197
TEXT_IMAGE=198
AS_NESTED=199
SVD=200
DIAG=201
IF=202
ELSE=203
WHILE=204
FOR=205
IN=206
BREAK=207
CONTINUE=208
RETURN=209
TIMESTAMP=210
SORT=211
ARGSORT=212
ARGMIN=213
ARGMAX=214
SOFTMAX=215
SOFTMIN=216
UNIQUE=217
FLIP=218
STARTSWITH=219
ENDSWITH=220
SQUEEZE=221
UNSQUEEZE=222
ROLL=223
COV=224
CORR=225
ENTROPY=226
CROP=227
NONE=228
COORDS=229
GATHER=230
SCATTER=231
SCATTER_ADD=232
NOISE=233
PINK_NOISE=234
BROWN_NOISE=235
RAND=236
CAUCHY=237
EXPONENTIAL=238
LOGNORMAL=239
BERNOULLI=240
POISSON=241
GAMMADIST=242
BETADIST=243
LAPLACEDIST=244
GUMBELDIST=245
WEIBULLDIST=246
CHI2DIST=247
STUDENTTDIST=248
PERLIN=249
CELLULAR=250
PLASMA=251
RIDGED=252
DOMAIN_WARP=253
PLUS=254
MINUS=255
MULT=256
DIV=257
MOD=258
POW=259
LSHIFT=260
RSHIFT=261
GE=262
GT=263
LE=264
LT=265
EQ=266
EQUEALS=267
PLUS_EQ=268
MINUS_EQ=269
MULT_EQ=270
DIV_EQ=271
MOD_EQ=272
NE=273
PIPE=274
LPAREN=275
RPAREN=276
COMMA=277
SEMICOLON=278
ARROW=279
LBRACKET=280
RBRACKET=281
QUESTION=282
COLON=283
LBRACE=284
RBRACE=285
NUMBER=286
CONSTANT=287
STRING=288
VARIABLE=289
SL_COMMENT=290
ML_COMMENT=291
WS=292
'sin'=1
'cos'=2
'tan'=3
@@ -315,193 +317,195 @@ WS=290
'logsumexp'=25
'norm'=26
'normalize'=27
'outer'=28
'trace'=29
'det'=30
'rfft'=31
'irfft'=32
'isnan'=33
'isinf'=34
'isfinite'=35
'smin'=36
'smax'=37
'tmin'=38
'tmax'=39
'tnorm'=40
'snorm'=41
'floor'=42
'ceil'=43
'round'=44
'gamma'=45
'pow'=46
'sigm'=47
'clamp'=48
'fft'=49
'ifft'=50
'angle'=51
'print'=52
'lerp'=55
'step'=56
'smoothstep'=57
'fract'=58
'relu'=59
'softsign'=60
'leaky_relu'=61
'softplus'=62
'gelu'=63
'sign'=64
'degrees'=65
'radians'=66
'logical_not'=67
'logical_and'=68
'logical_or'=69
'hypot'=70
'map'=71
'swap'=74
'range'=78
'linspace'=79
'logspace'=80
'topk'=81
'botk'=82
'pinv'=83
'inv'=84
'sum'=85
'mean'=86
'std'=87
'var'=88
'prod'=89
'isclose'=90
'allclose'=91
'quantile'=94
'dot'=95
'moment'=96
'erf'=97
'erfinv'=98
'any'=99
'all'=100
'edge'=101
'median'=103
'mode'=104
'cumsum'=105
'cumprod'=106
'smootherstep'=112
'remap'=114
'keys'=117
'repeat'=125
'flatten'=126
'append'=127
'get_value'=128
'flow_apply'=129
'motion_mask'=131
'flow_to_image'=132
'where'=135
'overlay'=137
'pad'=138
'cross'=139
'matmul'=140
'solve'=141
'matrix_rank'=142
'rife'=143
'shape'=146
'tensor'=150
'zeros'=151
'ones'=152
'eye'=153
'one_hot'=154
'mse'=155
'mae'=156
'psnr'=157
'weighted_mean'=158
'huber_loss'=159
'cross_entropy'=160
'add_key'=161
'stack_push'=163
'stack_pop'=164
'stack_clear'=165
'stack_has'=166
'stack_get'=167
'stack'=169
'nonzero'=170
'int'=171
'float'=172
'upper'=173
'lower'=174
'trim'=175
'split'=176
'join'=177
'find'=179
'replace'=180
'dilate'=181
'erode'=182
'morph_open'=183
'morph_close'=184
'rgb_to_oklab'=185
'rgb_to_cielab'=186
'oklab_to_rgb'=187
'cielab_to_rgb'=188
'rgb_to_hsv'=189
'hsv_to_rgb'=190
'int_to_rgb'=191
'rgb_to_int'=192
'interpolate_linear'=193
'interpolate_area'=194
'text_image'=196
'if'=200
'else'=201
'while'=202
'for'=203
'in'=204
'break'=205
'continue'=206
'return'=207
'sort'=209
'argsort'=210
'argmin'=211
'argmax'=212
'softmax'=213
'softmin'=214
'unique'=215
'flip'=216
'startswith'=217
'endswith'=218
'squeeze'=219
'unsqueeze'=220
'roll'=221
'cov'=222
'entropy'=224
'crop'=225
'gather'=228
'scatter'=229
'scatter_add'=230
'+'=252
'-'=253
'*'=254
'/'=255
'%'=256
'^'=257
'<<'=258
'>>'=259
'>='=260
'>'=261
'<='=262
'<'=263
'=='=264
'='=265
'+='=266
'-='=267
'*='=268
'/='=269
'%='=270
'!='=271
'|'=272
'('=273
')'=274
','=275
';'=276
'->'=277
'['=278
']'=279
'?'=280
':'=281
'{'=282
'}'=283
'group_norm'=28
'outer'=29
'trace'=30
'det'=31
'rfft'=32
'irfft'=33
'isnan'=34
'isinf'=35
'isfinite'=36
'smin'=37
'smax'=38
'tmin'=39
'tmax'=40
'tnorm'=41
'snorm'=42
'floor'=43
'ceil'=44
'round'=45
'gamma'=46
'pow'=47
'sigm'=48
'clamp'=49
'fft'=50
'ifft'=51
'angle'=52
'print'=53
'lerp'=56
'step'=57
'smoothstep'=58
'fract'=59
'relu'=60
'softsign'=61
'leaky_relu'=62
'softplus'=63
'gelu'=64
'silu'=65
'sign'=66
'degrees'=67
'radians'=68
'logical_not'=69
'logical_and'=70
'logical_or'=71
'hypot'=72
'map'=73
'swap'=76
'range'=80
'linspace'=81
'logspace'=82
'topk'=83
'botk'=84
'pinv'=85
'inv'=86
'sum'=87
'mean'=88
'std'=89
'var'=90
'prod'=91
'isclose'=92
'allclose'=93
'quantile'=96
'dot'=97
'moment'=98
'erf'=99
'erfinv'=100
'any'=101
'all'=102
'edge'=103
'median'=105
'mode'=106
'cumsum'=107
'cumprod'=108
'smootherstep'=114
'remap'=116
'keys'=119
'repeat'=127
'flatten'=128
'append'=129
'get_value'=130
'flow_apply'=131
'motion_mask'=133
'flow_to_image'=134
'where'=137
'overlay'=139
'pad'=140
'cross'=141
'matmul'=142
'solve'=143
'matrix_rank'=144
'rife'=145
'shape'=148
'tensor'=152
'zeros'=153
'ones'=154
'eye'=155
'one_hot'=156
'mse'=157
'mae'=158
'psnr'=159
'weighted_mean'=160
'huber_loss'=161
'cross_entropy'=162
'add_key'=163
'stack_push'=165
'stack_pop'=166
'stack_clear'=167
'stack_has'=168
'stack_get'=169
'stack'=171
'nonzero'=172
'int'=173
'float'=174
'upper'=175
'lower'=176
'trim'=177
'split'=178
'join'=179
'find'=181
'replace'=182
'dilate'=183
'erode'=184
'morph_open'=185
'morph_close'=186
'rgb_to_oklab'=187
'rgb_to_cielab'=188
'oklab_to_rgb'=189
'cielab_to_rgb'=190
'rgb_to_hsv'=191
'hsv_to_rgb'=192
'int_to_rgb'=193
'rgb_to_int'=194
'interpolate_linear'=195
'interpolate_area'=196
'text_image'=198
'if'=202
'else'=203
'while'=204
'for'=205
'in'=206
'break'=207
'continue'=208
'return'=209
'sort'=211
'argsort'=212
'argmin'=213
'argmax'=214
'softmax'=215
'softmin'=216
'unique'=217
'flip'=218
'startswith'=219
'endswith'=220
'squeeze'=221
'unsqueeze'=222
'roll'=223
'cov'=224
'entropy'=226
'crop'=227
'gather'=230
'scatter'=231
'scatter_add'=232
'+'=254
'-'=255
'*'=256
'/'=257
'%'=258
'^'=259
'<<'=260
'>>'=261
'>='=262
'>'=263
'<='=264
'<'=265
'=='=266
'='=267
'+='=268
'-='=269
'*='=270
'/='=271
'%='=272
'!='=273
'|'=274
'('=275
')'=276
','=277
';'=278
'->'=279
'['=280
']'=281
'?'=282
':'=283
'{'=284
'}'=285
@@ -1079,6 +1079,15 @@ class MathExprListener(ParseTreeListener):
pass
# Enter a parse tree produced by MathExprParser#SiluFunc.
def enterSiluFunc(self, ctx:MathExprParser.SiluFuncContext):
pass
# Exit a parse tree produced by MathExprParser#SiluFunc.
def exitSiluFunc(self, ctx:MathExprParser.SiluFuncContext):
pass
# Enter a parse tree produced by MathExprParser#SignFunc.
def enterSignFunc(self, ctx:MathExprParser.SignFuncContext):
pass
@@ -2582,6 +2591,15 @@ class MathExprListener(ParseTreeListener):
pass
# Enter a parse tree produced by MathExprParser#GroupNormFunc.
def enterGroupNormFunc(self, ctx:MathExprParser.GroupNormFuncContext):
pass
# Exit a parse tree produced by MathExprParser#GroupNormFunc.
def exitGroupNormFunc(self, ctx:MathExprParser.GroupNormFuncContext):
pass
# Enter a parse tree produced by MathExprParser#SMinFunc.
def enterSMinFunc(self, ctx:MathExprParser.SMinFuncContext):
pass
File diff suppressed because one or more lines are too long
@@ -604,6 +604,11 @@ class MathExprVisitor(ParseTreeVisitor):
return self.visitChildren(ctx)
# Visit a parse tree produced by MathExprParser#SiluFunc.
def visitSiluFunc(self, ctx:MathExprParser.SiluFuncContext):
return self.visitChildren(ctx)
# Visit a parse tree produced by MathExprParser#SignFunc.
def visitSignFunc(self, ctx:MathExprParser.SignFuncContext):
return self.visitChildren(ctx)
@@ -1439,6 +1444,11 @@ class MathExprVisitor(ParseTreeVisitor):
return self.visitChildren(ctx)
# Visit a parse tree produced by MathExprParser#GroupNormFunc.
def visitGroupNormFunc(self, ctx:MathExprParser.GroupNormFuncContext):
return self.visitChildren(ctx)
# Visit a parse tree produced by MathExprParser#SMinFunc.
def visitSMinFunc(self, ctx:MathExprParser.SMinFuncContext):
return self.visitChildren(ctx)
+42
View File
@@ -157,6 +157,48 @@ def test_tnorm_normalizes_lists():
torch.testing.assert_close(torch.tensor(eval_expr("tnorm([[3, 4], [0, 0]])")), torch.tensor([[0.6, 0.8], [0.0, 0.0]]))
torch.testing.assert_close(torch.tensor(eval_expr("tnorm([[3, 0], [0, 4]], 0)")), torch.tensor([[1.0, 0.0], [0.0, 1.0]]))
def test_silu_activation():
expected = torch.nn.functional.silu(torch.tensor([-2.0, 0.0, 2.0])).tolist()
assert eval_expr("silu([-2, 0, 2])") == pytest.approx(expected)
assert eval_expr("silu(1000)") == pytest.approx(1000.0)
values = torch.tensor([-3.0, 0.0, 2.0])
torch.testing.assert_close(eval_expr("silu(x)", {"x": values}), torch.nn.functional.silu(values))
assert "silu" in INBUILT_FUNCTIONS
def test_group_norm_matches_pytorch():
values = torch.arange(24, dtype=torch.float32).reshape(2, 4, 3)
weight = torch.tensor([1.0, 0.5, 2.0, 3.0])
bias = torch.tensor([0.0, 1.0, -1.0, 2.0])
variables = {"x": values, "weight": weight, "bias": bias}
torch.testing.assert_close(
eval_expr("group_norm(x, 2)", variables),
torch.nn.functional.group_norm(values, 2),
)
torch.testing.assert_close(
eval_expr("group_norm(x, 2, weight, bias, 0.01)", variables),
torch.nn.functional.group_norm(values, 2, weight, bias, eps=0.01),
)
assert "group_norm" in INBUILT_FUNCTIONS
with pytest.raises(ValueError, match="divide the channel count"):
eval_expr("group_norm(x, 3)", variables)
with pytest.raises(ValueError, match="weight must have shape"):
eval_expr("group_norm(x, 2, [1, 2])", variables)
with pytest.raises(ValueError, match="eps must be a positive finite scalar"):
eval_expr("group_norm(x, 2, none, none, 0)", variables)
def test_group_norm_preserves_float8_dtype():
float8_dtypes = [
getattr(torch, name, None)
for name in ("float8_e4m3fn", "float8_e4m3fnuz", "float8_e5m2", "float8_e5m2fnuz")
]
for dtype in (dtype for dtype in float8_dtypes if dtype is not None):
values = torch.randn(2, 4, 3).to(dtype)
result = eval_expr("group_norm(x, 2)", {"x": values})
assert result.dtype == dtype
if __name__ == "__main__":
test_logic_functions()
test_spatial_functions()
+6
View File
@@ -152,3 +152,9 @@ def test_weighted_mean_and_losses():
torch.nn.functional.cross_entropy(logits, probabilities, reduction="sum"),
)
logits_by_class = torch.tensor([[2.0, 0.0], [0.0, 2.0], [0.0, 0.0]])
torch.testing.assert_close(
parse_and_visit("cross_entropy(logits, labels, 0)", {"logits": logits_by_class, "labels": labels}),
torch.nn.functional.cross_entropy(logits_by_class.movedim(0, 1), labels),
)
+3 -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", "brown", "brown_noise", "bxor", "cat", "cbrt", "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", "cross_entropy", "cubic", "cubic_ease", "cumprod", "cumsum", "degrees", "det", "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", "eye", "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", "huber_loss", "hypot", "changed_keys", "ifft", "int", "int_to_rgb", "interpolate_area", "interpolate_linear", "interpolate_nearest", "interpolate_nearest_exact", "inv", "irfft", "isclose", "isfinite", "isinf", "isnan", "join", "keys", "leaky_relu", "length", "lerp", "linspace", "ln", "log", "log1p", "log2", "logaddexp", "logical_and", "logical_not", "logical_or", "logspace", "logsumexp", "lower", "mae", "map", "matmul", "matrix_rank", "mean", "median", "mode", "moment", "morph_close", "morph_open", "motion_mask", "mse", "nan_to_num", "noise", "nonzero", "norm", "normalize", "now", "nvl", "oklab_to_rgb", "one_hot", "ones", "outer", "overlay", "pad", "percentile", "perlin", "perlin_noise", "perm", "permute", "pink", "pink_noise", "pinv", "plasma", "plasma_noise", "popcnt", "popcount", "pow", "prcnt", "print", "print_shape", "prod", "pshp", "psnr", "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", "reciprocal", "relu", "remap", "remove_key", "removed_keys", "repeat", "replace", "reset_tracking", "reshape", "rfft", "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", "softsign", "solve", "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", "trace", "track_off", "track_on", "track_reset", "transpose", "trim", "turbulence", "unchanged_keys", "unique", "unsqueeze", "upper", "var", "voronoi", "voronoi_noise", "weighted_mean", "where", "worley", "zeros"
"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", "brown", "brown_noise", "bxor", "cat", "cbrt", "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", "cross_entropy", "cubic", "cubic_ease", "cumprod", "cumsum", "degrees", "det", "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", "eye", "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", "group_norm", "hist", "histogram", "hsv_to_rgb", "huber_loss", "hypot", "changed_keys", "ifft", "int", "int_to_rgb", "interpolate_area", "interpolate_linear", "interpolate_nearest", "interpolate_nearest_exact", "inv", "irfft", "isclose", "isfinite", "isinf", "isnan", "join", "keys", "leaky_relu", "length", "lerp", "linspace", "ln", "log", "log1p", "log2", "logaddexp", "logical_and", "logical_not", "logical_or", "logspace", "logsumexp", "lower", "mae", "map", "matmul", "matrix_rank", "mean", "median", "mode", "moment", "morph_close", "morph_open", "motion_mask", "mse", "nan_to_num", "noise", "nonzero", "norm", "normalize", "now", "nvl", "oklab_to_rgb", "one_hot", "ones", "outer", "overlay", "pad", "percentile", "perlin", "perlin_noise", "perm", "permute", "pink", "pink_noise", "pinv", "plasma", "plasma_noise", "popcnt", "popcount", "pow", "prcnt", "print", "print_shape", "prod", "pshp", "psnr", "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", "reciprocal", "relu", "remap", "remove_key", "removed_keys", "repeat", "replace", "reset_tracking", "reshape", "rfft", "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", "silu", "sin", "sine", "sine_ease", "singular_value_decomposition", "sinh", "smax", "smin", "smootherstep", "smoothstep", "snorm", "softmax", "softmin", "softplus", "softsign", "solve", "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", "trace", "track_off", "track_on", "track_reset", "transpose", "trim", "turbulence", "unchanged_keys", "unique", "unsqueeze", "upper", "var", "voronoi", "voronoi_noise", "weighted_mean", "where", "worley", "zeros"
]);
export const FUNCTION_META = {
@@ -40,6 +40,7 @@ export const FUNCTION_META = {
"logsumexp": { minArgs: 1, maxArgs: 2, snippet: "logsumexp(x, dims)", description: "computes log(sum(exp(x))) stably, optionally reducing along one or more dimensions" },
"norm": { minArgs: 1, maxArgs: 3, snippet: "norm(x, p, dims)", description: "computes the p-norm globally or along one or more dimensions (default p=2)" },
"normalize": { minArgs: 1, maxArgs: 4, snippet: "normalize(x, p, dim, eps)", description: "normalizes x along dim using the p-norm (defaults: p=2, dim=-1, eps=1e-12)" },
"group_norm": { minArgs: 2, maxArgs: 5, snippet: "group_norm(x, groups, weight, bias, eps)", description: "applies channel-first GroupNorm to [N, C, ...] input" },
"outer": { minArgs: 2, maxArgs: 2, snippet: "outer(x, y)", description: "computes the outer product of flattened x and y" },
"trace": { minArgs: 1, maxArgs: 1, snippet: "trace(x)", description: "sums the main diagonal of each square matrix in x" },
"det": { minArgs: 1, maxArgs: 1, snippet: "det(x)", description: "computes the determinant of each square matrix in x" },
@@ -78,6 +79,7 @@ export const FUNCTION_META = {
"leaky_relu": { minArgs: 1, maxArgs: 2, snippet: "leaky_relu(x, negative_slope)", description: "applies leaky ReLU element-wise; negative_slope defaults to 0.01" },
"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" },
"silu": { minArgs: 1, maxArgs: 1, snippet: "silu(x)", description: "applies the Sigmoid Linear Unit activation element-wise" },
"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)" },