-
Notifications
You must be signed in to change notification settings - Fork 244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Check whether array element is fully specialized #6000
Merged
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f45cd07
Check whether array element is fully specialized
fac1fa5
add test
kaizhangNV 4c70c8e
add all wrapper types into the check
kaizhangNV 0431e56
add utility function to check if the type is wrapper type
kaizhangNV d68304a
Merge branch 'master' into spec_array
csyonghe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj -output-using-type | ||
//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -profile sm_6_0 -use-dxil -output-using-type | ||
//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -cuda -shaderobj -output-using-type | ||
//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -cpu -shaderobj -output-using-type | ||
//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -wgpu -output-using-type | ||
// | ||
struct WrappedBuffer<T : IDifferentiable> | ||
{ | ||
StructuredBuffer<T> buffer; | ||
int shape; | ||
|
||
T get(int idx) { return buffer[idx]; } | ||
} | ||
|
||
struct GradInBuffer<T : IDifferentiable> | ||
{ | ||
WrappedBuffer<T.Differential> grad_in; | ||
} | ||
|
||
struct CallData | ||
{ | ||
WrappedBuffer<float[1]> grad_in; | ||
} | ||
|
||
|
||
//TEST_INPUT: set call_data.grad_in.buffer = ubuffer(data=[1.0 2.0], stride=4); | ||
ParameterBlock<CallData> call_data; | ||
|
||
|
||
//TEST_INPUT:ubuffer(data=[0.0 0.0], stride=4):out, name outputBuffer | ||
RWStructuredBuffer<float> outputBuffer; | ||
|
||
|
||
[shader("compute")] | ||
[numthreads(1, 1, 1)] | ||
void computeMain() | ||
{ | ||
|
||
float[1] data1 = call_data.grad_in.buffer[0]; | ||
float[1] data2 = call_data.grad_in.get(1); | ||
outputBuffer[0] = data1[0]; | ||
outputBuffer[1] = data2[0]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
type: float | ||
1.000000 | ||
2.000000 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder why this case is necessary.
If we have an type that is
T.Differential[N]
, then it shall be encoded asIRArrayType(IRLookupWitness(w, "Differential"), N)
, and sinceIRLookupWitness
has operandw
, it won't appear in global scope, and therefore the IRArrayType itself won't appear directly in the global scope, and therefore it won't be reported astrue
by the default case logic.Basically, if the element type is not fully specialized, then the array type itself shouldn't appear in the global scope. What IR are you seeing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this case this necessary, the unit test can reproduce the case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ask this question because in theory this shouldn’t happen, otherwise we will have the same issue for Ptr type and all other kinds of wrapper types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you dump the IR from the unit test, you will find out:
this could result as:
and finally this lookup table will give us
here is the case I need to handle.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. In this case we do need to also handle all other opcodes by recursively checking their operands. Because we could have PtrType(lookupWitness()), or ArrayType(int, lookupwitness()), etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I always hit this:
not sure what's wrong regarding extending Array to conform to IFoo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In your syntax you specified
T:IFoo
, sincefloat !: IFoo
,Array<float,1> !: IFoo
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see the problem, I forgot removing that line.
OK, I will see if I can craft a shader to reproduce this issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For a repro, you probably need to define an associatedtype in the interface for lookupwitness to occur inside an array type
for example, something like:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wrote another shader a little bit different from yours, but now I can get stable reproduce.