image.domain\self_evolve\propagation.mbt
70.5% · 31 / 44 points · 147 linesBackground color reports the state of each line. Underlined characters mark exact instrumented byte offsets; hover them to inspect the visit count.
- 1
///| - 2
/// # 传播 self_evolve/propagation - 3
/// - 4
/// 图像处理库子模块 - 5
/// 图像处理库子模块 Image processing library submodule - 6
// 跨算子退化传播 — 分析 pipeline 中退化如何在算子间传播 - 7
// Cross-op degradation propagation: analyze how degradations propagate across pipeline - 8
// - 9
// Phase 7 v291: 将根因分析从"单算子"推向"跨算子传播链" — 退化如何在管道中传播。 - 10
- 11
///| - 12
/// 单个退化传播步骤。 - 13
/// 描述 Single degradation propagation step. - 14
#derive(Eq, @debug.Debug) - 15
pub(all) struct PropagationStep { - 16
from_op_tag : String - 17
to_op_tag : String - 18
degradation_kind : DegradationKind - 19
propagation_desc : String - 20
} - 21
- 22
///| - 23
pub extend PropagationStep with @debug.Debug::{to_repr} - 24
- 25
///| - 26
pub extend PropagationStep with Eq::{not_equal, equal} - 27
- 28
///| - 29
/// 退化传播报告。 - 30
/// 描述 Degradation propagation report. - 31
#derive(Eq, @debug.Debug) - 32
pub(all) struct PropagationReport { - 33
steps : Array[PropagationStep] - 34
total_propagations : Int32 - 35
chain_length : Int32 - 36
summary : String - 37
} - 38
- 39
///| - 40
pub extend PropagationReport with @debug.Debug::{to_repr} - 41
- 42
///| - 43
pub extend PropagationReport with Eq::{not_equal, equal} - 44
- 45
///| - 46
/// 分析管道中退化传播链。 - 47
/// 描述 Analyze degradation propagation chain in a pipeline. - 48
pub fn analyze_propagation(pipeline : @imgir.IRPipeline) -> PropagationReport { - 49●
let steps : Array[PropagationStep] = [] - 50
let ops = pipeline.ops - 51●
let n = ops.length() - 52
for i in 0..<n { - 53●
let degs = detect_degradation(ops[i]) - 54●
if degs.length() > 0 && i + 1 < n { - 55●
let from_tag = ops[i].tag() - 56●
let to_tag = ops[i + 1].tag() - 57
for d in degs { - 58●
let desc = match d.kind { - 59
DivisionByZero => - 60●
"除零退化从 " + from_tag + " 传播至 " + to_tag - 61
SingularMatrix => - 62○
"奇异矩阵从 " + from_tag + " 传播至 " + to_tag - 63
FieldDiscontinuity => - 64●
"场间断从 " + from_tag + " 传播至 " + to_tag - 65○
Overflow => "溢出从 " + from_tag + " 传播至 " + to_tag - 66○
NaNValue => "NaN 从 " + from_tag + " 传播至 " + to_tag - 67○
InfValue => "Inf 从 " + from_tag + " 传播至 " + to_tag - 68
} - 69●
steps.push({ - 70
from_op_tag: from_tag, - 71
to_op_tag: to_tag, - 72
degradation_kind: d.kind, - 73
propagation_desc: desc, - 74
}) - 75
} - 76
} - 77
} - 78●
let total = steps.length() - 79●
let chain_length = if total > 0 { n } else { 0 } - 80
let summary = "传播分析: " + - 81●
total.to_string() + - 82
" 处退化传播, 链长 " + - 83●
chain_length.to_string() + - 84
"(管道 " + - 85●
@imgir.ir_describe(pipeline) + - 86
")" - 87
{ steps, total_propagations: total, chain_length, summary, } - 88
} - 89
- 90
///| - 91
/// 对全部 19 种算子的相邻组合分析传播。 - 92
/// 描述 Analyze propagation for all adjacent op combinations. - 93
pub fn analyze_propagation_all() -> PropagationReport { - 94●
let ops = all_ops() - 95
let steps : Array[PropagationStep] = [] - 96●
let n = ops.length() - 97
for i in 0..<(n - 1) { - 98●
let from_tag = ops[i].tag() - 99●
let to_tag = ops[i + 1].tag() - 100●
let degs = detect_degradation(ops[i]) - 101
for d in degs { - 102○
let desc = match d.kind { - 103○
DivisionByZero => "除零退化从 " + from_tag + " 传播至 " + to_tag - 104○
SingularMatrix => "奇异矩阵从 " + from_tag + " 传播至 " + to_tag - 105
FieldDiscontinuity => - 106○
"场间断从 " + from_tag + " 传播至 " + to_tag - 107○
Overflow => "溢出从 " + from_tag + " 传播至 " + to_tag - 108○
NaNValue => "NaN 从 " + from_tag + " 传播至 " + to_tag - 109○
InfValue => "Inf 从 " + from_tag + " 传播至 " + to_tag - 110
} - 111○
steps.push({ - 112
from_op_tag: from_tag, - 113
to_op_tag: to_tag, - 114
degradation_kind: d.kind, - 115
propagation_desc: desc, - 116
}) - 117
} - 118
} - 119●
let total = steps.length() - 120
let summary = "全算子传播分析: " + - 121●
total.to_string() + - 122
" 处退化传播" - 123
{ steps, total_propagations: total, chain_length: n, summary, } - 124
} - 125
- 126
///| - 127
/// 管道是否有传播风险。 - 128
/// 描述 Whether pipeline has propagation risk. - 129
pub fn has_propagation_risk(pipeline : @imgir.IRPipeline) -> Bool { - 130●
analyze_propagation(pipeline).total_propagations > 0 - 131
} - 132
- 133
///| - 134
/// 获取管道的传播链。 - 135
/// 获取 Get propagation chain of a pipeline. - 136
pub fn propagation_chain( - 137
pipeline : @imgir.IRPipeline, - 138
) -> Array[PropagationStep] { - 139●
analyze_propagation(pipeline).steps - 140
} - 141
- 142
///| - 143
/// 传播报告是否无风险。 - 144
/// 描述 Whether propagation report has no risk. - 145
pub fn PropagationReport::is_safe(self : PropagationReport) -> Bool { - 146●
self.total_propagations == 0 - 147
}