You are viewing a plain text version of this content. The canonical link for it is here.
Posted to discuss-archive@tvm.apache.org by "gemini-code-assist[bot] (via GitHub)" <gi...@apache.org> on 2026/02/11 21:57:14 UTC

Re: [PR] [REFACTOR] Remove picojson dependency, replace with tvm::ffi::json API [tvm]

gemini-code-assist[bot] commented on code in PR #18759:
URL: https://github.com/apache/tvm/pull/18759#discussion_r2795722465


##########
src/runtime/contrib/nvshmem/init.cc:
##########
@@ -82,28 +82,26 @@ void InitNVSHMEM(ffi::Shape uid_64, int num_workers, int worker_id_start) {
 }
 
 void InitNVSHMEMWrapper(ffi::String args) {
-  picojson::value v;
-  std::string err = picojson::parse(v, args);
+  namespace json = tvm::ffi::json;
+  ffi::String err;
+  json::Value v = json::Parse(args, &err);
   if (!err.empty()) {
     LOG(FATAL) << "JSON parse error: " << err;
   }
 
-  if (!v.is<picojson::object>()) {
-    LOG(FATAL) << "JSON is not an object";
-  }
-
-  picojson::object& obj = v.get<picojson::object>();
+  CHECK(v.as<json::Object>()) << "JSON is not an object";
+  json::Object obj = v.cast<json::Object>();
 
-  picojson::array uid_array = obj["uid"].get<picojson::array>();
+  json::Array uid_array = obj[ffi::String("uid")].cast<json::Array>();
   std::vector<int64_t> uid_vector;

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   For a minor performance improvement and for consistency with other parts of the codebase (e.g., `src/runtime/disco/loader.cc`), it's good practice to reserve space for the `uid_vector` before populating it in the loop. This avoids potential reallocations.
   
   ```c
     std::vector<int64_t> uid_vector;
     uid_vector.reserve(uid_array.size());
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org