diff --git a/taichi/runtime/gfx/aot_module_builder_impl.cpp b/taichi/runtime/gfx/aot_module_builder_impl.cpp index f33e46796346f..82e4986a4319f 100644 --- a/taichi/runtime/gfx/aot_module_builder_impl.cpp +++ b/taichi/runtime/gfx/aot_module_builder_impl.cpp @@ -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 &compiled_structs, KernelCompilationManager &compilation_manager,