summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-check-conversion.cpp
diff options
context:
space:
mode:
authorCopilot <198982749+Copilot@users.noreply.github.com>2025-07-16 08:57:54 -0700
committerGitHub <noreply@github.com>2025-07-16 15:57:54 +0000
commit73f9aeb838bfaeaeae2c46d94000a4f98da47cea (patch)
tree9cfef27c22749a5746b5fc60b4e959532966af1c /source/slang/slang-check-conversion.cpp
parent80f43f43466a46a5795ad44e5096d99e12c2a0da (diff)
Fix duplicate DiffPair struct generation for row_major matrices in autodiff (#7728)
* Initial plan * Fix duplicate DiffPair struct generation for row_major matrices in autodiff Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Fix matrix layout conversion to use BuiltinCastExpr Address root cause in slang-check-conversion.cpp by creating proper cast expressions for matrix layout conversions instead of reusing expressions. This ensures autodiff sees proper type conversions and generates consistent DiffPair structs. Reverted the band-aid fix in autodiff system and implemented the proper front-end fix as suggested in code review. Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Fix test to prevent dead code elimination and make it executable on CPU Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Fix spirv emit of matrix layout cast insts. * Update test. * cleanup test. * Improve test with meaningful values that verify correct gradient computation Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'source/slang/slang-check-conversion.cpp')
-rw-r--r--source/slang/slang-check-conversion.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/source/slang/slang-check-conversion.cpp b/source/slang/slang-check-conversion.cpp
index 6456dbe98..3ace9f999 100644
--- a/source/slang/slang-check-conversion.cpp
+++ b/source/slang/slang-check-conversion.cpp
@@ -1430,7 +1430,11 @@ bool SemanticsVisitor::_coerce(
}
if (outToExpr)
{
- *outToExpr = fromExpr;
+ auto castExpr = getASTBuilder()->create<BuiltinCastExpr>();
+ castExpr->type = toType;
+ castExpr->loc = fromExpr->loc;
+ castExpr->base = fromExpr;
+ *outToExpr = castExpr;
}
return true;
}