diff options
| author | Yong He <yonghe@outlook.com> | 2025-07-29 19:26:52 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-29 19:26:52 -0700 |
| commit | b8663a5d93e6e73d5e2d7e737cffd1efac055719 (patch) | |
| tree | 21eedc0d19065306eb4de7e1be8d00d1045ee032 /tests | |
| parent | 48efc60380aa79e8c4aba13976cc2015f38a659e (diff) | |
Fix ICE when immutable value is passed to a bwd_diff function. (#7973)
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/diagnostics/implicit-cast-lvalue.slang.expected | 1 | ||||
| -rw-r--r-- | tests/diagnostics/lvalue-in-bwd-diff.slang | 23 | ||||
| -rw-r--r-- | tests/diagnostics/methods/mutating-method-on-rvalue.slang.expected | 1 |
3 files changed, 23 insertions, 2 deletions
diff --git a/tests/diagnostics/implicit-cast-lvalue.slang.expected b/tests/diagnostics/implicit-cast-lvalue.slang.expected index 93217b239..10ebfc656 100644 --- a/tests/diagnostics/implicit-cast-lvalue.slang.expected +++ b/tests/diagnostics/implicit-cast-lvalue.slang.expected @@ -7,7 +7,6 @@ tests/diagnostics/implicit-cast-lvalue.slang(19): error 30047: argument passed t a(y); ^ tests/diagnostics/implicit-cast-lvalue.slang(19): note 30063: argument was implicitly cast from 'double' to 'float', and Slang does not support using an implicit cast as an l-value with this type -tests/diagnostics/implicit-cast-lvalue.slang(19): note 30049: attempting to assign to a const variable or immutable member; use '[mutating]' attribute on the containing method to allow modification } standard output = { } diff --git a/tests/diagnostics/lvalue-in-bwd-diff.slang b/tests/diagnostics/lvalue-in-bwd-diff.slang new file mode 100644 index 000000000..2e12bf5c0 --- /dev/null +++ b/tests/diagnostics/lvalue-in-bwd-diff.slang @@ -0,0 +1,23 @@ +//TEST:SIMPLE(filecheck=CHECK): -target spirv +[Differentiable] +float square(float x, float y) +{ + return x * x + y * y; +} + +void main() +{ + // Forward mode differentiation + let x = diffPair(3.0, 1.0); // x = 3, 𝜕x/𝜕𝛉 = 1 + let y = diffPair(4.0, 1.0); // y = 4, 𝜕y/𝜕𝛄 = 1 + let result = fwd_diff(square)(x, y); + printf("dResult: %f\n", result.d); + + // Backward mode differentiation + let dLdSquare = 1.0f; + // CHECK-NOT: error 30049 + // CHECK: error 30047 + // CHECK-NOT: error 30049 + bwd_diff(square)(x, y, dLdSquare); + printf("dL/dx: %f, dL/dy: %f\n", x.d, y.d); +} diff --git a/tests/diagnostics/methods/mutating-method-on-rvalue.slang.expected b/tests/diagnostics/methods/mutating-method-on-rvalue.slang.expected index d9694276b..066c8439d 100644 --- a/tests/diagnostics/methods/mutating-method-on-rvalue.slang.expected +++ b/tests/diagnostics/methods/mutating-method-on-rvalue.slang.expected @@ -7,7 +7,6 @@ tests/diagnostics/methods/mutating-method-on-rvalue.slang(13): note 30049: attem tests/diagnostics/methods/mutating-method-on-rvalue.slang(25): error 30050: mutating method 'increment' cannot be called on an immutable value gCounter.increment(); ^ -tests/diagnostics/methods/mutating-method-on-rvalue.slang(25): note 30049: attempting to assign to a const variable or immutable member; use '[mutating]' attribute on the containing method to allow modification } standard output = { } |
