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

Method registerFunc

web/src/runtime.ts:1087–1110  ·  view source on GitHub ↗

* Register function to be global function in tvm runtime. * @param name The name of the function. * @param func Function to be registered. * @param override Whether overwrite function in existing registry.

(
    name: string,
    func: PackedFunc | Function,
    override = false
  )

Source from the content-addressed store, hash-verified

1085 * @param override Whether overwrite function in existing registry.
1086 */
1087 registerFunc(
1088 name: string,
1089 func: PackedFunc | Function,
1090 override = false
1091 ): void {
1092 this.withNewScope(() => {
1093 const autoAttachToScope = true;
1094 // packed func can be released once it is registered
1095 const packedFunc = this.toPackedFuncInternal(func, autoAttachToScope);
1096 const ioverride = override ? 1 : 0;
1097
1098 const stack = this.lib.getOrAllocCallStack();
1099 const nameOffset = stack.allocByteArrayForString(name);
1100 stack.commitToWasmMemory();
1101 this.lib.checkCall(
1102 (this.lib.exports.TVMFFIFunctionSetGlobal as ctypes.FTVMFFIFunctionSetGlobal)(
1103 stack.ptrFromOffset(nameOffset),
1104 packedFunc._tvmPackedCell.getHandle(),
1105 ioverride
1106 )
1107 );
1108 this.lib.recycleCallStack(stack);
1109 });
1110 }
1111
1112 /**
1113 * Get global PackedFunc from the runtime.

Callers 5

registerAsyncifyFuncMethod · 0.95
initWebGPUMethod · 0.95
asyncInitServerMethod · 0.80

Calls 9

withNewScopeMethod · 0.95
toPackedFuncInternalMethod · 0.95
getOrAllocCallStackMethod · 0.80
commitToWasmMemoryMethod · 0.80
ptrFromOffsetMethod · 0.80
getHandleMethod · 0.80
recycleCallStackMethod · 0.80
checkCallMethod · 0.45

Tested by

no test coverage detected