MCPcopy Index your code
hub / github.com/apache/tvm / eval

Method eval

python/tvm/script/parser/core/evaluator.py:101–132  ·  view source on GitHub ↗

Expression evaluation for TVMScript parser. Parameters ---------- parser : Parser The parser bound with the evaluator. value_table : Dict[str, Any] The value table for expression evaluation. node : doc.AST The root node o

(parser: "Parser", value_table: dict[str, Any], node: doc.AST)

Source from the content-addressed store, hash-verified

99
100 @staticmethod
101 def eval(parser: "Parser", value_table: dict[str, Any], node: doc.AST) -> Any:
102 """Expression evaluation for TVMScript parser.
103
104 Parameters
105 ----------
106 parser : Parser
107 The parser bound with the evaluator.
108
109 value_table : Dict[str, Any]
110 The value table for expression evaluation.
111
112 node : doc.AST
113 The root node of AST tree node of expression to evaluate.
114
115 Returns
116 -------
117 res : Any
118 The evaluation result.
119 """
120 self = ExprEvaluator(parser, value_table)
121 result = self._visit(node) # pylint: disable=protected-access
122 if isinstance(result, doc.Name):
123 if result.id in self.value_table:
124 return self.value_table[result.id]
125 else:
126 builtin = _get_builtin_or_none(result.id)
127 if builtin:
128 return builtin
129 raise ParserError(result, f"Undefined variable: {result.id}")
130 if isinstance(result, doc.Constant):
131 return result.value
132 raise TypeError(f"Unexpected result type: {type(result)}")
133
134 def _add_intermediate_result(self, value: Any) -> doc.Name:
135 """Add intermediate result during evaluation into value table.

Callers 15

eval_exprFunction · 0.80
train_fullMethod · 0.80
predict_incrementalMethod · 0.80
after_iterationMethod · 0.80
test_batchnorm2dFunction · 0.80
_calcFunction · 0.80
test_index_tensorFunction · 0.80
test_fullFunction · 0.80
test_full_likeFunction · 0.80
test_onesFunction · 0.80

Calls 4

_visitMethod · 0.95
ExprEvaluatorClass · 0.85
_get_builtin_or_noneFunction · 0.85
ParserErrorClass · 0.85

Tested by 15

test_batchnorm2dFunction · 0.64
_calcFunction · 0.64
test_index_tensorFunction · 0.64
test_fullFunction · 0.64
test_full_likeFunction · 0.64
test_onesFunction · 0.64
test_sortFunction · 0.64
test_tensor_clampFunction · 0.64
test_tensor_expand_asFunction · 0.64
test_copy_Function · 0.64