summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorSai Praveen Bangaru <31557731+saipraveenb25@users.noreply.github.com>2025-02-04 18:41:11 -0800
committerGitHub <noreply@github.com>2025-02-04 21:41:11 -0500
commitfe77f076b46f45d6c89ab8592d0ff548bda223de (patch)
tree53159ad0daa43244142ba3da9d3938b6d3d23e33 /source
parent78a6389aa4b01cfe4f8b4ec34d48b2cbfc092865 (diff)
Fix non-square matrix derivatives (#6282)
Diffstat (limited to 'source')
-rw-r--r--source/slang/slang-ir-autodiff-transpose.h7
1 files changed, 3 insertions, 4 deletions
diff --git a/source/slang/slang-ir-autodiff-transpose.h b/source/slang/slang-ir-autodiff-transpose.h
index a5ed5814c..5e96c4e0f 100644
--- a/source/slang/slang-ir-autodiff-transpose.h
+++ b/source/slang/slang-ir-autodiff-transpose.h
@@ -1812,8 +1812,8 @@ struct DiffTransposePass
{
List<RevGradient> gradients;
auto matrixType = as<IRMatrixType>(fwdMakeMatrix->getDataType());
- auto row = as<IRIntLit>(matrixType->getRowCount());
auto colCount = matrixType->getColumnCount();
+ auto colCountVal = as<IRIntLit>(matrixType->getColumnCount())->getValue();
IRType* rowVectorType = nullptr;
for (UIndex ii = 0; ii < fwdMakeMatrix->getOperandCount(); ii++)
{
@@ -1828,9 +1828,8 @@ struct DiffTransposePass
}
else
{
- SLANG_RELEASE_ASSERT(row);
- UInt rowIndex = ii / (UInt)row->getValue();
- UInt colIndex = ii % (UInt)row->getValue();
+ UInt rowIndex = ii / (UInt)colCountVal;
+ UInt colIndex = ii % (UInt)colCountVal;
if (!rowVectorType)
rowVectorType = builder->getVectorType(matrixType->getElementType(), colCount);
auto revRow = builder->emitElementExtract(