Skip to content

Commit

Permalink
[aot] Remove unused AotDataConverter (#7799)
Browse files Browse the repository at this point in the history
Issue: #

### Brief Summary

<!--
copilot:summary
-->
### <samp>🤖 Generated by Copilot at cc28232</samp>

Remove `AotDataConverter` class <s>and simplify AOT module format. This
class was used to convert between different data structures for AOT
modules, but it is no longer needed as the source structure now uses
protobuf messages. This change makes the AOT module format more
consistent and portable.</s>

### Walkthrough

<!--
copilot:walkthrough
-->
### <samp>🤖 Generated by Copilot at cc28232</samp>

* Remove `AotDataConverter` class and its usages, as it is no longer
needed to convert between TaichiAotData and aot::ModuleData structures
([link](https://github.com/taichi-dev/taichi/pull/7799/files?diff=unified&w=0#diff-be8b774a8052c4122479b69798509100af7e53eb36da000cc42877863bcfbf89L13-L104),
F0L
  • Loading branch information
lin-hitonami authored Apr 13, 2023
1 parent 4eea1ec commit 5d2a462
Showing 1 changed file with 0 additions and 92 deletions.
92 changes: 0 additions & 92 deletions taichi/runtime/gfx/aot_module_builder_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,98 +10,6 @@
namespace taichi::lang {
namespace gfx {

namespace {
class AotDataConverter {
public:
static aot::ModuleData convert(const TaichiAotData &in) {
AotDataConverter c{};
return c.visit(in);
}

private:
explicit AotDataConverter() = default;

aot::ModuleData visit(const TaichiAotData &in) const {
aot::ModuleData res{};
for (const auto &ker : in.kernels) {
auto val = visit(ker);
res.kernels[ker.name] = val;
}
res.fields = in.fields;
res.required_caps = in.required_caps;
res.root_buffer_size = in.root_buffer_size;
return res;
}

aot::CompiledTaichiKernel visit(
const spirv::TaichiKernelAttributes &in) const {
aot::CompiledTaichiKernel res{};
res.tasks.reserve(in.tasks_attribs.size());
for (const auto &t : in.tasks_attribs) {
res.tasks.push_back(visit(t));
}
res.args_count = in.ctx_attribs.args().size();
res.rets_count = in.ctx_attribs.rets().size();
res.args_buffer_size = in.ctx_attribs.args_bytes();
res.rets_buffer_size = in.ctx_attribs.rets_bytes();
for (const auto &arg : in.ctx_attribs.args()) {
if (!arg.is_array) {
aot::ScalarArg scalar_arg{};
scalar_arg.dtype_name = PrimitiveType::get(arg.dtype).to_string();
scalar_arg.offset_in_args_buf = arg.offset_in_mem;
res.scalar_args[arg.index] = scalar_arg;
} else {
aot::ArrayArg arr_arg{};
arr_arg.dtype_name = PrimitiveType::get(arg.dtype).to_string();
arr_arg.field_dim = arg.field_dim;
arr_arg.element_shape = arg.element_shape;
arr_arg.format = arg.format;
arr_arg.shape_offset_in_args_buf = arg.index * sizeof(int32_t);
res.arr_args[arg.index] = arr_arg;
}
}
return res;
}

aot::CompiledOffloadedTask visit(const TaskAttributes &in) const {
aot::CompiledOffloadedTask res{};
res.type = offloaded_task_type_name(in.task_type);
res.name = in.name;
if (in.range_for_attribs && in.range_for_attribs->const_begin &&
in.range_for_attribs->const_end) {
res.range_hint = std::to_string(in.range_for_attribs->end -
in.range_for_attribs->begin);
}
res.gpu_block_size = in.advisory_num_threads_per_group;
for (auto &buffer_bind : in.buffer_binds) {
if (buffer_bind.buffer.type == BufferType::Root) {
res.buffer_binds.push_back(
{{aot::BufferType::Root, buffer_bind.buffer.root_id},
buffer_bind.binding});
} else if (buffer_bind.buffer.type == BufferType::Rets) {
res.buffer_binds.push_back(
{{aot::BufferType::Rets, buffer_bind.buffer.root_id},
buffer_bind.binding});
} else if (buffer_bind.buffer.type == BufferType::GlobalTmps) {
res.buffer_binds.push_back(
{{aot::BufferType::GlobalTmps, buffer_bind.buffer.root_id},
buffer_bind.binding});
} else if (buffer_bind.buffer.type == BufferType::Args) {
res.buffer_binds.push_back(
{{aot::BufferType::Args, buffer_bind.buffer.root_id},
buffer_bind.binding});
}
}

for (auto &texture_bind : in.texture_binds) {
res.texture_binds.push_back(
{texture_bind.arg_id, texture_bind.binding, texture_bind.is_storage});
}
return res;
}
};

} // namespace
AotModuleBuilderImpl::AotModuleBuilderImpl(
const std::vector<spirv::CompiledSNodeStructs> &compiled_structs,
KernelCompilationManager &compilation_manager,
Expand Down

0 comments on commit 5d2a462

Please sign in to comment.