(tree, type_hint)
| 17539 | } |
| 17540 | } |
| 17541 | emitSimpleExpr(tree, type_hint) { |
| 17542 | if (tree instanceof ast.Constant) { |
| 17543 | if (tree.value === true) { |
| 17544 | return this.graph.insertConstant(new torch._C.IValue(true, 'Bool'), tree.range()); |
| 17545 | } else if (tree.value === false) { |
| 17546 | return this.graph.insertConstant(new torch._C.IValue(false, 'Bool'), tree.range()); |
| 17547 | } else if (tree.value === null) { |
| 17548 | return this.graph.insertConstant(new torch._C.IValue(), tree.range()); |
| 17549 | } else if (typeof tree.value === 'string') { |
| 17550 | return this.emitStringLiteral(tree); |
| 17551 | } |
| 17552 | return this.emitConst(tree); |
| 17553 | } else if (tree instanceof ast.List) { |
| 17554 | return this.emitListLiteral(tree, type_hint); |
| 17555 | } else if (tree instanceof ast.UnaryOp && tree.op instanceof ast.USub && tree.operand instanceof ast.Name && tree.operand.id === 'inf') { |
| 17556 | return this.emitConst(new ast.Constant(-Infinity, 'float')); |
| 17557 | } else if (tree instanceof ast.UnaryOp && tree.op instanceof ast.USub && tree.operand instanceof ast.Constant) { |
| 17558 | const c = tree.operand; |
| 17559 | if (c.type === 'complex') { |
| 17560 | return this.emitConst(new ast.Constant(new builtins.complex(-c.value.real, -c.value.imag), 'complex')); |
| 17561 | } |
| 17562 | return this.emitConst(new ast.Constant(-c.value, c.type)); |
| 17563 | } else if (tree instanceof ast.UnaryOp && tree.op instanceof ast.USub) { |
| 17564 | return this.emitUnaryOp(tree, '__neg__', 'aten::neg'); |
| 17565 | } else if (tree instanceof ast.BinOp) { |
| 17566 | return this.emitBinaryOp(tree); |
| 17567 | } else if (tree instanceof ast.Dict) { |
| 17568 | return this.emitDictLiteral(tree, type_hint); |
| 17569 | } else if (tree instanceof ast.Tuple) { |
| 17570 | const values = this.getValues(tree.elts, /*maybe_unpack=*/true); |
| 17571 | return this.graph.insertNode(this.graph.createTuple(values)).output(); |
| 17572 | } |
| 17573 | throw new python.Error(`Simple expression '${tree.__class__.__name__}' not implemented.`); |
| 17574 | } |
| 17575 | getNodeKind(kind /*, ninputs */) { |
| 17576 | if (kind instanceof ast.Add) { |
| 17577 | return 'aten::add'; |
no test coverage detected