From deac54112483c553de3d5c993d2dbb52edd7ae0c Mon Sep 17 00:00:00 2001 From: Yuanqiang Liu Date: Fri, 6 Sep 2024 17:42:15 +0800 Subject: [PATCH] use discardable attributes --- compiler/lib/Conversion/FuncToByre/FuncToByre.cpp | 12 +++++------- compiler/python/byteir/compile.py | 2 -- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/compiler/lib/Conversion/FuncToByre/FuncToByre.cpp b/compiler/lib/Conversion/FuncToByre/FuncToByre.cpp index d8ced90fe..391704d74 100644 --- a/compiler/lib/Conversion/FuncToByre/FuncToByre.cpp +++ b/compiler/lib/Conversion/FuncToByre/FuncToByre.cpp @@ -108,13 +108,6 @@ class ConvertGPULaunchFuncToByrePattern launchOp->getLoc(), TypeRange(), "PTXOp", launchOp.getKernelOperands(), /*memEffects*/ ArrayAttr()); - computeOp->setAttr(rewriter.getStringAttr("device_file_name"), - launchOp->getAttr("device_file_name")); - if (launchOp->hasAttr(byre::getKernelCallConventionAttrName())) { - computeOp->setAttr( - byre::getKernelCallConventionAttrName(), - launchOp->getAttr(byre::getKernelCallConventionAttrName())); - } computeOp->setAttr( rewriter.getStringAttr("kernel_name"), rewriter.getStringAttr(launchOp.getKernelName().getValue())); @@ -135,6 +128,11 @@ class ConvertGPULaunchFuncToByrePattern computeOp->setAttr("BlockSize.y", rewriter.getI32IntegerAttr(by)); computeOp->setAttr("BlockSize.z", rewriter.getI32IntegerAttr(bz)); + // get discardable attributes from gpu.launch + for (auto attr : launchOp->getDiscardableAttrDictionary().getValue()) { + computeOp->setAttr(attr.getName(), attr.getValue()); + } + rewriter.eraseOp(launchOp); return success(); diff --git a/compiler/python/byteir/compile.py b/compiler/python/byteir/compile.py index 724258b97..659682436 100755 --- a/compiler/python/byteir/compile.py +++ b/compiler/python/byteir/compile.py @@ -131,7 +131,6 @@ def _compile_cuda( PassManager.parse("builtin.module(gpu-opt{device-file-name=" + output_file_prefix + ".ptx" + "})").run(module.operation) _print_verbose(module, "// IR Dump After GPU Opt:") if verbose else ... with context: - # PassManager.parse("builtin.module(func.func(remove-func-body{anchor-attr=__byteir_elementwise_fusion__}))").run(module.operation) PassManager.parse("builtin.module(inline)").run(module.operation) PassManager.parse("builtin.module(func.func(lccl-to-byre))").run(module.operation) PassManager.parse("builtin.module(func.func(gpu-launch-func-to-byre))").run(module.operation) @@ -238,7 +237,6 @@ def _compile_cuda_with_ait( PassManager.parse("builtin.module(gpu-opt{device-file-name=" + output_file_prefix + ".ptx" + "})").run(module.operation) _print_verbose(processor.module, "// IR Dump After GPU Opt:") if verbose else ... with context: - # PassManager.parse("builtin.module(func.func(remove-func-body{anchor-attr=__byteir_elementwise_fusion__}))").run(processor.module.operation) PassManager.parse("builtin.module(inline)").run(processor.module.operation) PassManager.parse("builtin.module(func.func(lccl-to-byre))").run(module.operation) PassManager.parse("builtin.module(func.func(gpu-launch-func-to-byre))").run(processor.module.operation)