Skip to content

Commit

Permalink
[tuner]: address comments
Browse files Browse the repository at this point in the history
Signed-off-by: Bangtian Liu <[email protected]>
  • Loading branch information
bangtianliu committed Dec 10, 2024
1 parent a0c4e2b commit 6db201a
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 32 deletions.
2 changes: 1 addition & 1 deletion tuner/tuner/candidate_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def apply_configuration(
workgroup_sizes = lowering_config.workgroup_tile_sizes
reduction_sizes = lowering_config.reduction_tile_sizes
gpu_pipeline_options = configuration.translation_info.configuration[
"gpu_pipeline_options"
GPU_PIPELINE_OPTIONS
]
tune_logger.info(f"Applying: {configuration}")
expr0 = re.compile(
Expand Down
42 changes: 28 additions & 14 deletions tuner/tuner/candidate_gen_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,12 @@ def test_apply_params_mmt(tuner_ctx: common.TunerContext) -> None:
subgroup_n_count=16,
)
pipeline_attr = iree_codegen.DispatchLoweringPassPipelineAttr.get(
iree_codegen.DispatchLoweringPassPipeline.None_
iree_codegen.DispatchLoweringPassPipeline.LLVMGPUVectorize
)
pipeline_option = iree_gpu.PipelineOptionsAttr.get(prefetch_shared_memory=True)
pipeline_option_dict = ir.DictAttr.get({"gpu_pipeline_options": pipeline_option})
pipeline_option_dict = ir.DictAttr.get(
{common.GPU_PIPELINE_OPTIONS: pipeline_option}
)
translation_info = iree_codegen.TranslationInfoAttr.get(
pipeline_attr, None, [16, 16, 1], 16, pipeline_option_dict
)
Expand Down Expand Up @@ -124,14 +126,16 @@ def test_apply_params_conv(tuner_ctx: common.TunerContext) -> None:
subgroup_n_count=4,
)
pipeline_attr = iree_codegen.DispatchLoweringPassPipelineAttr.get(
iree_codegen.DispatchLoweringPassPipeline.None_
iree_codegen.DispatchLoweringPassPipeline.LLVMGPUVectorize
)
pipeline_option = iree_gpu.PipelineOptionsAttr.get(
reorder_workgroups_strategy=iree_gpu.ReorderWorkgroupsStrategyAttr.get(
iree_gpu.ReorderWorkgroupsStrategy.Transpose
)
)
pipeline_option_dict = ir.DictAttr.get({"gpu_pipeline_options": pipeline_option})
pipeline_option_dict = ir.DictAttr.get(
{common.GPU_PIPELINE_OPTIONS: pipeline_option}
)
translation_info = iree_codegen.TranslationInfoAttr.get(
pipeline_attr, None, [256, 1, 1], 64, pipeline_option_dict
)
Expand Down Expand Up @@ -203,10 +207,12 @@ def test_apply_params_contract(tuner_ctx: common.TunerContext) -> None:
subgroup_n_count=4,
)
pipeline_attr = iree_codegen.DispatchLoweringPassPipelineAttr.get(
iree_codegen.DispatchLoweringPassPipeline.None_
iree_codegen.DispatchLoweringPassPipeline.LLVMGPUVectorize
)
pipeline_option = iree_gpu.PipelineOptionsAttr.get()
pipeline_option_dict = ir.DictAttr.get({"gpu_pipeline_options": pipeline_option})
pipeline_option_dict = ir.DictAttr.get(
{common.GPU_PIPELINE_OPTIONS: pipeline_option}
)
translation_info = iree_codegen.TranslationInfoAttr.get(
pipeline_attr, None, [256, 1, 1], 64, pipeline_option_dict
)
Expand Down Expand Up @@ -264,10 +270,12 @@ def test_apply_params_batch_matmul(tuner_ctx: common.TunerContext) -> None:
subgroup_n_count=2,
)
pipeline_attr = iree_codegen.DispatchLoweringPassPipelineAttr.get(
iree_codegen.DispatchLoweringPassPipeline.None_
iree_codegen.DispatchLoweringPassPipeline.LLVMGPUVectorize
)
pipeline_option = iree_gpu.PipelineOptionsAttr.get()
pipeline_option_dict = ir.DictAttr.get({"gpu_pipeline_options": pipeline_option})
pipeline_option_dict = ir.DictAttr.get(
{common.GPU_PIPELINE_OPTIONS: pipeline_option}
)
translation_info = iree_codegen.TranslationInfoAttr.get(
pipeline_attr, None, [128, 2, 1], 64, pipeline_option_dict
)
Expand Down Expand Up @@ -328,10 +336,12 @@ def test_apply_params_batch_mmt_float(tuner_ctx: common.TunerContext) -> None:
subgroup_n_count=2,
)
pipeline_attr = iree_codegen.DispatchLoweringPassPipelineAttr.get(
iree_codegen.DispatchLoweringPassPipeline.None_
iree_codegen.DispatchLoweringPassPipeline.LLVMGPUVectorize
)
pipeline_option = iree_gpu.PipelineOptionsAttr.get()
pipeline_option_dict = ir.DictAttr.get({"gpu_pipeline_options": pipeline_option})
pipeline_option_dict = ir.DictAttr.get(
{common.GPU_PIPELINE_OPTIONS: pipeline_option}
)
translation_info = iree_codegen.TranslationInfoAttr.get(
pipeline_attr, None, [128, 2, 1], 64, pipeline_option_dict
)
Expand Down Expand Up @@ -390,10 +400,12 @@ def test_apply_params_batch_mmt_int(tuner_ctx: common.TunerContext) -> None:
subgroup_n_count=2,
)
pipeline_attr = iree_codegen.DispatchLoweringPassPipelineAttr.get(
iree_codegen.DispatchLoweringPassPipeline.None_
iree_codegen.DispatchLoweringPassPipeline.LLVMGPUVectorize
)
pipeline_option = iree_gpu.PipelineOptionsAttr.get()
pipeline_option_dict = ir.DictAttr.get({"gpu_pipeline_options": pipeline_option})
pipeline_option_dict = ir.DictAttr.get(
{common.GPU_PIPELINE_OPTIONS: pipeline_option}
)
translation_info = iree_codegen.TranslationInfoAttr.get(
pipeline_attr, None, [128, 2, 1], 64, pipeline_option_dict
)
Expand Down Expand Up @@ -476,10 +488,12 @@ def test_apply_params_broadcast_rhs_mmt(tuner_ctx: common.TunerContext) -> None:
subgroup_n_count=2,
)
pipeline_attr = iree_codegen.DispatchLoweringPassPipelineAttr.get(
iree_codegen.DispatchLoweringPassPipeline.None_
iree_codegen.DispatchLoweringPassPipeline.LLVMGPUVectorize
)
pipeline_option = iree_gpu.PipelineOptionsAttr.get()
pipeline_option_dict = ir.DictAttr.get({"gpu_pipeline_options": pipeline_option})
pipeline_option_dict = ir.DictAttr.get(
{common.GPU_PIPELINE_OPTIONS: pipeline_option}
)
translation_info = iree_codegen.TranslationInfoAttr.get(
pipeline_attr, None, [128, 2, 1], 64, pipeline_option_dict
)
Expand Down
6 changes: 5 additions & 1 deletion tuner/tuner/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ class Configuration:
waves_per_eu: int


# The key name for GPUPipelineOptionsAttr in the translation info config dictionary.
GPU_PIPELINE_OPTIONS = "gpu_pipeline_options"


def get_lowering_config(
tuner_ctx: TunerContext,
**kwargs: Any,
Expand Down Expand Up @@ -159,7 +163,7 @@ def get_lowering_config(
def get_pipeline_config(configuration: Configuration) -> str:
extra_config = ""
pipeline_options = configuration.translation_info.configuration[
"gpu_pipeline_options"
GPU_PIPELINE_OPTIONS
]
if pipeline_options != iree_gpu.PipelineOptionsAttr.get():
extra_config += f", gpu_pipeline_options = {pipeline_options}"
Expand Down
16 changes: 11 additions & 5 deletions tuner/tuner/common_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,12 @@ def test_get_pipeline_config(tuner_ctx: common.TunerContext) -> None:
subgroup_n_count=1,
)
pipeline_attr = iree_codegen.DispatchLoweringPassPipelineAttr.get(
iree_codegen.DispatchLoweringPassPipeline.None_
iree_codegen.DispatchLoweringPassPipeline.LLVMGPUVectorize
)
pipeline_option = iree_gpu.PipelineOptionsAttr.get()
pipeline_option_dict = ir.DictAttr.get({"gpu_pipeline_options": pipeline_option})
pipeline_option_dict = ir.DictAttr.get(
{common.GPU_PIPELINE_OPTIONS: pipeline_option}
)
translation_info = iree_codegen.TranslationInfoAttr.get(
pipeline_attr, None, [16, 16, 1], 32, pipeline_option_dict
)
Expand All @@ -106,7 +108,9 @@ def test_get_pipeline_config(tuner_ctx: common.TunerContext) -> None:
assert config2_str == ', llvm_func_attrs = {"amdgpu-waves-per-eu" = "4"}'

pipeline_option = iree_gpu.PipelineOptionsAttr.get(prefetch_shared_memory=True)
pipeline_option_dict = ir.DictAttr.get({"gpu_pipeline_options": pipeline_option})
pipeline_option_dict = ir.DictAttr.get(
{common.GPU_PIPELINE_OPTIONS: pipeline_option}
)
translation_info = iree_codegen.TranslationInfoAttr.get(
pipeline_attr, None, [16, 16, 1], 32, pipeline_option_dict
)
Expand Down Expand Up @@ -222,10 +226,12 @@ def test_get_lowering_config(tuner_ctx: common.TunerContext) -> None:
)

pipeline_attr = iree_codegen.DispatchLoweringPassPipelineAttr.get(
iree_codegen.DispatchLoweringPassPipeline.None_
iree_codegen.DispatchLoweringPassPipeline.LLVMGPUVectorize
)
pipeline_option = iree_gpu.PipelineOptionsAttr.get()
pipeline_option_dict = ir.DictAttr.get({"gpu_pipeline_options": pipeline_option})
pipeline_option_dict = ir.DictAttr.get(
{common.GPU_PIPELINE_OPTIONS: pipeline_option}
)
translation_info = iree_codegen.TranslationInfoAttr.get(
pipeline_attr, None, [16, 16, 1], 32, pipeline_option_dict
)
Expand Down
7 changes: 2 additions & 5 deletions tuner/tuner/dispatch_constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,8 @@ def generate_solutions(
iree_codegen.DispatchLoweringPassPipeline.LLVMGPUVectorDistribute
)
pipeline_option = iree_gpu.PipelineOptionsAttr.get()
# TODO: expose the function getDictKeyName() from GPUPipelineOptionsAttr to
# get the key name 'gpu_pipeline_options'in the translation info config dictionary
pipeline_option_dict = ir.DictAttr.get(
{"gpu_pipeline_options": pipeline_option}
)
pipeline_option_dict = ir.DictAttr.get({GPU_PIPELINE_OPTIONS: pipeline_option})

translation_info = iree_codegen.TranslationInfoAttr.get(
pipeline_attr,
None,
Expand Down
18 changes: 12 additions & 6 deletions tuner/tuner/dispatch_parser_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,12 @@ def test_get_mmt_tile_sizes(tuner_ctx: common.TunerContext) -> None:
subgroup_n_count=4,
)
pipeline_attr = iree_codegen.DispatchLoweringPassPipelineAttr.get(
iree_codegen.DispatchLoweringPassPipeline.None_
iree_codegen.DispatchLoweringPassPipeline.LLVMGPUVectorize
)
pipeline_option = iree_gpu.PipelineOptionsAttr.get()
pipeline_option_dict = ir.DictAttr.get({"gpu_pipeline_options": pipeline_option})
pipeline_option_dict = ir.DictAttr.get(
{common.GPU_PIPELINE_OPTIONS: pipeline_option}
)
translation_info = iree_codegen.TranslationInfoAttr.get(
pipeline_attr, None, [], 0, pipeline_option_dict
)
Expand All @@ -81,10 +83,12 @@ def test_get_conv_tile_sizes(tuner_ctx: common.TunerContext) -> None:
subgroup_n_count=4,
)
pipeline_attr = iree_codegen.DispatchLoweringPassPipelineAttr.get(
iree_codegen.DispatchLoweringPassPipeline.None_
iree_codegen.DispatchLoweringPassPipeline.LLVMGPUVectorize
)
pipeline_option = iree_gpu.PipelineOptionsAttr.get()
pipeline_option_dict = ir.DictAttr.get({"gpu_pipeline_options": pipeline_option})
pipeline_option_dict = ir.DictAttr.get(
{common.GPU_PIPELINE_OPTIONS: pipeline_option}
)
translation_info = iree_codegen.TranslationInfoAttr.get(
pipeline_attr, None, [256, 1, 1], 64, pipeline_option_dict
)
Expand All @@ -109,10 +113,12 @@ def test_get_contract_tile_sizes(tuner_ctx: common.TunerContext) -> None:
subgroup_n_count=1,
)
pipeline_attr = iree_codegen.DispatchLoweringPassPipelineAttr.get(
iree_codegen.DispatchLoweringPassPipeline.None_
iree_codegen.DispatchLoweringPassPipeline.LLVMGPUVectorize
)
pipeline_option = iree_gpu.PipelineOptionsAttr.get()
pipeline_option_dict = ir.DictAttr.get({"gpu_pipeline_options": pipeline_option})
pipeline_option_dict = ir.DictAttr.get(
{common.GPU_PIPELINE_OPTIONS: pipeline_option}
)
translation_info = iree_codegen.TranslationInfoAttr.get(
pipeline_attr, None, [16, 16, 1], 32, pipeline_option_dict
)
Expand Down

0 comments on commit 6db201a

Please sign in to comment.