This is an automated email from the ASF dual-hosted git repository.

tqchen pushed a commit to branch refactor-s1
in repository https://gitbox.apache.org/repos/asf/tvm.git

commit 71e4048fe6567b064429c1c4b0e29d56ff02471e
Author: tqchen <[email protected]>
AuthorDate: Sun Apr 13 16:23:45 2025 -0400

    fix web runtime
---
 web/src/runtime.ts            | 42 ++++--------------------------------------
 web/tests/node/test_object.js |  7 +------
 2 files changed, 5 insertions(+), 44 deletions(-)

diff --git a/web/src/runtime.ts b/web/src/runtime.ts
index d14ae663b2..53e675866f 100644
--- a/web/src/runtime.ts
+++ b/web/src/runtime.ts
@@ -157,8 +157,6 @@ class RuntimeContext implements Disposable {
   arrayGetSize: PackedFunc;
   arrayMake: PackedFunc;
   arrayConcat: PackedFunc;
-  stringMake: PackedFunc;
-  getFFIString: PackedFunc;
   getSysLib: PackedFunc;
   arrayCacheGet: PackedFunc;
   arrayCacheUpdate: PackedFunc;
@@ -183,8 +181,6 @@ class RuntimeContext implements Disposable {
     this.arrayGetSize = getGlobalFunc("runtime.ArraySize");
     this.arrayMake = getGlobalFunc("runtime.Array");
     this.arrayConcat = getGlobalFunc("tvmjs.runtime.ArrayConcat");
-    this.stringMake = getGlobalFunc("runtime.String");
-    this.getFFIString = getGlobalFunc("runtime.GetFFIString");
     this.getSysLib = getGlobalFunc("runtime.SystemLib");
     this.arrayCacheGet = getGlobalFunc("vm.builtin.ndarray_cache.get");
     this.arrayCacheRemove = getGlobalFunc("vm.builtin.ndarray_cache.remove");
@@ -214,8 +210,6 @@ class RuntimeContext implements Disposable {
     this.arrayGetSize.dispose();
     this.arrayMake.dispose();
     this.arrayConcat.dispose();
-    this.stringMake.dispose();
-    this.getFFIString.dispose();
     this.arrayCacheGet.dispose();
     this.arrayCacheRemove.dispose();
     this.arrayCacheUpdate.dispose();
@@ -923,24 +917,6 @@ export class TVMArray extends TVMObject {
   }
 }
 
-/** Runtime string object. */
-export class TVMString extends TVMObject {
-  constructor(
-    handle: Pointer,
-    lib: FFILibrary,
-    ctx: RuntimeContext
-  ) {
-    super(handle, lib, ctx);
-  }
-
-  /**
-   * @returns the size of the array.
-   */
-  toString(): string {
-    return this.ctx.getFFIString(this) as string;
-  }
-}
-
 export enum VMAllocatorKind {
   NAIVE_ALLOCATOR = 1,
   POOLED_ALLOCATOR = 2,
@@ -1900,7 +1876,7 @@ export class Instance implements Disposable {
    * @returns The result array.
    */
   makeTVMArray(
-    inputs: Array<TVMObjectBase>
+    inputs: Array<any>
   ): TVMArray {
     const CALL_STACK_LIMIT = 30000;
     const inputsLength = inputs.length;
@@ -1912,7 +1888,7 @@ export class Instance implements Disposable {
     const listOfArrays: Array<TVMArray> = [];
     for (let begin = 0; begin < inputsLength; begin += CALL_STACK_LIMIT) {
       const end = Math.min(inputsLength, begin + CALL_STACK_LIMIT);
-      const chunk: Array<TVMObjectBase> = inputs.slice(begin, end);
+      const chunk: Array<any> = inputs.slice(begin, end);
       listOfArrays.push(this.ctx.arrayMake(...chunk) as TVMArray);
     }
     return this.ctx.arrayConcat(...listOfArrays) as TVMArray;
@@ -1942,16 +1918,6 @@ export class Instance implements Disposable {
     return this.ctx.concatEmbeddings(...embeddings) as NDArray;
   }
 
-  /**
-   * Create a {@link TVMString} that can be consumed by runtime.
-   *
-   * @param input The string.
-   * @returns The result TVMString.
-   */
-  makeString(input: string): TVMString {
-    return this.ctx.stringMake(input) as TVMString;
-  }
-
   /**
    * Create a shape tuple to pass to runtime.
    * @param shape The shape .
@@ -2311,8 +2277,8 @@ export class Instance implements Disposable {
 
       // Convert string[] to a TVMArray of TVMString, hence treated as a 
TVMObject
       if (val instanceof Array && val.every(e => typeof e === "string")) {
-        const tvmStringArray: TVMString[] = [];
-        val.forEach(e => { tvmStringArray.push(this.makeString(e)) });
+        const tvmStringArray: string[] = [];
+        val.forEach(e => { tvmStringArray.push(e) });
         val = this.makeTVMArray(tvmStringArray);
       }
 
diff --git a/web/tests/node/test_object.js b/web/tests/node/test_object.js
index d8ab2098b1..2423ef4ceb 100644
--- a/web/tests/node/test_object.js
+++ b/web/tests/node/test_object.js
@@ -43,14 +43,9 @@ test("object", () => {
     let t1 = b.get(1);
     assert(t1.getHandle() == t.getHandle());
 
-    let s0 = tvm.makeString("hello world");
-    assert(s0.toString() == "hello world");
-    s0.dispose();
-
     let ret_string = tvm.getGlobalFunc("testing.ret_string");
     let s1 = ret_string("hello");
-    assert(s1.toString() == "hello");
+    assert(s1 == "hello");
     ret_string.dispose();
-    s1.dispose();
   });
 });

Reply via email to