Skip to content

Conversation

salilsdesai
Copy link
Contributor

@salilsdesai salilsdesai commented Jan 9, 2023

Stack from ghstack (oldest at bottom):

@bypass-github-export-checks

This diff allows for adding entries to the shader registry by specifying which op names and registry keys should map to a template codegen Shader in the codegen Shader's glslt and params yaml files.

This can be done by

  • adding a REGISTER_FOR entry which maps to either a tuple of (op name, list of registry keys) or null to the YAML file, and
  • adding a REGISTER_FOR = $REGISTER_FOR line to the ShaderInfo comment in the glslt file

Ex.

YAML File:

conv2d_pw:
  parameter_names_with_default_values:
      ...
      REGISTER_FOR:
        - !!python/tuple ["conv2d_pw", ["catchall"]]
  parameter_values:
    - ...
      REGISTER_FOR: null

GLSLT File:

...
 * REGISTER_FOR = $REGISTER_FOR
...

This diff also registers the conv2d_pw_2x2 Shader under 'conv2d_pw → 'catchall' in the registry and uses VK_REGISTRY_KERNEL to retrieve the shader by look up in the registry

The shader registry generated in spv.cpp now looks like

ShaderRegistry shader_registry = {
        {"conv2d", {{"catchall", "conv2d"}}},
        {"conv2d_pw", {{"catchall", "conv2d_pw_2x2"}}}};

and the generated conv2d_p2_KxK.glsl files look like:
K=1

...
/*
 * TILE_SIZE = (1, 1, 1)
 * WEIGHT_STORAGE = TEXTURE_2D
 * WEIGHT_STORAGE_LAYOUT = OC4,IC4,4ic,4oc
 * BIAS_STORAGE = TEXTURE_2D
 * REGISTER_FOR = None
 */
...

K=2

...
/*
 * TILE_SIZE = (2, 2, 1)
 * WEIGHT_STORAGE = TEXTURE_2D
 * WEIGHT_STORAGE_LAYOUT = OC4,IC4,4ic,4oc
 * BIAS_STORAGE = TEXTURE_2D
 * REGISTER_FOR = ('conv2d_pw', ['catchall'])
 */
...

Differential Revision: D42198560

…files (conv2d_pw)

@bypass-github-export-checks

This diff allows for adding entries to the shader registry by specifying which op names and registry keys should map to a template codegen Shader in the codegen Shader's glslt and params yaml files.

This can be done by
- adding a REGISTER_FOR entry which maps to either a tuple of (op name, list of registry keys) or null to the YAML file, and
- adding a ```REGISTER_FOR = $REGISTER_FOR``` line to the ShaderInfo comment in the glslt file

Ex.

YAML File:
```
conv2d_pw:
  parameter_names_with_default_values:
      ...
      REGISTER_FOR:
        - !!python/tuple ["conv2d_pw", ["catchall"]]
  parameter_values:
    - ...
      REGISTER_FOR: null
```
GLSLT File:
```
...
 * REGISTER_FOR = $REGISTER_FOR
...
```

This diff also registers the conv2d_pw_2x2 Shader under ```'conv2d_pw → 'catchall'``` in the registry and uses ```VK_REGISTRY_KERNEL``` to retrieve the shader by look up in the registry

The shader registry generated in spv.cpp now looks like
```
ShaderRegistry shader_registry = {
        {"conv2d", {{"catchall", "conv2d"}}},
        {"conv2d_pw", {{"catchall", "conv2d_pw_2x2"}}}};
```

and the generated conv2d_p2_KxK.glsl files look like:
K=1
```
...
/*
 * TILE_SIZE = (1, 1, 1)
 * WEIGHT_STORAGE = TEXTURE_2D
 * WEIGHT_STORAGE_LAYOUT = OC4,IC4,4ic,4oc
 * BIAS_STORAGE = TEXTURE_2D
 * REGISTER_FOR = None
 */
...
```
K=2
```
...
/*
 * TILE_SIZE = (2, 2, 1)
 * WEIGHT_STORAGE = TEXTURE_2D
 * WEIGHT_STORAGE_LAYOUT = OC4,IC4,4ic,4oc
 * BIAS_STORAGE = TEXTURE_2D
 * REGISTER_FOR = ('conv2d_pw', ['catchall'])
 */
...
```

Differential Revision: [D42198560](https://our.internmc.facebook.com/intern/diff/D42198560/)

[ghstack-poisoned]
@pytorch-bot
Copy link

pytorch-bot bot commented Jan 9, 2023

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/91916

Note: Links to docs will display an error until the docs builds have been completed.

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

❌ 2 Failures

As of commit 32b7714:

NEW FAILURES - The following jobs have failed:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@salilsdesai salilsdesai added the topic: not user facing topic category label Jan 9, 2023
…arams YAML files (conv2d_pw)"

bypass-github-export-checks

This diff allows for adding entries to the shader registry by specifying which op names and registry keys should map to a template codegen Shader in the codegen Shader's glslt and params yaml files.

This can be done by
- adding a REGISTER_FOR entry which maps to either a tuple of (op name, list of registry keys) or null to the YAML file, and
- adding a ```REGISTER_FOR = $REGISTER_FOR``` line to the ShaderInfo comment in the glslt file

Ex.

YAML File:
```
conv2d_pw:
  parameter_names_with_default_values:
      ...
      REGISTER_FOR:
        - !!python/tuple ["conv2d_pw", ["catchall"]]
  parameter_values:
    - ...
      REGISTER_FOR: null
```
GLSLT File:
```
...
 * REGISTER_FOR = $REGISTER_FOR
...
```

This diff also registers the conv2d_pw_2x2 Shader under ```'conv2d_pw → 'catchall'``` in the registry and uses ```VK_REGISTRY_KERNEL``` to retrieve the shader by look up in the registry

The shader registry generated in spv.cpp now looks like
```
ShaderRegistry shader_registry = {
        {"conv2d", {{"catchall", "conv2d"}}},
        {"conv2d_pw", {{"catchall", "conv2d_pw_2x2"}}}};
```

and the generated conv2d_p2_KxK.glsl files look like:
K=1
```
...
/*
 * TILE_SIZE = (1, 1, 1)
 * WEIGHT_STORAGE = TEXTURE_2D
 * WEIGHT_STORAGE_LAYOUT = OC4,IC4,4ic,4oc
 * BIAS_STORAGE = TEXTURE_2D
 * REGISTER_FOR = None
 */
...
```
K=2
```
...
/*
 * TILE_SIZE = (2, 2, 1)
 * WEIGHT_STORAGE = TEXTURE_2D
 * WEIGHT_STORAGE_LAYOUT = OC4,IC4,4ic,4oc
 * BIAS_STORAGE = TEXTURE_2D
 * REGISTER_FOR = ('conv2d_pw', ['catchall'])
 */
...
```

Differential Revision: [D42198560](https://our.internmc.facebook.com/intern/diff/D42198560/)

[ghstack-poisoned]
…arams YAML files (conv2d_pw)"

bypass-github-export-checks

This diff allows for adding entries to the shader registry by specifying which op names and registry keys should map to a template codegen Shader in the codegen Shader's glslt and params yaml files.

This can be done by
- adding a REGISTER_FOR entry which maps to either a tuple of (op name, list of registry keys) or null to the YAML file, and
- adding a ```REGISTER_FOR = $REGISTER_FOR``` line to the ShaderInfo comment in the glslt file

Ex.

YAML File:
```
conv2d_pw:
  parameter_names_with_default_values:
      ...
      REGISTER_FOR:
        - !!python/tuple ["conv2d_pw", ["catchall"]]
  parameter_values:
    - ...
      REGISTER_FOR: null
```
GLSLT File:
```
...
 * REGISTER_FOR = $REGISTER_FOR
...
```

This diff also registers the conv2d_pw_2x2 Shader under ```'conv2d_pw → 'catchall'``` in the registry and uses ```VK_REGISTRY_KERNEL``` to retrieve the shader by look up in the registry

The shader registry generated in spv.cpp now looks like
```
ShaderRegistry shader_registry = {
        {"conv2d", {{"catchall", "conv2d"}}},
        {"conv2d_pw", {{"catchall", "conv2d_pw_2x2"}}}};
```

and the generated conv2d_p2_KxK.glsl files look like:
K=1
```
...
/*
 * TILE_SIZE = (1, 1, 1)
 * WEIGHT_STORAGE = TEXTURE_2D
 * WEIGHT_STORAGE_LAYOUT = OC4,IC4,4ic,4oc
 * BIAS_STORAGE = TEXTURE_2D
 * REGISTER_FOR = None
 */
...
```
K=2
```
...
/*
 * TILE_SIZE = (2, 2, 1)
 * WEIGHT_STORAGE = TEXTURE_2D
 * WEIGHT_STORAGE_LAYOUT = OC4,IC4,4ic,4oc
 * BIAS_STORAGE = TEXTURE_2D
 * REGISTER_FOR = ('conv2d_pw', ['catchall'])
 */
...
```

Differential Revision: [D42198560](https://our.internmc.facebook.com/intern/diff/D42198560/)

[ghstack-poisoned]
@facebook-github-bot
Copy link
Contributor

@pytorchbot merge -f 'Landed internally'

(Initiating merge automatically since Phabricator Diff has merged, using force because this PR might not pass merge_rules.json but landed internally)

@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

@facebook-github-bot facebook-github-bot deleted the gh/salilsdesai/33/head branch June 8, 2023 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants