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

Method insertToList

source/python.js:12389–12413  ·  view source on GitHub ↗
(v, type)

Source from the content-addressed store, hash-verified

12387 return n.output();
12388 }
12389 insertToList(v, type) {
12390 let dim = 0;
12391 let ptr = type;
12392 while (ptr instanceof torch.ListType) {
12393 ptr = ptr.getElementType();
12394 dim += 1;
12395 }
12396 let elem_ty = 0;
12397 if (ptr instanceof torch.IntType) {
12398 elem_ty = 0;
12399 } else if (ptr instanceof torch.FloatType) {
12400 elem_ty = 1;
12401 } else if (ptr instanceof torch.BoolType) {
12402 elem_ty = 2;
12403 } else if (ptr instanceof torch.ComplexType) {
12404 elem_ty = 3;
12405 } else {
12406 throw new python.Error(`Unsupported list type '${type.kind()}'.`);
12407 }
12408 const dim_val = this.insertConstant(dim);
12409 const elem_ty_val = this.insertConstant(elem_ty);
12410 const n = this.insertNode(this.create('prim::tolist', [v, dim_val, elem_ty_val]));
12411 n.output().setType(type);
12412 return n.output();
12413 }
12414 insertFunctionCall(callee, matched) {
12415 const func_name = callee.name();
12416 const fn_constant = this.insertNode(this.create('prim::Constant')).s_('name', func_name).output().setType(torch._C.FunctionType.create(callee));

Callers 1

emitApplySpecialFormMethod · 0.80

Calls 7

getElementTypeMethod · 0.80
insertConstantMethod · 0.80
insertNodeMethod · 0.80
setTypeMethod · 0.80
kindMethod · 0.45
createMethod · 0.45
outputMethod · 0.45

Tested by

no test coverage detected