MCPcopy Index your code
hub / github.com/lutzroeder/netron / emitUnaryOp

Method emitUnaryOp

source/python.js:17194–17207  ·  view source on GitHub ↗
(tree, magicMethod, opSymbol)

Source from the content-addressed store, hash-verified

17192 return out;
17193 }
17194 emitUnaryOp(tree, magicMethod, opSymbol) {
17195 const inputs = [tree.operand];
17196 const named_values = this.getNamedValues(inputs, /*maybe_unpack=*/false);
17197 const val = torch._C.asSimple(torch._C.makeMagic(magicMethod, new torch._C.BuiltinFunction(opSymbol, null)).call(tree.range(), this.method, named_values, [], 0));
17198 if (val.node().kind() !== opSymbol) {
17199 return val;
17200 }
17201 const maybe_out_stack = torch._C.runNodeIfInputsAreConstant(val.node());
17202 if (!maybe_out_stack) {
17203 return val;
17204 }
17205 torch._C.TORCH_INTERNAL_ASSERT(maybe_out_stack.length === 1);
17206 return this.graph.insertConstant(maybe_out_stack[0], tree);
17207 }
17208 emitAssignment(stmt) {
17209 if (stmt instanceof ast.AnnAssign) {
17210 return this.emitSingleAssignment(stmt);

Callers 1

emitSimpleExprMethod · 0.80

Calls 5

getNamedValuesMethod · 0.80
insertConstantMethod · 0.80
callMethod · 0.45
kindMethod · 0.45
nodeMethod · 0.45

Tested by

no test coverage detected