Skip to content

Commit

Permalink
[compiler] enable dump mlirbc in cpu pipe
Browse files Browse the repository at this point in the history
* as title
* del simple util*

Signed-off-by: chenhui.huang <huangchenhui.yellow@bytedance.com>
  • Loading branch information
YellowHCH committed May 12, 2024
1 parent 3d5ac72 commit b7f7241
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 14 deletions.
2 changes: 0 additions & 2 deletions compiler/include/byteir/Utils/AttrUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ void setParsedConcatAttr(Operation *op, const std::string &attrName,
const std::string &attrType,
const std::string &attrValue);

void eraseAttr(Operation *op, const std::string &attrName);

/// Return a new ElementsAttr that has the same data as the current
/// attribute, but has been reshaped to 'newShape'.
std::optional<ElementsAttr>
Expand Down
4 changes: 2 additions & 2 deletions compiler/lib/Transforms/FuncTag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ struct RemoveFuncTagPass : public RemoveFuncTagBase<RemoveFuncTagPass> {
for (auto funcOp : getOperation().getOps<func::FuncOp>()) {
if (funcOp.getName() == funcName) {
LLVM_DEBUG(llvm::dbgs() << "Before remove func tag [" << attrName
<< "] on [" << funcName << "], attrName:\n");
eraseAttr(funcOp, attrName);
<< "] on [" << funcOp.getName() << "]\n");
funcOp->removeAttr(llvm::StringRef(attrName));
}
}
}
Expand Down
6 changes: 0 additions & 6 deletions compiler/lib/Utils/AttrUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,6 @@ void mlir::setParsedConcatAttr(Operation *op, const std::string &attrName,
}
}

void mlir::eraseAttr(Operation *op, const std::string &attrName) {
if (!op)
return;
op->removeAttr(llvm::StringRef(attrName));
}

std::optional<ElementsAttr>
mlir::reshapeSplatElementsAttr(ElementsAttr attr,
llvm::ArrayRef<int64_t> newShape) {
Expand Down
4 changes: 0 additions & 4 deletions compiler/python/byteir/compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,22 +320,18 @@ def _compile_cpu(
with context:
PassManager.parse("builtin.module(byre-host{" + target_str + " " + entry_func_str + "})").run(module.operation)
_print_verbose(module, "// IR Dump After Byre Host:") if verbose else ...
'''
# NB. Remove `device_file_name` attr as byre v1.0.0 not support this attr.
target_attr_name = "device_file_name"
PassManager.parse("builtin.module(remove-func-tag{" + f"attr-name={target_attr_name} " + f" func-name={entry_func} " + "})").run(module.operation)
_print_verbose(module, "// IR Dump After Remove func tag:") if verbose else ...
'''

# write to output host mlir file
with open(output_file_path, "w") as f:
f.write(module.operation.get_asm())
'''
output_bc_file_path = os.path.splitext(output_file_path)[0] + ".mlirbc"
# FIXME(chhuang) Pass target version info to compile options
targetVersion = "1.0.0"
byteir.serialize_byre(module, targetVersion, output_bc_file_path)
'''

def compile(
input_file_path: str,
Expand Down

0 comments on commit b7f7241

Please sign in to comment.