Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions backends/cadence/aot/tests/test_replace_ops_passes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1242,9 +1242,17 @@ def test_replace_conv1d_with_linear(self) -> None:
self.assertTrue(result.modified)
graph_after_passes = result.graph_module

# Validate numerical accuracy
# Conv and linear compute the same dot product but accumulate fp32
# terms in different order, so non-associativity of floating-point
# addition produces diffs up to ~1.2e-05. Use rtol=2e-05.
inputs = [x, weights, bias]
validate(gm_before, graph_after_passes, inputs, "ReplaceTrivialConvWithLinear")
validate(
gm_before,
graph_after_passes,
inputs,
"ReplaceTrivialConvWithLinear",
rtol=2e-5,
)

# Assert that conv1d is trivially converted to linear
self.assertEqual(
Expand Down Expand Up @@ -1278,9 +1286,17 @@ def test_replace_conv2d_with_linear(self) -> None:
self.assertTrue(result.modified)
graph_after_passes = result.graph_module

# Validate numerical accuracy
# Conv and linear compute the same dot product but accumulate fp32
# terms in different order, so non-associativity of floating-point
# addition produces diffs up to ~1.2e-05. Use rtol=2e-05.
inputs = [x, weights, bias]
validate(gm_before, graph_after_passes, inputs, "ReplaceTrivialConvWithLinear")
validate(
gm_before,
graph_after_passes,
inputs,
"ReplaceTrivialConvWithLinear",
rtol=2e-5,
)

# Assert that conv2d is trivially converted to linear
self.assertEqual(
Expand Down
Loading