Skip to content

Commit

Permalink
[aot] [refactor] Add make_new_field for Metal (#4559)
Browse files Browse the repository at this point in the history
* Add new field for Metal

* Add back comment
  • Loading branch information
qiao-bo authored Mar 18, 2022
1 parent c57b8d2 commit 03c148d
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions taichi/backends/metal/aot_module_loader_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ class AotModuleImpl : public aot::Module {
for (const auto &k : aot_data_.kernels) {
kernels_[k.kernel_name] = &k;
}
for (const auto &f : aot_data_.fields) {
fields_[f.field_name] = &f;
}
}

size_t get_root_size() const override {
Expand Down Expand Up @@ -81,13 +84,19 @@ class AotModuleImpl : public aot::Module {
}

std::unique_ptr<aot::Field> make_new_field(const std::string &name) override {
TI_NOT_IMPLEMENTED;
return nullptr;
auto itr = fields_.find(name);
if (itr == fields_.end()) {
TI_DEBUG("Failed to load field {}", name);
return nullptr;
}
auto *field_data = itr->second;
return std::make_unique<FieldImpl>(runtime_, *field_data);
}

KernelManager *const runtime_;
TaichiAotData aot_data_;
std::unordered_map<std::string, const CompiledKernelData *> kernels_;
std::unordered_map<std::string, const CompiledFieldData *> fields_;
};

} // namespace
Expand Down

0 comments on commit 03c148d

Please sign in to comment.