diff options
| author | Sai Praveen Bangaru <31557731+saipraveenb25@users.noreply.github.com> | 2023-10-20 21:21:30 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-10-20 18:21:30 -0700 |
| commit | d8f4c9424c69a3d406fabf56a25dd3eda4bc7d51 (patch) | |
| tree | 88f3fdb6fdf4450a8f406183aa8ba05df706c247 /source | |
| parent | d001a7b5eee4400150816e9962adaff183bfff35 (diff) | |
Fix issue with transposing `IRMakeVector` with non-singleton operands (#3280)
Diffstat (limited to 'source')
| -rw-r--r-- | source/slang/slang-ir-autodiff-transpose.h | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/source/slang/slang-ir-autodiff-transpose.h b/source/slang/slang-ir-autodiff-transpose.h index bcebd2108..a3a4eb2b3 100644 --- a/source/slang/slang-ir-autodiff-transpose.h +++ b/source/slang/slang-ir-autodiff-transpose.h @@ -1841,6 +1841,7 @@ struct DiffTransposePass TranspositionResult transposeMakeVector(IRBuilder* builder, IRInst* fwdMakeVector, IRInst* revValue) { List<RevGradient> gradients; + UInt offset = 0; for (UIndex ii = 0; ii < fwdMakeVector->getOperandCount(); ii++) { auto argOperand = fwdMakeVector->getOperand(ii); @@ -1857,12 +1858,12 @@ struct DiffTransposePass gradAtIndex = builder->emitElementExtract( argOperand->getDataType(), revValue, - builder->getIntValue(builder->getIntType(), ii)); + builder->getIntValue(builder->getIntType(), offset)); } else { ShortList<UInt> componentIndices; - for (UInt index = ii; index < ii + componentCount; index++) + for (UInt index = offset; index < offset + componentCount; index++) componentIndices.add(index); gradAtIndex = builder->emitSwizzle( argOperand->getDataType(), @@ -1876,6 +1877,8 @@ struct DiffTransposePass fwdMakeVector->getOperand(ii), gradAtIndex, fwdMakeVector)); + + offset += componentCount; } // (A = float3(X, Y, Z)) -> [(dX += dA), (dY += dA), (dZ += dA)] |
