Operation expression evaluation implementation for TVMScript parser. Parameters ---------- op : doc.AST The root node of AST tree node of operation expression to evaluate. values : List[Any] The list of values of operands. Returns ------- res : Any
(
op: doc.AST,
values: list[Any],
)
| 529 | |
| 530 | |
| 531 | def _eval_op( |
| 532 | op: doc.AST, |
| 533 | values: list[Any], |
| 534 | ): |
| 535 | """Operation expression evaluation implementation for TVMScript parser. |
| 536 | |
| 537 | Parameters |
| 538 | ---------- |
| 539 | op : doc.AST |
| 540 | The root node of AST tree node of operation expression to evaluate. |
| 541 | |
| 542 | values : List[Any] |
| 543 | The list of values of operands. |
| 544 | |
| 545 | Returns |
| 546 | ------- |
| 547 | res : Any |
| 548 | The evaluation result. |
| 549 | """ |
| 550 | op_type = type(op) # pylint: disable=protected-access |
| 551 | for i, v in enumerate(values): |
| 552 | v_type = getattr(type(v), "_dispatch_type", None) |
| 553 | if v_type is None: |
| 554 | continue |
| 555 | f = dispatch.get_op( |
| 556 | operand_type=v_type, op_node_type=op_type, operand_index=i, default=None |
| 557 | ) |
| 558 | if f is not None: |
| 559 | return f(*values) |
| 560 | return DEFAULT_OP[op_type](*values) |
| 561 | |
| 562 | |
| 563 | def _eval_assign( |
no test coverage detected
searching dependent graphs…