MCPcopy
hub / github.com/apache/tvm / RuntimeContext

Class RuntimeContext

web/src/runtime.ts:157–306  ·  view source on GitHub ↗

* @internal * Manages extra runtime context for the runtime.

Source from the content-addressed store, hash-verified

155 * Manages extra runtime context for the runtime.
156 */
157class RuntimeContext implements Disposable {
158 functionListGlobalNamesFunctor: PackedFunc;
159 moduleGetFunction: PackedFunc;
160 moduleImport: PackedFunc;
161 tensorEmpty: PackedFunc;
162 tensorCopyFromTo: PackedFunc;
163 tensorCopyFromJSBytes: PackedFunc;
164 tensorCopyToJSBytes: PackedFunc;
165 arrayGetItem: PackedFunc;
166 arrayGetSize: PackedFunc;
167 arrayMake: PackedFunc;
168 arrayConcat: PackedFunc;
169 getSysLib: PackedFunc;
170 tensorCacheGet: PackedFunc;
171 tensorCacheUpdate: PackedFunc;
172 tensorCacheRemove: PackedFunc;
173 tensorCacheClear: PackedFunc;
174 arrayDecodeStorage: PackedFunc;
175 paramModuleFromCache: PackedFunc;
176 paramModuleFromCacheByName: PackedFunc;
177 makeShapeTuple: PackedFunc;
178 tensorCreateView: PackedFunc;
179 sampleTopPFromLogits: PackedFunc;
180 sampleTopPFromProb: PackedFunc;
181 applyRepetitionPenalty: PackedFunc;
182 applyPresenceAndFrequencyPenalty: PackedFunc;
183 applySoftmaxWithTemperature: PackedFunc;
184 concatEmbeddings: PackedFunc | undefined;
185 bool: PackedFunc;
186 private autoDisposeScope: Array<Array<Disposable | undefined>> = [];
187
188 constructor(
189 getGlobalFunc: (name: string) => PackedFunc
190 ) {
191 this.functionListGlobalNamesFunctor = getGlobalFunc(
192 "ffi.FunctionListGlobalNamesFunctor"
193 );
194 this.moduleGetFunction = getGlobalFunc("ffi.ModuleGetFunction");
195 this.moduleImport = getGlobalFunc("ffi.ModuleImportModule");
196 this.tensorEmpty = getGlobalFunc("runtime.TVMTensorAllocWithScope");
197 this.tensorCopyFromTo = getGlobalFunc("runtime.TVMTensorCopyFromTo");
198 this.tensorCopyFromJSBytes = getGlobalFunc("tvmjs.runtime.TensorCopyFromBytes");
199 this.tensorCopyToJSBytes = getGlobalFunc("tvmjs.runtime.TensorCopyToBytes");
200 this.arrayGetItem = getGlobalFunc("ffi.ArrayGetItem");
201 this.arrayGetSize = getGlobalFunc("ffi.ArraySize");
202 this.arrayMake = getGlobalFunc("ffi.Array");
203 this.arrayConcat = getGlobalFunc("tvmjs.runtime.ArrayConcat");
204 this.getSysLib = getGlobalFunc("ffi.SystemLib");
205 this.tensorCacheGet = getGlobalFunc("vm.builtin.tensor_cache.get");
206 this.tensorCacheRemove = getGlobalFunc("vm.builtin.tensor_cache.remove");
207 this.tensorCacheUpdate = getGlobalFunc("vm.builtin.tensor_cache.update");
208 this.tensorCacheClear = getGlobalFunc("vm.builtin.tensor_cache.clear");
209 this.arrayDecodeStorage = getGlobalFunc("tvmjs.array.decode_storage");
210 this.paramModuleFromCache = getGlobalFunc("vm.builtin.param_module_from_cache");
211 this.paramModuleFromCacheByName = getGlobalFunc("vm.builtin.param_module_from_cache_by_name");
212 this.makeShapeTuple = getGlobalFunc("ffi.Shape");
213 this.tensorCreateView = getGlobalFunc("runtime.TVMTensorCreateView");
214 this.sampleTopPFromLogits = getGlobalFunc("vm.builtin.sample_top_p_from_logits");

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…