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

Method emitToBool

source/python.js:17182–17193  ·  view source on GitHub ↗
(loc, v)

Source from the content-addressed store, hash-verified

17180 }
17181 }
17182 emitToBool(loc, v) {
17183 let out = null;
17184 const bool_cast = this.environment_stack.getSugaredVar('bool', loc);
17185 out = torch._C.asSimple(bool_cast.call(loc, this.method, [new torch._C.NamedValue(v)], [], 0));
17186 if (!out) {
17187 throw new python.Error('Could not cast value to bool.');
17188 }
17189 if (!out.type().isSubtypeOf(torch.BoolType.get())) {
17190 throw new python.Error('Expected a bool expression for condition.');
17191 }
17192 return out;
17193 }
17194 emitUnaryOp(tree, magicMethod, opSymbol) {
17195 const inputs = [tree.operand];
17196 const named_values = this.getNamedValues(inputs, /*maybe_unpack=*/false);

Callers 2

emitLoopCommonMethod · 0.80
emitCondExprMethod · 0.80

Calls 5

getSugaredVarMethod · 0.80
isSubtypeOfMethod · 0.80
callMethod · 0.45
typeMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected