add .clang-format

reformat all src
This commit is contained in:
NiccoloN
2026-02-26 19:16:42 +01:00
parent a2c31836ae
commit 810e5e75f9
32 changed files with 902 additions and 953 deletions

View File

@@ -1,5 +1,6 @@
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/Pass/Pass.h"
#include "src/Accelerators/PIM/Dialect/PIM/PimOps.hpp"
#include "src/Accelerators/PIM/Dialect/Spatial/SpatialOps.hpp"
#include "src/Compiler/CompilerUtils.hpp"
@@ -10,22 +11,19 @@ namespace onnx_mlir {
namespace {
struct CountInstructionPass
: public PassWrapper<CountInstructionPass, OperationPass<ModuleOp>> {
struct CountInstructionPass : public PassWrapper<CountInstructionPass, OperationPass<ModuleOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(CountInstructionPass)
StringRef getArgument() const override { return "count-instruction-pass"; }
StringRef getDescription() const override {
return "Count instructions for each core/compute in the module";
}
StringRef getDescription() const override { return "Count instructions for each core/compute in the module"; }
// Make sure that we have a valid default constructor and copy
// constructor to make sure that the options are initialized properly.
CountInstructionPass() {}
CountInstructionPass(const CountInstructionPass &pass)
: PassWrapper<CountInstructionPass, OperationPass<ModuleOp>>() {}
CountInstructionPass(const CountInstructionPass& pass)
: PassWrapper<CountInstructionPass, OperationPass<ModuleOp>>() {}
void runOnOperation() final {
ModuleOp module = getOperation();
@@ -37,8 +35,7 @@ struct CountInstructionPass
for (auto computeOp : func.getOps<spatial::SpatWeightedCompute>()) {
unsigned instructionCount = 0;
instructionCount += computeOp.getBody().front().getOperations().size();
llvm::outs() << "Compute " << computeId << ": " << instructionCount
<< " instructions\n";
llvm::outs() << "Compute " << computeId << ": " << instructionCount << " instructions\n";
totalInstructionCount += instructionCount;
computeId++;
}
@@ -47,21 +44,17 @@ struct CountInstructionPass
for (auto coreOp : func.getOps<pim::PimCoreOp>()) {
unsigned instructionCount = 0;
instructionCount += coreOp.getBody().front().getOperations().size();
llvm::outs() << "Core " << coreId << ": " << instructionCount
<< " instructions\n";
llvm::outs() << "Core " << coreId << ": " << instructionCount << " instructions\n";
totalInstructionCount += instructionCount;
coreId++;
}
llvm::outs() << "Total instruction count: " << totalInstructionCount
<< "\n";
llvm::outs() << "Total instruction count: " << totalInstructionCount << "\n";
}
};
} // namespace
std::unique_ptr<Pass> createCountInstructionPass() {
return std::make_unique<CountInstructionPass>();
}
std::unique_ptr<Pass> createCountInstructionPass() { return std::make_unique<CountInstructionPass>(); }
} // namespace onnx_mlir
} // namespace onnx_mlir