MCPcopy
hub / github.com/lutzroeder/netron / emitBinaryOp

Method emitBinaryOp

source/python.js:17640–17658  ·  view source on GitHub ↗
(tree)

Source from the content-addressed store, hash-verified

17638 throw new python.Error(`Unknown kind '${kind.__class__.__name__}'.`);
17639 }
17640 emitBinaryOp(tree) {
17641 const inputs = [tree.left, tree.right];
17642 const kind = this.getNodeKind(tree.op, inputs.length);
17643 const overload = this.getOperatorOverload(tree.op, inputs.length);
17644 const named_values = this.getNamedValues(inputs, /*maybe_unpack=*/false);
17645 if (tree.op instanceof ast.In) {
17646 // std::iter_swap(named_values.begin() + 0, named_values.begin() + 1);
17647 throw new python.Error('Not implemented.');
17648 }
17649 if (named_values[0].type() instanceof torch.TupleType &&
17650 named_values[1].type() instanceof torch.TupleType &&
17651 kind === 'aten::add') {
17652 const first_tuple = torch._C.createTupleUnpack(named_values[0].value(this.graph)).vec();
17653 const second_tuple = torch._C.createTupleUnpack(named_values[1].value(this.graph)).vec();
17654 first_tuple.insert(first_tuple.end(), second_tuple.begin(), second_tuple.end());
17655 return this.graph.insertNode(this.graph.createTuple(first_tuple)).output();
17656 }
17657 return torch._C.asSimple(torch._C.makeMagic(overload, new torch._C.BuiltinFunction(kind, null)).call(tree.range(), this.method, named_values, [], 0));
17658 }
17659 emitDictLiteral(dl, type_hint) {
17660 const key_trees = dl.keys;
17661 const value_trees = dl.values;

Callers 1

emitSimpleExprMethod · 0.80

Calls 12

getNodeKindMethod · 0.80
getOperatorOverloadMethod · 0.80
getNamedValuesMethod · 0.80
createTupleUnpackMethod · 0.80
insertMethod · 0.80
insertNodeMethod · 0.80
createTupleMethod · 0.80
typeMethod · 0.45
valueMethod · 0.45
endMethod · 0.45
outputMethod · 0.45
callMethod · 0.45

Tested by

no test coverage detected