diff --git a/taichi/runtime/gfx/aot_module_loader_impl.cpp b/taichi/runtime/gfx/aot_module_loader_impl.cpp index 708717583f46a..d51165a8e5e06 100644 --- a/taichi/runtime/gfx/aot_module_loader_impl.cpp +++ b/taichi/runtime/gfx/aot_module_loader_impl.cpp @@ -46,29 +46,27 @@ class AotModuleImpl : public aot::Module { liong::json::deserialize(json, ti_aot_data_); } - if (!params.enable_lazy_loading) { - for (int i = 0; i < ti_aot_data_.kernels.size(); ++i) { - auto k = ti_aot_data_.kernels[i]; - std::vector> spirv_sources_codes; - for (int j = 0; j < k.tasks_attribs.size(); ++j) { - std::string spirv_path = k.tasks_attribs[j].name + ".spv"; - - std::vector spirv; - dir->load_file(spirv_path, spirv); - - if (spirv.size() == 0) { - mark_corrupted(); - TI_WARN("spirv '{}' cannot be read", spirv_path); - return; - } - if (spirv.at(0) != 0x07230203) { - TI_WARN("spirv '{}' has a incorrect magic number {}", spirv_path, - spirv.at(0)); - } - spirv_sources_codes.emplace_back(std::move(spirv)); + for (int i = 0; i < ti_aot_data_.kernels.size(); ++i) { + auto k = ti_aot_data_.kernels[i]; + std::vector> spirv_sources_codes; + for (int j = 0; j < k.tasks_attribs.size(); ++j) { + std::string spirv_path = k.tasks_attribs[j].name + ".spv"; + + std::vector spirv; + dir->load_file(spirv_path, spirv); + + if (spirv.size() == 0) { + mark_corrupted(); + TI_WARN("spirv '{}' cannot be read", spirv_path); + return; + } + if (spirv.at(0) != 0x07230203) { + TI_WARN("spirv '{}' has a incorrect magic number {}", spirv_path, + spirv.at(0)); } - ti_aot_data_.spirv_codes.emplace_back(std::move(spirv_sources_codes)); + spirv_sources_codes.emplace_back(std::move(spirv)); } + ti_aot_data_.spirv_codes.emplace_back(std::move(spirv_sources_codes)); } { @@ -136,9 +134,6 @@ class AotModuleImpl : public aot::Module { // AOT, only use the name of the function which should be the first part // of the struct if (ti_aot_data_.kernels[i].name.rfind(name, 0) == 0) { - if (!try_load_spv_kernel(i)) { - return false; - } kernel.kernel_attribs = ti_aot_data_.kernels[i]; kernel.task_spirv_source_codes = ti_aot_data_.spirv_codes[i]; // We don't have to store the number of SNodeTree in |ti_aot_data_| yet, @@ -176,24 +171,6 @@ class AotModuleImpl : public aot::Module { return std::make_unique(runtime_, field); } - bool try_load_spv_kernel(std::size_t index) { - if (index >= ti_aot_data_.spirv_codes.size() || - ti_aot_data_.spirv_codes[index].empty()) { - ti_aot_data_.spirv_codes.resize(index + 1); - auto &codes = ti_aot_data_.spirv_codes[index]; - const auto &k = ti_aot_data_.kernels[index]; - for (const auto &t : k.tasks_attribs) { - auto spv = read_spv_file(module_path_, t); - if (spv.empty()) { - mark_corrupted(); - return false; - } - codes.push_back(spv); - } - } - return true; - } - static std::vector read_spv_file(const std::string &output_dir, const TaskAttributes &k) { const std::string spv_path = fmt::format("{}/{}.spv", output_dir, k.name); diff --git a/taichi/runtime/gfx/aot_module_loader_impl.h b/taichi/runtime/gfx/aot_module_loader_impl.h index ee74d2fdd6b24..de90fea4e89b6 100644 --- a/taichi/runtime/gfx/aot_module_loader_impl.h +++ b/taichi/runtime/gfx/aot_module_loader_impl.h @@ -20,7 +20,6 @@ struct TI_DLL_EXPORT AotModuleParams { std::string module_path{}; const io::VirtualDir *dir{nullptr}; GfxRuntime *runtime{nullptr}; - bool enable_lazy_loading{false}; AotModuleParams() = default;