From 3558c5840e7c973e2b1a86ae3a9335b44cad59d4 Mon Sep 17 00:00:00 2001 From: Viet-Hoa Do Date: Fri, 16 Dec 2022 14:45:57 +0000 Subject: Add temporary tile support for dynamic fusion * Multiple intermediate tensors can share the same tile. - A simple operator can reuse the input tensor for the result if the input tensor has the same shape, data type and it is only consumed by that operator. - The special case is a simple operator and an output operator consume the same tensor. However as the output operator doesn't change the content of the input tensor, it doesn't count as "consuming" the input tensor. * These temporary tiles are declared automatically by the template writer. Individual operator doesn't need to generate output tile declaration. * Cast is now simple operator. Resolves: COMPMID-5778 Signed-off-by: Viet-Hoa Do Change-Id: I232647ac976645e2d266a62e055b9eb48c356a8e Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/8877 Comments-Addressed: Arm Jenkins Reviewed-by: Gunes Bayir Reviewed-by: Gian Marco Iodice Tested-by: Arm Jenkins Benchmark: Arm Jenkins --- .../gpu/template_writer/cl/ClTemplateWriter.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/dynamic_fusion/sketch/gpu/template_writer/cl/ClTemplateWriter.cpp') diff --git a/src/dynamic_fusion/sketch/gpu/template_writer/cl/ClTemplateWriter.cpp b/src/dynamic_fusion/sketch/gpu/template_writer/cl/ClTemplateWriter.cpp index eed481f109..2ab6316947 100644 --- a/src/dynamic_fusion/sketch/gpu/template_writer/cl/ClTemplateWriter.cpp +++ b/src/dynamic_fusion/sketch/gpu/template_writer/cl/ClTemplateWriter.cpp @@ -191,6 +191,26 @@ std::string ClTemplateWriter::write_code() code += write_global_section(); code += " //------------------ END KERNEL_BUILDER_COORDINATE ---------------------\n"; + { + const auto tiles = _components.get_tiles(); + std::stringstream tiles_ss; + + tiles_ss << " //------------------ START TILE DECLARATION ---------------------\n"; + + for(auto tile : tiles) + { + const auto var = _vtable.get_variable(tile); + const auto data_type = get_cl_type_from_data_type(tile->data_type()); + const auto var_name = var.uniq_name; + + tiles_ss << " TILE(" << data_type << ", M0, N0, " << var_name << ");\n"; + } + + tiles_ss << " //------------------ END TILE DECLARATION ---------------------\n"; + + code += tiles_ss.str(); + } + for(const auto &component_code : component_codes) { code += component_code; -- cgit v1.2.1