MCPcopy Index your code
hub / github.com/apache/tvm / getGlobalFuncInternal

Method getGlobalFuncInternal

web/src/runtime.ts:1121–1143  ·  view source on GitHub ↗
(name: string, autoAttachToScope = true)

Source from the content-addressed store, hash-verified

1119 }
1120
1121 private getGlobalFuncInternal(name: string, autoAttachToScope = true): PackedFunc {
1122 const stack = this.lib.getOrAllocCallStack();
1123 const nameOffset = stack.allocByteArrayForString(name);
1124 const outOffset = stack.allocPtrArray(1);
1125 const outPtr = stack.ptrFromOffset(outOffset);
1126
1127 stack.commitToWasmMemory(outOffset);
1128
1129 this.lib.checkCall(
1130 (this.exports.TVMFFIFunctionGetGlobal as ctypes.FTVMFFIFunctionGetGlobal)(
1131 stack.ptrFromOffset(nameOffset),
1132 outPtr
1133 )
1134 );
1135 const handle = this.memory.loadPointer(outPtr);
1136 this.lib.recycleCallStack(stack);
1137 if (handle === 0) {
1138 throw Error("Cannot find global function " + name);
1139 }
1140 const ret = this.makePackedFunc(handle);
1141 if (autoAttachToScope) this.ctx.attachToCurrentScope(ret);
1142 return ret;
1143 }
1144
1145 /**
1146 * Check if func is PackedFunc.

Callers 2

constructorMethod · 0.95
getGlobalFuncMethod · 0.95

Calls 10

makePackedFuncMethod · 0.95
getOrAllocCallStackMethod · 0.80
allocPtrArrayMethod · 0.80
ptrFromOffsetMethod · 0.80
commitToWasmMemoryMethod · 0.80
loadPointerMethod · 0.80
recycleCallStackMethod · 0.80
checkCallMethod · 0.45
attachToCurrentScopeMethod · 0.45

Tested by

no test coverage detected