Remove stale generated parser files and duplicate tests

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
mcDandy
2026-10-18 12:55:16 +02:00
co-authored by Claude Opus 5.5
parent 17716324e0
commit 198f0d882a
12 changed files with 0 additions and 26087 deletions
-212
View File
@@ -1,212 +0,0 @@
# Function Consistency Check: README.md vs MathExpr.g4
## Executive Summary
✅ **All documented functions have grammar rules defined**
✅ **All grammar functions have documentation**
⚠️ **Minor discrepancies in aliases and function naming**
## Functions in README but Need Verification in Grammar
### ✅ Verified - All Present
#### Basic Math (All Present)
- ✅ abs (AbsFunc)
- ✅ sqrt (SqrtFunc)
- ✅ ln (LnFunc)
- ✅ log (LogFunc)
- ✅ exp (ExpFunc)
- ✅ pow (PowFunc as POWE)
- ✅ floor (FloorFunc)
- ✅ ceil (CeilFunc)
- ✅ round (RoundFunc)
- ✅ fract (FractFunc)
- ✅ sign (SignFunc)
- ✅ gamma (GammaFunc)
- ✅ dist/distance (DistFunc)
- ✅ clamp (ClampFunc)
- ✅ step (StepFunc)
#### Trigonometric (All Present)
- ✅ sin, cos, tan, asin, acos, atan, atan2 (all present)
#### Hyperbolic (All Present)
- ✅ sinh, cosh, tanh, asinh, acosh, atanh (all present)
#### Machine Learning / Activation (All Present)
- ✅ relu (ReluFunc)
- ✅ gelu (GeluFunc)
- ✅ softplus (SoftplusFunc)
- ✅ sigm (SigmoidFunc as SIGM)
- ✅ softmax (SoftmaxFunc)
- ✅ softmin (SoftminFunc)
#### Interpolation (All Present)
- ✅ smoothstep (SmoothstepFunc)
- ✅ smootherstep (SmootherstepFunc)
- ✅ cubic_ease/cubic (CubicEaseFunc)
- ✅ sine_ease/sine (SineEaseFunc)
- ✅ elastic_ease/elastic (ElasticEaseFunc)
- ✅ lerp (LerpFunc)
#### Aggregates & Tensor Operations (All Present)
- ✅ tmin (TMinFunc)
- ✅ tmax (TMaxFunc)
- ✅ smin (SMinFunc)
- ✅ smax (SMaxFunc)
- ✅ sum (SumFunc)
- ✅ mean (MeanFunc)
- ✅ std (StdFunc)
- ✅ var (VarFunc)
- ✅ median (MedianFunc)
- ✅ mode (ModeFunc)
- ✅ quartile (QuartileFunc)
- ✅ percentile (PercentileFunc)
- ✅ quantile (QuantileFunc)
- ✅ dot (DotFunc)
- ✅ moment (MomentFunc)
- ✅ topk (TopkFunc)
- ✅ botk (BotkFunc)
- ✅ topk_ind/topk_indices (TopkIndFunc)
- ✅ botk_ind/botk_indices (BotkIndFunc)
- ✅ sort (SortFunc)
- ✅ argsort (ArgsortFunc)
- ✅ argmin (ArgminFunc)
- ✅ argmax (ArgmaxFunc)
- ✅ unique (UniqueFunc)
- ✅ tnorm (TNormFunc)
- ✅ snorm (SNormFunc)
- ✅ swap (SwapFunc)
- ✅ cossim (CossimFunc)
- ✅ flip (FlipFunc)
- ✅ cov (CovFunc)
- ✅ append (AppendFunc)
- ✅ any (AnyFunc)
- ✅ all (AllFunc)
- ✅ cumsum (CumsumFunc)
- ✅ cumprod (CumprodFunc)
- ✅ tensor (EmptyTensorFunc)
- ✅ flatten (FlattenFunc)
#### Advanced Tensor Operations (All Present)
- ✅ map (MapFunc)
- ✅ ezconvolution/ezconv (EzConvFunc)
- ✅ convolution/conv (ConvFunc)
- ✅ get_value (GetValueFunc)
- ✅ crop (CropFunc)
- ✅ permute/perm (PermuteFunc)
- ✅ reshape/rshp (ReshapeFunc)
- ✅ blur/gaussian (GaussianFunc)
- ✅ edge (EdgeFunc)
- ✅ batch_shuffle/shuffle/select (BatchShuffleFunc)
- ✅ matmul (MatmulFunc)
- ✅ cross (CrossFunc)
#### Optical Flow (All Present)
- ✅ rife (RifeFunc)
- ✅ motion_mask (MotionMaskFunc)
- ✅ flow_to_image (FlowToImageFunc)
- ✅ flow_apply (FlowApplyFunc)
#### FFT (All Present)
- ✅ fft (SFFT)
- ✅ ifft (SIFFT)
- ✅ angle (ANGL)
#### Utility (All Present)
- ✅ print (PrintFunc as PRNT)
- ✅ print_shape/pshp (PrintShapeFunc)
- ✅ pinv (PinvFunc)
- ✅ range (RangeFunc)
- ✅ nan_to_num/nvl (NvlFunc)
- ✅ remap (RemapFunc)
- ✅ timestamp (TimestampFunc as TIMESTAMP)
- ✅ count/length/cnt (CountFunc)
#### Random Distributions (All Present)
- ✅ random_normal/randn/noise (NoiseFunc)
- ✅ random_uniform/rand (RandFunc)
- ✅ random_exponential/rande (ExponentialFunc)
- ✅ random_cauchy/randc (CauchyFunc)
- ✅ random_log_normal/randln (LogNormalFunc)
- ✅ random_bernoulli/randb (BernoulliFunc)
- ✅ random_poisson/randp (PoissonFunc)
- ✅ random_gamma/randg (GammaDistFunc)
- ✅ random_beta/randbeta (BetaDistFunc)
- ✅ random_laplace/randl (LaplaceDistFunc)
- ✅ random_gumbel/randgumbel (GumbelDistFunc)
- ✅ random_weibull/randw (WeibullDistFunc)
- ✅ random_chi2/randchi2 (Chi2DistFunc)
- ✅ random_studentt/randt (StudentTDistFunc)
#### Bitwise Operations (All Present)
- ✅ band/bitwise_and (BitAndFunc)
- ✅ bor/bitwise_or (BitOrFunc)
- ✅ xor/bitwise_xor (BitXorFunc)
- ✅ bnot/bitwise_not (BitNotFunc)
- ✅ bitcount/popcount/popcnt (BitCountFunc)
- ✅ << (LSHIFT)
- ✅ >> (RSHIFT)
#### Stack (All Present)
- ✅ stack_push (PushFunc)
- ✅ stack_pop (PopFunc)
- ✅ stack_get (GetFunc)
- ✅ stack_clear (ClearFunc)
- ✅ stack_has (HasFunc)
## Minor Naming Discrepancies
### README Mentions These Aliases Not Explicitly in Grammar Lexer
1. `now` - README mentions as alias for `timestamp`, but only TIMESTAMP: 'timestamp' is in grammar
- **Fix Needed**: Add `TIMESTAMP: 'timestamp' | 'now';`
2. `flow_view` - README mentions as alias for `flow_to_image`
- **Fix Needed**: Add to `FLOW_TO_IMAGE: 'flow_to_image' | 'flow_view';`
3. `apply_flow` - README mentions as alias for `flow_apply`
- **Fix Needed**: Add to `FLOW_APPLY: 'flow_apply' | 'apply_flow';`
4. Bitwise aliases - Should update for consistency:
- `BAND: 'band' | 'bitwise_and' | 'bitand';` (currently has 'bitand' as alias)
- `BOR: 'bor' | 'bitwise_or' | 'bitor';` (currently has 'bitor' as alias)
- `XOR: 'xor' | 'bitwise_xor' | 'xor';` (should add 'bitwise_xor')
- `BNOT: 'bnot' | 'bitnot' | 'bitwise_not';` (should add 'bitwise_not')
## Summary of Issues
### Critical (Must Fix)
None - all documented functions work
### High Priority (Should Fix)
1. Add missing aliases for consistency:
- `now` for `timestamp`
- `flow_view` for `flow_to_image`
- `apply_flow` for `flow_apply`
- `bitwise_*` names for bitwise operators
### Low Priority (Nice to Have)
- Documentation in README could list all aliases explicitly
## Recommended Grammar Updates
```antlr
// Update these lexer rules:
TIMESTAMP: 'timestamp' | 'now';
FLOW_APPLY: 'flow_apply' | 'apply_flow';
FLOW_TO_IMAGE: 'flow_to_image' | 'flow_view';
BAND: 'band' | 'bitand' | 'bitwise_and';
BOR: 'bor' | 'bitor' | 'bitwise_or';
XOR: 'xor' | 'bitwise_xor';
BNOT: 'bnot' | 'bitnot' | 'bitwise_not';
BITCOUNT: 'bitcount' | 'popcount' | 'popcnt' | 'bitcount';
```
## Conclusion
✅ **Status: EXCELLENT CONSISTENCY**
- 100% of documented functions have grammar rules
- 100% of grammar functions have documentation
- Only minor alias discrepancies that don't affect functionality
- All core functionality is properly defined and documented
**Recommendation**: Regenerate parser after applying the minor grammar updates above to ensure all documented aliases work correctly.
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
-423
View File
@@ -1,423 +0,0 @@
SIN=1
COS=2
TAN=3
ASIN=4
ACOS=5
ATAN=6
ATAN2=7
SINH=8
COSH=9
TANH=10
ASINH=11
ACOSH=12
ATANH=13
ABS=14
SQRT=15
LN=16
LOG=17
EXP=18
SMIN=19
SMAX=20
TMIN=21
TMAX=22
TNORM=23
SNORM=24
FLOOR=25
CEIL=26
ROUND=27
GAMMA=28
POWE=29
SIGM=30
CLAMP=31
SFFT=32
SIFFT=33
ANGL=34
PRNT=35
PRINT_SHAPE=36
NVL=37
LERP=38
STEP=39
SMOOTHSTEP=40
FRACT=41
RELU=42
SOFTPLUS=43
GELU=44
SIGN=45
MAP=46
EZCONV=47
CONV=48
SWAP=49
TRANSPOSE=50
PERM=51
RESHAPE=52
RANGE=53
LINSPACE=54
LOGSPACE=55
TOPK=56
BOTK=57
PINV=58
SUM=59
MEAN=60
STD=61
VAR=62
QUARTILE=63
PERCENTILE=64
QUANTILE=65
DOT=66
MOMENT=67
ERF=68
ERFINV=69
ANY=70
ALL=71
EDGE=72
GAUSSIAN=73
MEDIAN=74
MODE=75
CUMSUM=76
CUMPROD=77
TOPK_IND=78
BOTK_IND=79
CUBIC_EASE=80
ELASTIC_EASE=81
SINE_EASE=82
SMOOTHERSTEP=83
DIST=84
REMAP=85
COSSIM=86
COUNT=87
KEYS=88
ENABLE_TRACKING=89
DISABLE_TRACKING=90
RESET_TRACKING=91
GET_CHANGED_KEYS=92
GET_ADDED_KEYS=93
GET_REMOVED_KEYS=94
GET_UNCHANGED_KEYS=95
REPEAT=96
FLATTEN=97
APPEND=98
GET_VALUE=99
FLOW_APPLY=100
BATCH_SHUFFLE=101
MOTION_MASK=102
FLOW_TO_IMAGE=103
FLOW_MAG=104
FLOW_ANG=105
WHERE=106
HISTOGRAM=107
OVERLAY=108
PAD=109
CROSS=110
MATMUL=111
RIFE=112
BNOT=113
BITCOUNT=114
SHAPE=115
BAND=116
XOR=117
BOR=118
TENSOR=119
ADD_KEY=120
REMOVE_KEY=121
PUSH=122
POP=123
CLEAR=124
HAS=125
GET=126
CONCAT=127
STACK=128
NONZERO=129
INT=130
FLOAT=131
UPPER=132
LOWER=133
TRIM=134
SPLIT=135
JOIN=136
SUBSTRING=137
FIND=138
REPLACE=139
DILATE=140
ERODE=141
MORPH_OPEN=142
MORPH_CLOSE=143
RGB_TO_OKLAB=144
RGB_TO_CIELAB=145
OKLAB_TO_RGB=146
CIELAB_TO_RGB=147
RGB_TO_HSV=148
HSV_TO_RGB=149
INT_TO_RGB=150
RGB_TO_INT=151
INTERPOLATE_LINEAR=152
INTERPOLATE_AREA=153
INTERPOLATE_NEAREST=154
TEXT_IMAGE=155
AS_NESTED=156
SVD=157
DIAG=158
IF=159
ELSE=160
WHILE=161
FOR=162
IN=163
BREAK=164
CONTINUE=165
RETURN=166
TIMESTAMP=167
SORT=168
ARGSORT=169
ARGMIN=170
ARGMAX=171
SOFTMAX=172
SOFTMIN=173
UNIQUE=174
FLIP=175
STARTSWITH=176
ENDSWITH=177
SQUEEZE=178
UNSQUEEZE=179
ROLL=180
COV=181
CORR=182
ENTROPY=183
CROP=184
NONE=185
COORDS=186
GATHER=187
SCATTER=188
SCATTER_ADD=189
NOISE=190
RAND=191
CAUCHY=192
EXPONENTIAL=193
LOGNORMAL=194
BERNOULLI=195
POISSON=196
GAMMADIST=197
BETADIST=198
LAPLACEDIST=199
GUMBELDIST=200
WEIBULLDIST=201
CHI2DIST=202
STUDENTTDIST=203
PERLIN=204
CELLULAR=205
PLASMA=206
RIDGED=207
DOMAIN_WARP=208
PLUS=209
MINUS=210
MULT=211
DIV=212
MOD=213
POW=214
LSHIFT=215
RSHIFT=216
GE=217
GT=218
LE=219
LT=220
EQ=221
EQUEALS=222
PLUS_EQ=223
MINUS_EQ=224
MULT_EQ=225
DIV_EQ=226
MOD_EQ=227
NE=228
PIPE=229
LPAREN=230
RPAREN=231
COMMA=232
SEMICOLON=233
ARROW=234
LBRACKET=235
RBRACKET=236
QUESTION=237
COLON=238
LBRACE=239
RBRACE=240
NUMBER=241
CONSTANT=242
STRING=243
VARIABLE=244
SL_COMMENT=245
ML_COMMENT=246
WS=247
'sin'=1
'cos'=2
'tan'=3
'asin'=4
'acos'=5
'atan'=6
'atan2'=7
'sinh'=8
'cosh'=9
'tanh'=10
'asinh'=11
'acosh'=12
'atanh'=13
'abs'=14
'sqrt'=15
'ln'=16
'log'=17
'exp'=18
'smin'=19
'smax'=20
'tmin'=21
'tmax'=22
'tnorm'=23
'snorm'=24
'floor'=25
'ceil'=26
'round'=27
'gamma'=28
'pow'=29
'sigm'=30
'clamp'=31
'fft'=32
'ifft'=33
'angle'=34
'print'=35
'lerp'=38
'step'=39
'smoothstep'=40
'fract'=41
'relu'=42
'softplus'=43
'gelu'=44
'sign'=45
'map'=46
'swap'=49
'range'=53
'linspace'=54
'logspace'=55
'topk'=56
'botk'=57
'pinv'=58
'sum'=59
'mean'=60
'std'=61
'var'=62
'quantile'=65
'dot'=66
'moment'=67
'erf'=68
'erfinv'=69
'any'=70
'all'=71
'edge'=72
'median'=74
'mode'=75
'cumsum'=76
'cumprod'=77
'smootherstep'=83
'remap'=85
'keys'=88
'repeat'=96
'flatten'=97
'append'=98
'get_value'=99
'flow_apply'=100
'motion_mask'=102
'flow_to_image'=103
'where'=106
'overlay'=108
'pad'=109
'cross'=110
'matmul'=111
'rife'=112
'shape'=115
'tensor'=119
'add_key'=120
'stack_push'=122
'stack_pop'=123
'stack_clear'=124
'stack_has'=125
'stack_get'=126
'stack'=128
'nonzero'=129
'int'=130
'float'=131
'upper'=132
'lower'=133
'trim'=134
'split'=135
'join'=136
'find'=138
'replace'=139
'dilate'=140
'erode'=141
'morph_open'=142
'morph_close'=143
'rgb_to_oklab'=144
'rgb_to_cielab'=145
'oklab_to_rgb'=146
'cielab_to_rgb'=147
'rgb_to_hsv'=148
'hsv_to_rgb'=149
'int_to_rgb'=150
'rgb_to_int'=151
'interpolate_linear'=152
'interpolate_area'=153
'text_image'=155
'if'=159
'else'=160
'while'=161
'for'=162
'in'=163
'break'=164
'continue'=165
'return'=166
'sort'=168
'argsort'=169
'argmin'=170
'argmax'=171
'softmax'=172
'softmin'=173
'unique'=174
'flip'=175
'startswith'=176
'endswith'=177
'squeeze'=178
'unsqueeze'=179
'roll'=180
'cov'=181
'entropy'=183
'crop'=184
'gather'=187
'scatter'=188
'scatter_add'=189
'+'=209
'-'=210
'*'=211
'/'=212
'%'=213
'^'=214
'<<'=215
'>>'=216
'>='=217
'>'=218
'<='=219
'<'=220
'=='=221
'='=222
'+='=223
'-='=224
'*='=225
'/='=226
'%='=227
'!='=228
'|'=229
'('=230
')'=231
','=232
';'=233
'->'=234
'['=235
']'=236
'?'=237
':'=238
'{'=239
'}'=240
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
-423
View File
@@ -1,423 +0,0 @@
SIN=1
COS=2
TAN=3
ASIN=4
ACOS=5
ATAN=6
ATAN2=7
SINH=8
COSH=9
TANH=10
ASINH=11
ACOSH=12
ATANH=13
ABS=14
SQRT=15
LN=16
LOG=17
EXP=18
SMIN=19
SMAX=20
TMIN=21
TMAX=22
TNORM=23
SNORM=24
FLOOR=25
CEIL=26
ROUND=27
GAMMA=28
POWE=29
SIGM=30
CLAMP=31
SFFT=32
SIFFT=33
ANGL=34
PRNT=35
PRINT_SHAPE=36
NVL=37
LERP=38
STEP=39
SMOOTHSTEP=40
FRACT=41
RELU=42
SOFTPLUS=43
GELU=44
SIGN=45
MAP=46
EZCONV=47
CONV=48
SWAP=49
TRANSPOSE=50
PERM=51
RESHAPE=52
RANGE=53
LINSPACE=54
LOGSPACE=55
TOPK=56
BOTK=57
PINV=58
SUM=59
MEAN=60
STD=61
VAR=62
QUARTILE=63
PERCENTILE=64
QUANTILE=65
DOT=66
MOMENT=67
ERF=68
ERFINV=69
ANY=70
ALL=71
EDGE=72
GAUSSIAN=73
MEDIAN=74
MODE=75
CUMSUM=76
CUMPROD=77
TOPK_IND=78
BOTK_IND=79
CUBIC_EASE=80
ELASTIC_EASE=81
SINE_EASE=82
SMOOTHERSTEP=83
DIST=84
REMAP=85
COSSIM=86
COUNT=87
KEYS=88
ENABLE_TRACKING=89
DISABLE_TRACKING=90
RESET_TRACKING=91
GET_CHANGED_KEYS=92
GET_ADDED_KEYS=93
GET_REMOVED_KEYS=94
GET_UNCHANGED_KEYS=95
REPEAT=96
FLATTEN=97
APPEND=98
GET_VALUE=99
FLOW_APPLY=100
BATCH_SHUFFLE=101
MOTION_MASK=102
FLOW_TO_IMAGE=103
FLOW_MAG=104
FLOW_ANG=105
WHERE=106
HISTOGRAM=107
OVERLAY=108
PAD=109
CROSS=110
MATMUL=111
RIFE=112
BNOT=113
BITCOUNT=114
SHAPE=115
BAND=116
XOR=117
BOR=118
TENSOR=119
ADD_KEY=120
REMOVE_KEY=121
PUSH=122
POP=123
CLEAR=124
HAS=125
GET=126
CONCAT=127
STACK=128
NONZERO=129
INT=130
FLOAT=131
UPPER=132
LOWER=133
TRIM=134
SPLIT=135
JOIN=136
SUBSTRING=137
FIND=138
REPLACE=139
DILATE=140
ERODE=141
MORPH_OPEN=142
MORPH_CLOSE=143
RGB_TO_OKLAB=144
RGB_TO_CIELAB=145
OKLAB_TO_RGB=146
CIELAB_TO_RGB=147
RGB_TO_HSV=148
HSV_TO_RGB=149
INT_TO_RGB=150
RGB_TO_INT=151
INTERPOLATE_LINEAR=152
INTERPOLATE_AREA=153
INTERPOLATE_NEAREST=154
TEXT_IMAGE=155
AS_NESTED=156
SVD=157
DIAG=158
IF=159
ELSE=160
WHILE=161
FOR=162
IN=163
BREAK=164
CONTINUE=165
RETURN=166
TIMESTAMP=167
SORT=168
ARGSORT=169
ARGMIN=170
ARGMAX=171
SOFTMAX=172
SOFTMIN=173
UNIQUE=174
FLIP=175
STARTSWITH=176
ENDSWITH=177
SQUEEZE=178
UNSQUEEZE=179
ROLL=180
COV=181
CORR=182
ENTROPY=183
CROP=184
NONE=185
COORDS=186
GATHER=187
SCATTER=188
SCATTER_ADD=189
NOISE=190
RAND=191
CAUCHY=192
EXPONENTIAL=193
LOGNORMAL=194
BERNOULLI=195
POISSON=196
GAMMADIST=197
BETADIST=198
LAPLACEDIST=199
GUMBELDIST=200
WEIBULLDIST=201
CHI2DIST=202
STUDENTTDIST=203
PERLIN=204
CELLULAR=205
PLASMA=206
RIDGED=207
DOMAIN_WARP=208
PLUS=209
MINUS=210
MULT=211
DIV=212
MOD=213
POW=214
LSHIFT=215
RSHIFT=216
GE=217
GT=218
LE=219
LT=220
EQ=221
EQUEALS=222
PLUS_EQ=223
MINUS_EQ=224
MULT_EQ=225
DIV_EQ=226
MOD_EQ=227
NE=228
PIPE=229
LPAREN=230
RPAREN=231
COMMA=232
SEMICOLON=233
ARROW=234
LBRACKET=235
RBRACKET=236
QUESTION=237
COLON=238
LBRACE=239
RBRACE=240
NUMBER=241
CONSTANT=242
STRING=243
VARIABLE=244
SL_COMMENT=245
ML_COMMENT=246
WS=247
'sin'=1
'cos'=2
'tan'=3
'asin'=4
'acos'=5
'atan'=6
'atan2'=7
'sinh'=8
'cosh'=9
'tanh'=10
'asinh'=11
'acosh'=12
'atanh'=13
'abs'=14
'sqrt'=15
'ln'=16
'log'=17
'exp'=18
'smin'=19
'smax'=20
'tmin'=21
'tmax'=22
'tnorm'=23
'snorm'=24
'floor'=25
'ceil'=26
'round'=27
'gamma'=28
'pow'=29
'sigm'=30
'clamp'=31
'fft'=32
'ifft'=33
'angle'=34
'print'=35
'lerp'=38
'step'=39
'smoothstep'=40
'fract'=41
'relu'=42
'softplus'=43
'gelu'=44
'sign'=45
'map'=46
'swap'=49
'range'=53
'linspace'=54
'logspace'=55
'topk'=56
'botk'=57
'pinv'=58
'sum'=59
'mean'=60
'std'=61
'var'=62
'quantile'=65
'dot'=66
'moment'=67
'erf'=68
'erfinv'=69
'any'=70
'all'=71
'edge'=72
'median'=74
'mode'=75
'cumsum'=76
'cumprod'=77
'smootherstep'=83
'remap'=85
'keys'=88
'repeat'=96
'flatten'=97
'append'=98
'get_value'=99
'flow_apply'=100
'motion_mask'=102
'flow_to_image'=103
'where'=106
'overlay'=108
'pad'=109
'cross'=110
'matmul'=111
'rife'=112
'shape'=115
'tensor'=119
'add_key'=120
'stack_push'=122
'stack_pop'=123
'stack_clear'=124
'stack_has'=125
'stack_get'=126
'stack'=128
'nonzero'=129
'int'=130
'float'=131
'upper'=132
'lower'=133
'trim'=134
'split'=135
'join'=136
'find'=138
'replace'=139
'dilate'=140
'erode'=141
'morph_open'=142
'morph_close'=143
'rgb_to_oklab'=144
'rgb_to_cielab'=145
'oklab_to_rgb'=146
'cielab_to_rgb'=147
'rgb_to_hsv'=148
'hsv_to_rgb'=149
'int_to_rgb'=150
'rgb_to_int'=151
'interpolate_linear'=152
'interpolate_area'=153
'text_image'=155
'if'=159
'else'=160
'while'=161
'for'=162
'in'=163
'break'=164
'continue'=165
'return'=166
'sort'=168
'argsort'=169
'argmin'=170
'argmax'=171
'softmax'=172
'softmin'=173
'unique'=174
'flip'=175
'startswith'=176
'endswith'=177
'squeeze'=178
'unsqueeze'=179
'roll'=180
'cov'=181
'entropy'=183
'crop'=184
'gather'=187
'scatter'=188
'scatter_add'=189
'+'=209
'-'=210
'*'=211
'/'=212
'%'=213
'^'=214
'<<'=215
'>>'=216
'>='=217
'>'=218
'<='=219
'<'=220
'=='=221
'='=222
'+='=223
'-='=224
'*='=225
'/='=226
'%='=227
'!='=228
'|'=229
'('=230
')'=231
','=232
';'=233
'->'=234
'['=235
']'=236
'?'=237
':'=238
'{'=239
'}'=240
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
-133
View File
@@ -1,133 +0,0 @@
#!/usr/bin/env python3
"""Quick test to verify bitwise operations work with tensors"""
import sys
sys.path.insert(0, r'D:\stability\Data\Packages\ComfyUI')
import torch
from custom_nodes.more_math.more_math.Parser.UnifiedMathVisitor import UnifiedMathVisitor
def test_bitwise_xor_float():
"""Test XOR with float tensors (the reported bug)"""
print("Testing bitwise XOR with float tensors...")
# Create float tensors (this was causing the error)
a = torch.tensor([1.0, 2.0, 3.0], dtype=torch.float32)
b = torch.tensor([4.0, 5.0, 6.0], dtype=torch.float32)
visitor = UnifiedMathVisitor({"a": a, "b": b})
try:
# This should convert to int64, perform XOR, then convert back
result = visitor._bitwise_op(a, b, torch.bitwise_xor, lambda x, y: x ^ y)
print("✓ XOR succeeded!")
print(f" Input a (float32): {a}")
print(f" Input b (float32): {b}")
print(f" Result: {result}")
print(f" Result dtype: {result.dtype}")
return True
except Exception as e:
print(f"✗ XOR failed: {e}")
return False
def test_bitwise_and_float():
"""Test AND with float tensors"""
print("\nTesting bitwise AND with float tensors...")
a = torch.tensor([15.0, 14.0, 13.0], dtype=torch.float32)
b = torch.tensor([7.0, 3.0, 1.0], dtype=torch.float32)
visitor = UnifiedMathVisitor({"a": a, "b": b})
try:
result = visitor._bitwise_op(a, b, torch.bitwise_and, lambda x, y: x & y)
print("✓ AND succeeded!")
print(f" Input a (float32): {a}")
print(f" Input b (float32): {b}")
print(f" Result: {result}")
print(f" Result dtype: {result.dtype}")
return True
except Exception as e:
print(f"✗ AND failed: {e}")
return False
def test_bitwise_or_float():
"""Test OR with float tensors"""
print("\nTesting bitwise OR with float tensors...")
a = torch.tensor([15.0, 14.0, 13.0], dtype=torch.float32)
b = torch.tensor([7.0, 3.0, 1.0], dtype=torch.float32)
visitor = UnifiedMathVisitor({"a": a, "b": b})
try:
result = visitor._bitwise_op(a, b, torch.bitwise_or, lambda x, y: x | y)
print("✓ OR succeeded!")
print(f" Input a (float32): {a}")
print(f" Input b (float32): {b}")
print(f" Result: {result}")
print(f" Result dtype: {result.dtype}")
return True
except Exception as e:
print(f"✗ OR failed: {e}")
return False
def test_bitwise_not_float():
"""Test NOT with float tensors"""
print("\nTesting bitwise NOT with float tensors...")
a = torch.tensor([1.0, 2.0, 3.0], dtype=torch.float32)
visitor = UnifiedMathVisitor({"a": a})
try:
result = visitor._bitwise_not(a)
print("✓ NOT succeeded!")
print(f" Input a (float32): {a}")
print(f" Result: {result}")
print(f" Result dtype: {result.dtype}")
return True
except Exception as e:
print(f"✗ NOT failed: {e}")
return False
def test_int_tensors_preserved():
"""Ensure int tensors still work as before"""
print("\nTesting that int tensor dtypes are preserved...")
a = torch.tensor([15, 14, 13], dtype=torch.int16)
b = torch.tensor([7, 3, 1], dtype=torch.int16)
visitor = UnifiedMathVisitor({"a": a, "b": b})
try:
result = visitor._bitwise_op(a, b, torch.bitwise_and, lambda x, y: x & y)
assert result.dtype == torch.int16, f"Expected int16, got {result.dtype}"
print("✓ Int16 dtype preserved!")
print(f" Input a (int16): {a}")
print(f" Input b (int16): {b}")
print(f" Result (int16): {result}")
return True
except Exception as e:
print(f"✗ Int16 test failed: {e}")
return False
if __name__ == "__main__":
print("=" * 70)
print("Bitwise Operations Fix Verification")
print("=" * 70)
results = [
test_bitwise_xor_float(),
test_bitwise_and_float(),
test_bitwise_or_float(),
test_bitwise_not_float(),
test_int_tensors_preserved(),
]
print("\n" + "=" * 70)
if all(results):
print("✓ All tests passed!")
else:
print("✗ Some tests failed")
sys.exit(1)
print("=" * 70)
-170
View File
@@ -1,170 +0,0 @@
#!/usr/bin/env python3
"""
Test bitwise shift operators and bit count function
"""
import torch
import sys
sys.path.insert(0, 'custom_nodes/more_math')
from more_math.Parser.MathExprParser import MathExprParser
from more_math.Parser.UnifiedMathVisitor import UnifiedMathVisitor
from antlr4 import InputStream, CommonTokenFactory
def parse_and_evaluate(expression, variables=None):
"""Parse and evaluate a math expression"""
if variables is None:
variables = {}
input_stream = InputStream(expression)
lexer = MathExprParser(input_stream).lexer
stream = CommonTokenFactory()
parser = MathExprParser(input_stream)
tree = parser.start()
visitor = UnifiedMathVisitor(variables, device='cpu')
result = visitor.visit(tree)
return result
def test_bit_shifts():
"""Test bitwise shift operators"""
print("=" * 60)
print("Testing Bitwise Shift Operators")
print("=" * 60)
test_cases = [
# Left shift: 5 << 2 = 20 (0101 << 2 = 10100)
("5 << 2", {}, 20),
# Right shift: 20 >> 2 = 5 (10100 >> 2 = 0101)
("20 >> 2", {}, 5),
# Left shift with variable
("x << 3", {"x": 4}, 32), # 4 << 3 = 32
# Right shift with variable
("x >> 2", {"x": 16}, 4), # 16 >> 2 = 4
# Chained shifts
("(8 << 2) >> 3", {}, 4), # (32) >> 3 = 4
]
for expr, vars, expected in test_cases:
try:
result = parse_and_evaluate(expr, vars)
status = "✓" if result == expected else "✗"
print(f"{status} {expr:30} = {result:10} (expected {expected})")
except Exception as e:
print(f"✗ {expr:30} ERROR: {e}")
def test_bit_count():
"""Test bit count function"""
print("\n" + "=" * 60)
print("Testing Bitwise Bit Count Function")
print("=" * 60)
test_cases = [
# bitcount(5) = 2 (0101 has 2 set bits)
("bitcount(5)", {}, 2),
# bitcount(15) = 4 (1111 has 4 set bits)
("bitcount(15)", {}, 4),
# bitcount(7) = 3 (111 has 3 set bits)
("bitcount(7)", {}, 3),
# bitcount(255) = 8 (11111111 has 8 set bits)
("bitcount(255)", {}, 8),
# bitcount(0) = 0
("bitcount(0)", {}, 0),
# With variable
("bitcount(x)", {"x": 31}, 5), # 31 = 11111 = 5 bits set
]
for expr, vars, expected in test_cases:
try:
result = parse_and_evaluate(expr, vars)
status = "✓" if result == expected else "✗"
print(f"{status} {expr:30} = {result:10} (expected {expected})")
except Exception as e:
print(f"✗ {expr:30} ERROR: {e}")
def test_bit_shifts_with_tensors():
"""Test bitwise shifts with tensors"""
print("\n" + "=" * 60)
print("Testing Bitwise Shifts with Tensors")
print("=" * 60)
vars = {
"a": torch.tensor([1, 2, 4, 8], dtype=torch.int32),
"shift": 2,
}
try:
result = parse_and_evaluate("a << shift", vars)
expected = torch.tensor([4, 8, 16, 32], dtype=torch.int32)
match = torch.equal(result, expected)
status = "✓" if match else "✗"
print(f"{status} tensor_shift_left: [1,2,4,8] << 2 = {result.tolist()}")
except Exception as e:
print(f"✗ tensor_shift_left ERROR: {e}")
try:
result = parse_and_evaluate("a >> shift", vars)
expected = torch.tensor([0, 0, 1, 2], dtype=torch.int32)
match = torch.equal(result, expected)
status = "✓" if match else "✗"
print(f"{status} tensor_shift_right: [1,2,4,8] >> 2 = {result.tolist()}")
except Exception as e:
print(f"✗ tensor_shift_right ERROR: {e}")
def test_bit_count_with_tensors():
"""Test bit count with tensors"""
print("\n" + "=" * 60)
print("Testing Bit Count with Tensors")
print("=" * 60)
vars = {
"nums": torch.tensor([5, 15, 7, 255], dtype=torch.int32),
}
try:
result = parse_and_evaluate("bitcount(nums)", vars)
# Expected: [2, 4, 3, 8] set bits
print(f"✓ bitcount([5,15,7,255]): {result}")
except Exception as e:
print(f"✗ bitcount_tensor ERROR: {e}")
def test_combinations():
"""Test combinations of shift and bit count"""
print("\n" + "=" * 60)
print("Testing Combinations")
print("=" * 60)
test_cases = [
# Shift then count bits
("bitcount(5 << 2)", {}, 2), # 5 << 2 = 20 (10100) = 2 bits
# Combined with other operators
("(5 << 2) | (3 << 4)", {}, 0xCC), # 20 | 48 = 0xCC = 204
]
for expr, vars, expected in test_cases:
try:
result = parse_and_evaluate(expr, vars)
status = "✓" if result == expected else "✗"
print(f"{status} {expr:35} = {result:10} (expected {expected})")
except Exception as e:
print(f"✗ {expr:35} ERROR: {e}")
if __name__ == "__main__":
test_bit_shifts()
test_bit_count()
test_bit_shifts_with_tensors()
test_bit_count_with_tensors()
test_combinations()
print("\n" + "=" * 60)
print("All tests completed!")
print("=" * 60)