-
Notifications
You must be signed in to change notification settings - Fork 21.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update on "Generate type match guard for torch.Size input"
I suppose hypothetically, if the user code ends up working polymorphically over the SizeVariable, in such a way that a tuple would work, this type match is not necessary. But we do not carefully test for this. Signed-off-by: Edward Z. Yang <ezyangmeta.com> cc soumith voznesenskym penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx desertfire [ghstack-poisoned]
- Loading branch information
Showing
42 changed files
with
1,208 additions
and
386 deletions.
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,39 @@ | ||
#version 450 core | ||
#define PRECISION $precision | ||
#define FORMAT $format | ||
|
||
layout(std430) buffer; | ||
|
||
/* Qualifiers: layout - storage - precision - memory */ | ||
|
||
/* | ||
* Output Image | ||
*/ | ||
layout(set = 0, binding = 0, FORMAT) uniform PRECISION restrict writeonly image3D uOutput; | ||
|
||
/* | ||
* Input Buffer | ||
*/ | ||
layout(set = 0, binding = 1) uniform PRECISION sampler3D uInput; | ||
|
||
/* | ||
* Params Buffer | ||
*/ | ||
layout(set = 0, binding = 2) uniform PRECISION restrict Block { | ||
// batch_info.x: number of texels per batch | ||
// batch_info.y: index along batch dim to select | ||
ivec2 batch_info; | ||
} | ||
uBlock; | ||
|
||
/* | ||
* Local Work Group Size | ||
*/ | ||
layout(local_size_x_id = 0, local_size_y_id = 1, local_size_z_id = 2) in; | ||
|
||
void main() { | ||
const ivec3 pos = ivec3(gl_GlobalInvocationID); | ||
const uint src_pos_z = (uBlock.batch_info.y * uBlock.batch_info.x) + pos.z; | ||
imageStore( | ||
uOutput, pos, texelFetch(uInput, ivec3(pos.x, pos.y, src_pos_z), 0)); | ||
} |
This file was deleted.
Oops, something went wrong.
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,32 @@ | ||
#version 450 core | ||
#define PRECISION $precision | ||
#define FORMAT $format | ||
|
||
layout(std430) buffer; | ||
|
||
/* Qualifiers: layout - storage - precision - memory */ | ||
|
||
layout(set = 0, binding = 0, FORMAT) uniform PRECISION restrict writeonly image3D uOutput; | ||
layout(set = 0, binding = 1) uniform PRECISION sampler3D uInput; | ||
layout(set = 0, binding = 2) uniform PRECISION restrict Block { | ||
// depth_info.x: output texture x extent | ||
// depth_info.y: output texture y extent | ||
// depth_info.z: output texture z extent | ||
// depth_info.w: output texture w extent | ||
ivec4 depth_info; | ||
} | ||
uBlock; | ||
|
||
layout(local_size_x_id = 0, local_size_y_id = 1, local_size_z_id = 2) in; | ||
|
||
void main() { | ||
const ivec3 pos = ivec3(gl_GlobalInvocationID); | ||
|
||
if (all(lessThan(pos, uBlock.depth_info.xyz))) { | ||
const int tex = uBlock.depth_info.w / 4; | ||
const int ind = uBlock.depth_info.w % 4; | ||
const float v = texelFetch(uInput, ivec3(pos.x, pos.y, tex), 0)[ind]; | ||
|
||
imageStore(uOutput, ivec3(pos.x, pos.y, 0), vec4(v, 0, 0, 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,53 @@ | ||
#version 450 core | ||
#define PRECISION $precision | ||
#define FORMAT $format | ||
|
||
layout(std430) buffer; | ||
|
||
/* Qualifiers: layout - storage - precision - memory */ | ||
|
||
/* | ||
* Output Image | ||
*/ | ||
layout(set = 0, binding = 0, FORMAT) uniform PRECISION restrict writeonly image3D uOutput; | ||
|
||
/* | ||
* Input Buffer | ||
*/ | ||
layout(set = 0, binding = 1) uniform PRECISION sampler3D uInput; | ||
|
||
/* | ||
* Params Buffer | ||
*/ | ||
layout(set = 0, binding = 2) uniform PRECISION restrict Block { | ||
// depth_info.x: number of batches | ||
// depth_info.y: number of texels per batch | ||
// depth_info.z: index along channel dim to select | ||
// depth_info.w: zero pad for alignment | ||
ivec4 depth_info; | ||
} | ||
uBlock; | ||
|
||
/* | ||
* Local Work Group Size | ||
*/ | ||
layout(local_size_x_id = 0, local_size_y_id = 1, local_size_z_id = 2) in; | ||
|
||
void main() { | ||
const ivec3 pos = ivec3(gl_GlobalInvocationID); | ||
// read in the same channel from 4 separate batches | ||
vec4 out_texel = vec4(0, 0, 0, 0); | ||
for (int k = 0; k < 4; k++) { | ||
if ((k + pos.z * 4) >= | ||
uBlock.depth_info.x) { // < 4 batches for this texel, exit early | ||
break; | ||
} | ||
const uint src_pos_z = (4 * uBlock.depth_info.y * pos.z) + | ||
(k * uBlock.depth_info.y) + (uBlock.depth_info.z / 4); | ||
const uint src_pos_t = uBlock.depth_info.z % 4; | ||
out_texel[k] = | ||
texelFetch(uInput, ivec3(pos.x, pos.y, src_pos_z), 0)[src_pos_t]; | ||
} | ||
|
||
imageStore(uOutput, pos, out_texel); | ||
} |
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,51 @@ | ||
#version 450 core | ||
#define PRECISION $precision | ||
#define FORMAT $format | ||
|
||
layout(std430) buffer; | ||
|
||
/* Qualifiers: layout - storage - precision - memory */ | ||
|
||
/* | ||
* Output Image | ||
*/ | ||
layout(set = 0, binding = 0, FORMAT) uniform PRECISION restrict writeonly image3D uOutput; | ||
|
||
/* | ||
* Input Buffer | ||
*/ | ||
layout(set = 0, binding = 1) uniform PRECISION sampler3D uInput; | ||
|
||
/* | ||
* Params Buffer | ||
*/ | ||
layout(set = 0, binding = 2) uniform PRECISION restrict Block { | ||
// height_info.x: number of batches | ||
// height_info.y: number of texels per batch | ||
// height_info.z: index along height dim to select | ||
// height_info.w: zero pad for alignment | ||
ivec4 height_info; | ||
} | ||
uBlock; | ||
|
||
/* | ||
* Local Work Group Size | ||
*/ | ||
layout(local_size_x_id = 0, local_size_y_id = 1, local_size_z_id = 2) in; | ||
|
||
void main() { | ||
const ivec3 pos = ivec3(gl_GlobalInvocationID); | ||
vec4 out_texel = vec4(0, 0, 0, 0); | ||
// read in the same channel from 4 separate batches | ||
for (int k = 0; k < 4; k++) { | ||
if ((k + pos.z * 4) >= | ||
uBlock.height_info.x) { // < 4 batches for this texel, exit early | ||
break; | ||
} | ||
const uint src_pos_z = (pos.z * uBlock.height_info.y * 4) + | ||
k * uBlock.height_info.y + (pos.y / 4); | ||
out_texel[k] = texelFetch( | ||
uInput, ivec3(pos.x, uBlock.height_info.z, src_pos_z), 0)[pos.y % 4]; | ||
} | ||
imageStore(uOutput, pos, out_texel); | ||
} |
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,51 @@ | ||
#version 450 core | ||
#define PRECISION $precision | ||
#define FORMAT $format | ||
|
||
layout(std430) buffer; | ||
|
||
/* Qualifiers: layout - storage - precision - memory */ | ||
|
||
/* | ||
* Output Image | ||
*/ | ||
layout(set = 0, binding = 0, FORMAT) uniform PRECISION restrict writeonly image3D uOutput; | ||
|
||
/* | ||
* Input Buffer | ||
*/ | ||
layout(set = 0, binding = 1) uniform PRECISION sampler3D uInput; | ||
|
||
/* | ||
* Params Buffer | ||
*/ | ||
layout(set = 0, binding = 2) uniform PRECISION restrict Block { | ||
// width_info.x: number of batches | ||
// width_info.y: number of texels per batch | ||
// width_info.z: index along width dim to select | ||
// width_info.w: zero pad for alignment | ||
ivec4 width_info; | ||
} | ||
uBlock; | ||
|
||
/* | ||
* Local Work Group Size | ||
*/ | ||
layout(local_size_x_id = 0, local_size_y_id = 1, local_size_z_id = 2) in; | ||
|
||
void main() { | ||
const ivec3 pos = ivec3(gl_GlobalInvocationID); | ||
vec4 out_texel = vec4(0, 0, 0, 0); | ||
// read in the same channel from 4 separate batches | ||
for (int k = 0; k < 4; k++) { | ||
if ((k + pos.z * 4) >= | ||
uBlock.width_info.x) { // < 4 batches for this texel, exit early | ||
break; | ||
} | ||
const uint src_pos_z = (pos.z * uBlock.width_info.y * 4) + | ||
k * uBlock.width_info.y + (pos.y / 4); | ||
out_texel[k] = texelFetch( | ||
uInput, ivec3(uBlock.width_info.z, pos.x, src_pos_z), 0)[pos.y % 4]; | ||
} | ||
imageStore(uOutput, pos, out_texel); | ||
} |
Oops, something went wrong.