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

Method asTuple

source/python.js:15641–15657  ·  view source on GitHub ↗
(loc, m, size_hint)

Source from the content-addressed store, hash-verified

15639 return this._value;
15640 }
15641 asTuple(loc, m, size_hint) {
15642 const make_simple_value = (v) => new torch._C.SimpleValue(v);
15643 if (this._value.type() instanceof torch.TupleType) {
15644 const outputs = torch._C.createTupleUnpack(this._value);
15645 return outputs.map((v) => make_simple_value(v));
15646 } else if (this._value.type() instanceof torch.ListType) {
15647 if (!size_hint) {
15648 throw new python.Error('Cannot statically infer the expected size of a list in this context.');
15649 }
15650 const graph = this._value.owningGraph();
15651 const unpack = graph.insertNode(graph.createListUnpack(this._value, size_hint));
15652 return unpack.outputs().map((v) => make_simple_value(v));
15653 } else if (this._value.type().kind() === 'AnyTupleType') {
15654 throw new python.Error('Provided tuple is not fully defined including its element types.');
15655 }
15656 throw new python.Error(`Cannot use '${this._value.type().toString()}' as tuple.`);
15657 }
15658 attr(loc, m, field) {
15659 if (this._value.type().isSubtypeOf(torch.TensorType.get())) {
15660 if (torch._C.builtin_cast_method_to_scalar_type().has(field)) {

Callers 1

emitTupleAssignMethod · 0.80

Calls 9

createTupleUnpackMethod · 0.80
mapMethod · 0.80
owningGraphMethod · 0.80
insertNodeMethod · 0.80
createListUnpackMethod · 0.80
typeMethod · 0.45
outputsMethod · 0.45
kindMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected