Skip to content

Commit e01a74d

Browse files
committed
add tensor creation and fix ruff
1 parent 9d0f87e commit e01a74d

19 files changed

+1932
-1845
lines changed

more_math/ConditioningMathNode.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from unittest import result
21
import torch
32
from .helper_functions import generate_dim_variables, parse_expr, getIndexTensorAlongDim, as_tensor, normalize_to_common_shape, make_zero_like, get_v_variable, get_f_variable
43
from .Parser.UnifiedMathVisitor import UnifiedMathVisitor
@@ -105,7 +104,6 @@ def execute(cls, V, F, Expression, Expression_pi,batching, length_mismatch="tile
105104
V_norm_tensors = dict(zip(tensor_keys, norm_tensors_batch))
106105

107106
ref_tensor = norm_tensors_batch[0]
108-
common_shape = ref_tensor.shape
109107

110108
# Normalize pooled outputs (if they exist)
111109
valid_pooled_keys = [k for k, v in pooled_outputs.items() if v is not None]

more_math/GuiderMathNode.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from numpy import stack
21
import torch
32
import re
43
from antlr4 import InputStream, CommonTokenStream

more_math/Parser/MathExpr.g4

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
grammar MathExpr;
22

33
// Top-level entry point
4-
start: (funcDef | varDef | stmt)* expr? SEMICOLON? EOF;
4+
start: (funcDef | varDef | stmt)* expr SEMICOLON? EOF;
55

66
funcDef:
77
VARIABLE LPAREN paramList? RPAREN ARROW (block | expr) SEMICOLON # FunctionDef;
@@ -170,7 +170,8 @@ func2:
170170
| BOTK_IND LPAREN expr COMMA expr RPAREN # BotkIndFunc
171171
| BOTK_IND LPAREN expr COMMA expr RPAREN # BotkIndFunc
172172
| PUSH LPAREN expr COMMA expr RPAREN # PushFunc
173-
| GET_VALUE LPAREN expr COMMA expr RPAREN # GetValueFunc;
173+
| GET_VALUE LPAREN expr COMMA expr RPAREN # GetValueFunc
174+
| TENSOR LPAREN indexExpr (COMMA expr)? RPAREN # EmptyTensorFunc;
174175

175176
func3:
176177
CLAMP LPAREN expr COMMA expr COMMA expr RPAREN # ClampFunc
@@ -322,6 +323,8 @@ NONE: 'None' | 'none' | 'NULL' | 'null';
322323
BREAK: 'break';
323324
CONTINUE: 'continue';
324325

326+
TENSOR: 'tensor';
327+
325328
PLUS: '+';
326329
MINUS: '-';
327330
MULT: '*';

more_math/Parser/MathExpr.interp

Lines changed: 3 additions & 1 deletion
Large diffs are not rendered by default.

more_math/Parser/MathExpr.tokens

Lines changed: 58 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -108,37 +108,38 @@ TIMESTAMP=107
108108
NONE=108
109109
BREAK=109
110110
CONTINUE=110
111-
PLUS=111
112-
MINUS=112
113-
MULT=113
114-
DIV=114
115-
MOD=115
116-
POW=116
117-
GE=117
118-
GT=118
119-
LE=119
120-
LT=120
121-
EQ=121
122-
EQUEALS=122
123-
NE=123
124-
PIPE=124
125-
LPAREN=125
126-
RPAREN=126
127-
COMMA=127
128-
SEMICOLON=128
129-
ARROW=129
130-
LBRACKET=130
131-
RBRACKET=131
132-
QUESTION=132
133-
COLON=133
134-
LBRACE=134
135-
RBRACE=135
136-
NUMBER=136
137-
CONSTANT=137
138-
VARIABLE=138
139-
SL_COMMENT=139
140-
ML_COMMENT=140
141-
WS=141
111+
TENSOR=111
112+
PLUS=112
113+
MINUS=113
114+
MULT=114
115+
DIV=115
116+
MOD=116
117+
POW=117
118+
GE=118
119+
GT=119
120+
LE=120
121+
LT=121
122+
EQ=122
123+
EQUEALS=123
124+
NE=124
125+
PIPE=125
126+
LPAREN=126
127+
RPAREN=127
128+
COMMA=128
129+
SEMICOLON=129
130+
ARROW=130
131+
LBRACKET=131
132+
RBRACKET=132
133+
QUESTION=133
134+
COLON=134
135+
LBRACE=135
136+
RBRACE=136
137+
NUMBER=137
138+
CONSTANT=138
139+
VARIABLE=139
140+
SL_COMMENT=140
141+
ML_COMMENT=141
142+
WS=142
142143
'sin'=1
143144
'cos'=2
144145
'tan'=3
@@ -224,28 +225,29 @@ WS=141
224225
'in'=106
225226
'break'=109
226227
'continue'=110
227-
'+'=111
228-
'-'=112
229-
'*'=113
230-
'/'=114
231-
'%'=115
232-
'^'=116
233-
'>='=117
234-
'>'=118
235-
'<='=119
236-
'<'=120
237-
'=='=121
238-
'='=122
239-
'!='=123
240-
'|'=124
241-
'('=125
242-
')'=126
243-
','=127
244-
';'=128
245-
'->'=129
246-
'['=130
247-
']'=131
248-
'?'=132
249-
':'=133
250-
'{'=134
251-
'}'=135
228+
'tensor'=111
229+
'+'=112
230+
'-'=113
231+
'*'=114
232+
'/'=115
233+
'%'=116
234+
'^'=117
235+
'>='=118
236+
'>'=119
237+
'<='=120
238+
'<'=121
239+
'=='=122
240+
'='=123
241+
'!='=124
242+
'|'=125
243+
'('=126
244+
')'=127
245+
','=128
246+
';'=129
247+
'->'=130
248+
'['=131
249+
']'=132
250+
'?'=133
251+
':'=134
252+
'{'=135
253+
'}'=136

more_math/Parser/MathExprLexer.interp

Lines changed: 4 additions & 1 deletion
Large diffs are not rendered by default.

more_math/Parser/MathExprLexer.py

Lines changed: 498 additions & 494 deletions
Large diffs are not rendered by default.

more_math/Parser/MathExprLexer.tokens

Lines changed: 58 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -108,37 +108,38 @@ TIMESTAMP=107
108108
NONE=108
109109
BREAK=109
110110
CONTINUE=110
111-
PLUS=111
112-
MINUS=112
113-
MULT=113
114-
DIV=114
115-
MOD=115
116-
POW=116
117-
GE=117
118-
GT=118
119-
LE=119
120-
LT=120
121-
EQ=121
122-
EQUEALS=122
123-
NE=123
124-
PIPE=124
125-
LPAREN=125
126-
RPAREN=126
127-
COMMA=127
128-
SEMICOLON=128
129-
ARROW=129
130-
LBRACKET=130
131-
RBRACKET=131
132-
QUESTION=132
133-
COLON=133
134-
LBRACE=134
135-
RBRACE=135
136-
NUMBER=136
137-
CONSTANT=137
138-
VARIABLE=138
139-
SL_COMMENT=139
140-
ML_COMMENT=140
141-
WS=141
111+
TENSOR=111
112+
PLUS=112
113+
MINUS=113
114+
MULT=114
115+
DIV=115
116+
MOD=116
117+
POW=117
118+
GE=118
119+
GT=119
120+
LE=120
121+
LT=121
122+
EQ=122
123+
EQUEALS=123
124+
NE=124
125+
PIPE=125
126+
LPAREN=126
127+
RPAREN=127
128+
COMMA=128
129+
SEMICOLON=129
130+
ARROW=130
131+
LBRACKET=131
132+
RBRACKET=132
133+
QUESTION=133
134+
COLON=134
135+
LBRACE=135
136+
RBRACE=136
137+
NUMBER=137
138+
CONSTANT=138
139+
VARIABLE=139
140+
SL_COMMENT=140
141+
ML_COMMENT=141
142+
WS=142
142143
'sin'=1
143144
'cos'=2
144145
'tan'=3
@@ -224,28 +225,29 @@ WS=141
224225
'in'=106
225226
'break'=109
226227
'continue'=110
227-
'+'=111
228-
'-'=112
229-
'*'=113
230-
'/'=114
231-
'%'=115
232-
'^'=116
233-
'>='=117
234-
'>'=118
235-
'<='=119
236-
'<'=120
237-
'=='=121
238-
'='=122
239-
'!='=123
240-
'|'=124
241-
'('=125
242-
')'=126
243-
','=127
244-
';'=128
245-
'->'=129
246-
'['=130
247-
']'=131
248-
'?'=132
249-
':'=133
250-
'{'=134
251-
'}'=135
228+
'tensor'=111
229+
'+'=112
230+
'-'=113
231+
'*'=114
232+
'/'=115
233+
'%'=116
234+
'^'=117
235+
'>='=118
236+
'>'=119
237+
'<='=120
238+
'<'=121
239+
'=='=122
240+
'='=123
241+
'!='=124
242+
'|'=125
243+
'('=126
244+
')'=127
245+
','=128
246+
';'=129
247+
'->'=130
248+
'['=131
249+
']'=132
250+
'?'=133
251+
':'=134
252+
'{'=135
253+
'}'=136

more_math/Parser/MathExprListener.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,6 +1259,15 @@ def exitGetValueFunc(self, ctx:MathExprParser.GetValueFuncContext):
12591259
pass
12601260

12611261

1262+
# Enter a parse tree produced by MathExprParser#EmptyTensorFunc.
1263+
def enterEmptyTensorFunc(self, ctx:MathExprParser.EmptyTensorFuncContext):
1264+
pass
1265+
1266+
# Exit a parse tree produced by MathExprParser#EmptyTensorFunc.
1267+
def exitEmptyTensorFunc(self, ctx:MathExprParser.EmptyTensorFuncContext):
1268+
pass
1269+
1270+
12621271
# Enter a parse tree produced by MathExprParser#ClampFunc.
12631272
def enterClampFunc(self, ctx:MathExprParser.ClampFuncContext):
12641273
pass

0 commit comments

Comments
 (0)