Skip to content

Commit

Permalink
address comment
Browse files Browse the repository at this point in the history
  • Loading branch information
kaizhangNV committed Jan 2, 2025
1 parent 91b1943 commit ef8e4d4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
20 changes: 11 additions & 9 deletions source/slang/slang-ir-autodiff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,20 +126,22 @@ static IRInst* _getDiffTypeWitnessFromPairType(

bool isNoDiffType(IRType* paramType)
{
if (auto attrType = as<IRAttributedType>(paramType))
for(;;)
{
if (attrType->findAttr<IRNoDiffAttr>())
return true;
}

while (auto ptrType = as<IRPtrTypeBase>(paramType))
{
paramType = ptrType->getValueType();

if (auto attrType = as<IRAttributedType>(paramType))
{
if (attrType->findAttr<IRNoDiffAttr>())
return true;

paramType = attrType->getBaseType();
}
else if (auto ptrType = as<IRPtrTypeBase>(paramType))
{
paramType = ptrType->getValueType();
}
else
{
return false;
}
}
return false;
Expand Down
2 changes: 1 addition & 1 deletion tests/autodiff/nodiff-ptr.slang
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ float sumOfSquares(float x, float y, no_diff float4* test)
return x * x + y * y * (test->x + test->y + test->z);
}

//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj -output-using-type -compile-arg -skip-spirv-validation
//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj -output-using-type -compile-arg -skip-spirv-validation -emit-spirv-directly

//TEST_INPUT:ubuffer(data=[1.0 2.0 3.0 1.0 1.0 0.0 0.0 0.0], stride=4):out, name outputBuffer
RWStructuredBuffer<float4> outputBuffer;
Expand Down

0 comments on commit ef8e4d4

Please sign in to comment.