MCPcopy Create free account
hub / github.com/apache/tvm / _eval_compare

Method _eval_compare

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

The doc AST comparison operation node evaluating method. Parameters ---------- fields : Dict[str, Any] The dictionary of comparison operation information, e.g., operator types, operand values. Returns ------- res : Any

(self, fields: dict[str, Any])

Source from the content-addressed store, hash-verified

311 return value
312
313 def _eval_compare(self, fields: dict[str, Any]) -> Any:
314 """The doc AST comparison operation node evaluating method.
315
316 Parameters
317 ----------
318 fields : Dict[str, Any]
319 The dictionary of comparison operation information,
320 e.g., operator types, operand values.
321
322 Returns
323 -------
324 res : Any
325 The evaluation result.
326 """
327 values = [self._eval_expr(fields["left"])]
328 values.extend([self._eval_expr(rhs) for rhs in fields["comparators"]])
329 result = None
330 assert len(fields["ops"]) == len(values) - 1
331
332 for index, op in enumerate(fields["ops"]):
333 sub_result = _eval_op(op, values=[values[index], values[index + 1]])
334 if result is None:
335 result = sub_result
336 else:
337 result = _eval_op(doc.And(), values=[result, sub_result])
338 return result
339
340 def _eval_unary_op(self, fields: dict[str, Any]) -> Any:
341 """The doc AST unary operation node evaluating method.

Callers 1

_visitMethod · 0.95

Calls 3

_eval_exprMethod · 0.95
_eval_opFunction · 0.85
extendMethod · 0.80

Tested by

no test coverage detected