Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/runtime/contrib/json/json_runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,11 @@ class JSONRuntimeBase : public ModuleNode {
// The function to initialize constant tensors.
return PackedFunc([sptr_to_self, this](TVMArgs args, TVMRetValue* rv) {
ICHECK_EQ(args.size(), 1U);
this->Init(args[0]);
this->initialized_ = true;
std::lock_guard<std::mutex> guard(this->initialize_mutex_);
if (!this->initialized_) {
this->Init(args[0]);
this->initialized_ = true;
}
*rv = 0;
});
} else {
Expand Down Expand Up @@ -270,6 +273,8 @@ class JSONRuntimeBase : public ModuleNode {
std::vector<uint32_t> const_idx_;
/*! \brief Indicate if the engine has been initialized. */
bool initialized_{false};
/*! \brief Initializer mutex*/
std::mutex initialize_mutex_;
};

} // namespace json
Expand Down