fix trivial merge
Validate Operations / validate-operations (push) Waiting to run

minor validate.py fix
This commit is contained in:
NiccoloN
2026-07-22 15:43:27 +02:00
parent 8da4603be3
commit b491ff77b1
2 changed files with 21 additions and 7 deletions
@@ -42,6 +42,17 @@ static bool hasCapacityFor(Operation* producer, Operation* consumer) {
return getCrossbarUnionSize(producerWeights, consumerWeights) <= static_cast<size_t>(crossbarCountInCore.getValue());
}
template <typename ConsumerOp>
static bool isUniqueGraphComputePredecessor(Operation *candidate, ConsumerOp consumer) {
llvm::SmallSetVector<Operation *, 4> predecessors;
for (Value input : consumer.getInputs()) {
Operation *producer = input.getDefiningOp();
if (producer && isGraphComputeLike(producer))
predecessors.insert(producer);
}
return predecessors.size() == 1 && predecessors.front() == candidate;
}
struct TrivialGraphMergeStats {
size_t scalarBefore = 0;
size_t batchBefore = 0;
@@ -153,7 +164,8 @@ struct MergeTrivialScalarComputes : OpRewritePattern<SpatGraphCompute> {
for (Value input : consumer.getInputs()) {
auto candidate = input.getDefiningOp<SpatGraphCompute>();
if (candidate && candidate->getBlock() == consumer->getBlock() && hasOnlyStructuralAttrs(candidate)
&& hasOnlyStructuralAttrs(consumer) && isExclusivelyConsumedBy(candidate, consumer)
&& hasOnlyStructuralAttrs(consumer) && isUniqueGraphComputePredecessor(candidate, consumer)
&& isExclusivelyConsumedBy(candidate, consumer)
&& hasCapacityFor(candidate, consumer) && hasNoNestedArgumentCaptures(candidate)
&& hasNoNestedArgumentCaptures(consumer)) {
producer = candidate;
@@ -319,7 +331,8 @@ struct FoldBatchLeadingUnitNormalization : OpRewritePattern<SpatGraphCompute> {
? SpatGraphComputeBatch()
: consumer.getInputs().front().getDefiningOp<SpatGraphComputeBatch>();
if (!producer || producer->getBlock() != consumer->getBlock() || !hasOnlyStructuralAttrs(producer)
|| !hasOnlyStructuralAttrs(consumer) || !isExclusivelyConsumedBy(producer, consumer))
|| !hasOnlyStructuralAttrs(consumer) || !isUniqueGraphComputePredecessor(producer, consumer)
|| !isExclusivelyConsumedBy(producer, consumer))
return failure();
auto fragments = collectPublishedFragments(producer);
if (!matchLeadingUnitNormalization(producer, consumer) || failed(fragments))
@@ -394,7 +407,8 @@ struct MergeTrivialBatchComputes : OpRewritePattern<SpatGraphComputeBatch> {
auto candidate = input.getDefiningOp<SpatGraphComputeBatch>();
if (candidate && candidate->getBlock() == consumer->getBlock()
&& candidate.getLaneCount() == consumer.getLaneCount() && hasOnlyStructuralAttrs(candidate)
&& hasOnlyStructuralAttrs(consumer) && isExclusivelyConsumedBy(candidate, consumer)
&& hasOnlyStructuralAttrs(consumer) && isUniqueGraphComputePredecessor(candidate, consumer)
&& isExclusivelyConsumedBy(candidate, consumer)
&& hasCapacityFor(candidate, consumer) && hasDirectLaneConsumers(candidate, consumer)
&& succeeded(fragments = collectPublishedFragments(candidate))) {
producer = candidate;
@@ -462,7 +476,7 @@ struct TrivialGraphComputeMergePass final : PassWrapper<TrivialGraphComputeMerge
StringRef getArgument() const override { return "pim-trivial-graph-compute-merge"; }
StringRef getDescription() const override {
return "Inline graph computes with exclusive direct dependencies before PEFT scheduling.";
return "Inline linear exclusive graph compute chains while preserving fan-in boundaries.";
}
void runOnOperation() override {
+3 -3
View File
@@ -174,9 +174,6 @@ def main():
# Summary
n_passed = sum(1 for passed in results.values() if passed)
n_total = len(results)
print("\n" + Style.BRIGHT + Fore.CYAN + "Summary" + Style.RESET_ALL)
print(Style.BRIGHT + f"Passed: {n_passed}" + Style.RESET_ALL)
print(Style.BRIGHT + f"Failed: {n_total - n_passed}" + Style.RESET_ALL)
failing = [rel for rel, passed in results.items() if not passed]
if a.verbose or failing:
status_width = len("Result")
@@ -193,6 +190,9 @@ def main():
Fore.RED + plain_status.ljust(status_width) + Style.RESET_ALL
print(f"| {rel.ljust(path_width)} | {status} |")
print(separator)
print("\n" + Style.BRIGHT + Fore.CYAN + "Summary" + Style.RESET_ALL)
print(Style.BRIGHT + f"Passed: {n_passed}" + Style.RESET_ALL)
print(Style.BRIGHT + f"Failed: {n_total - n_passed}" + Style.RESET_ALL)
if a.verbose:
print_average_pim_pass_timings(
pass_timing_sums,