minor validate.py fix
This commit is contained in:
@@ -42,6 +42,17 @@ static bool hasCapacityFor(Operation* producer, Operation* consumer) {
|
|||||||
return getCrossbarUnionSize(producerWeights, consumerWeights) <= static_cast<size_t>(crossbarCountInCore.getValue());
|
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 {
|
struct TrivialGraphMergeStats {
|
||||||
size_t scalarBefore = 0;
|
size_t scalarBefore = 0;
|
||||||
size_t batchBefore = 0;
|
size_t batchBefore = 0;
|
||||||
@@ -153,7 +164,8 @@ struct MergeTrivialScalarComputes : OpRewritePattern<SpatGraphCompute> {
|
|||||||
for (Value input : consumer.getInputs()) {
|
for (Value input : consumer.getInputs()) {
|
||||||
auto candidate = input.getDefiningOp<SpatGraphCompute>();
|
auto candidate = input.getDefiningOp<SpatGraphCompute>();
|
||||||
if (candidate && candidate->getBlock() == consumer->getBlock() && hasOnlyStructuralAttrs(candidate)
|
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)
|
&& hasCapacityFor(candidate, consumer) && hasNoNestedArgumentCaptures(candidate)
|
||||||
&& hasNoNestedArgumentCaptures(consumer)) {
|
&& hasNoNestedArgumentCaptures(consumer)) {
|
||||||
producer = candidate;
|
producer = candidate;
|
||||||
@@ -319,7 +331,8 @@ struct FoldBatchLeadingUnitNormalization : OpRewritePattern<SpatGraphCompute> {
|
|||||||
? SpatGraphComputeBatch()
|
? SpatGraphComputeBatch()
|
||||||
: consumer.getInputs().front().getDefiningOp<SpatGraphComputeBatch>();
|
: consumer.getInputs().front().getDefiningOp<SpatGraphComputeBatch>();
|
||||||
if (!producer || producer->getBlock() != consumer->getBlock() || !hasOnlyStructuralAttrs(producer)
|
if (!producer || producer->getBlock() != consumer->getBlock() || !hasOnlyStructuralAttrs(producer)
|
||||||
|| !hasOnlyStructuralAttrs(consumer) || !isExclusivelyConsumedBy(producer, consumer))
|
|| !hasOnlyStructuralAttrs(consumer) || !isUniqueGraphComputePredecessor(producer, consumer)
|
||||||
|
|| !isExclusivelyConsumedBy(producer, consumer))
|
||||||
return failure();
|
return failure();
|
||||||
auto fragments = collectPublishedFragments(producer);
|
auto fragments = collectPublishedFragments(producer);
|
||||||
if (!matchLeadingUnitNormalization(producer, consumer) || failed(fragments))
|
if (!matchLeadingUnitNormalization(producer, consumer) || failed(fragments))
|
||||||
@@ -394,7 +407,8 @@ struct MergeTrivialBatchComputes : OpRewritePattern<SpatGraphComputeBatch> {
|
|||||||
auto candidate = input.getDefiningOp<SpatGraphComputeBatch>();
|
auto candidate = input.getDefiningOp<SpatGraphComputeBatch>();
|
||||||
if (candidate && candidate->getBlock() == consumer->getBlock()
|
if (candidate && candidate->getBlock() == consumer->getBlock()
|
||||||
&& candidate.getLaneCount() == consumer.getLaneCount() && hasOnlyStructuralAttrs(candidate)
|
&& 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)
|
&& hasCapacityFor(candidate, consumer) && hasDirectLaneConsumers(candidate, consumer)
|
||||||
&& succeeded(fragments = collectPublishedFragments(candidate))) {
|
&& succeeded(fragments = collectPublishedFragments(candidate))) {
|
||||||
producer = candidate;
|
producer = candidate;
|
||||||
@@ -462,7 +476,7 @@ struct TrivialGraphComputeMergePass final : PassWrapper<TrivialGraphComputeMerge
|
|||||||
|
|
||||||
StringRef getArgument() const override { return "pim-trivial-graph-compute-merge"; }
|
StringRef getArgument() const override { return "pim-trivial-graph-compute-merge"; }
|
||||||
StringRef getDescription() const override {
|
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 {
|
void runOnOperation() override {
|
||||||
|
|||||||
@@ -174,9 +174,6 @@ def main():
|
|||||||
# Summary
|
# Summary
|
||||||
n_passed = sum(1 for passed in results.values() if passed)
|
n_passed = sum(1 for passed in results.values() if passed)
|
||||||
n_total = len(results)
|
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]
|
failing = [rel for rel, passed in results.items() if not passed]
|
||||||
if a.verbose or failing:
|
if a.verbose or failing:
|
||||||
status_width = len("Result")
|
status_width = len("Result")
|
||||||
@@ -193,6 +190,9 @@ def main():
|
|||||||
Fore.RED + plain_status.ljust(status_width) + Style.RESET_ALL
|
Fore.RED + plain_status.ljust(status_width) + Style.RESET_ALL
|
||||||
print(f"| {rel.ljust(path_width)} | {status} |")
|
print(f"| {rel.ljust(path_width)} | {status} |")
|
||||||
print(separator)
|
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:
|
if a.verbose:
|
||||||
print_average_pim_pass_timings(
|
print_average_pim_pass_timings(
|
||||||
pass_timing_sums,
|
pass_timing_sums,
|
||||||
|
|||||||
Reference in New Issue
Block a user