MCPcopy Index your code
hub / github.com/lutzroeder/netron / _process_sym_expr

Method _process_sym_expr

source/python.js:20541–20568  ·  view source on GitHub ↗
(sym, hint)

Source from the content-addressed store, hash-verified

20539 }
20540 _parse_sym_expr(expr_str, hint) {
20541 const _process_sym_expr = (sym, hint) => {
20542 if (sym.is_Integer || sym.is_Float || sym.is_Boolean) {
20543 return sym;
20544 }
20545 expr_str = sym.__str__();
20546 for (const arg of sym.args) {
20547 this._parse_sym_expr(arg);
20548 }
20549 if (this.symbol_name_to_symbol.has(expr_str)) {
20550 sym = this.symbol_name_to_symbol.get(expr_str);
20551 } else {
20552 this.symbol_name_to_symbol.set(expr_str, sym);
20553 if (builtins.isinstance(sym, sympy.core.symbol.Symbol) && torch.fx.experimental.symbolic_shapes.symbol_is_type(sym, [torch.utils._sympy.symbol.SymT.UNBACKED_INT, torch.utils._sympy.symbol.SymT.UNBACKED_FLOAT])) {
20554 this.unbacked_symbols.add(sym);
20555 }
20556 }
20557 if (hint !== null && !this.shape_env.var_to_val.has(sym)) {
20558 this.shape_env.add_var_to_val(sym, hint);
20559 }
20560 const vr = this.symbol_name_to_range.get(expr_str);
20561 if (vr) {
20562 this.shape_env.constrain_symbol_range(sym, vr.lower, vr.upper);
20563 }
20564 if (builtins.isinstance(sym, sympy.core.symbol.Symbol)) {
20565 this.shape_env.var_to_stack.set(sym, torch.utils._traceback.CapturedTraceback.extract(false, false, 1));
20566 }
20567 return sym;
20568 };
20569 const locals = new Map([...this.sympy_functions, ...this.symbol_name_to_symbol]);
20570 const expr = sympy.core.sympify.sympify(expr_str, locals);
20571 return _process_sym_expr(expr, hint);

Callers

nothing calls this directly

Calls 9

__str__Method · 0.80
_parse_sym_exprMethod · 0.80
add_var_to_valMethod · 0.80
extractMethod · 0.80
hasMethod · 0.45
getMethod · 0.45
setMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected