-
Notifications
You must be signed in to change notification settings - Fork 425
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ET-VK] Adding a common utility function to calculate 3d output posit…
…ion based on unique index. (#7564) Pull Request resolved: #7522 This diff adds an indexing utils header file used in Vulkan backend of Executorch. The header file includes functions for converting a global index to u16 indices based on input sizes. ghstack-source-id: 260707858 @exported-using-ghexport Differential Revision: [D67821941](https://our.internmc.facebook.com/intern/diff/D67821941/) Co-authored-by: Vivek Trivedi <[email protected]>
- Loading branch information
1 parent
ca1f760
commit 6cb9037
Showing
4 changed files
with
27 additions
and
18 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
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
19 changes: 19 additions & 0 deletions
19
backends/vulkan/runtime/graph/ops/glsl/indexing_utils_u16.h
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,19 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#ifndef INDEXING_UTILS_U16_H | ||
#define INDEXING_UTILS_U16_H | ||
|
||
#extension GL_EXT_shader_explicit_arithmetic_types_int16 : require | ||
|
||
u16vec3 idx_to_u16pos_x_wise(uint idx, int size_x, int size_y) { | ||
const uint div_by_x = idx / size_x; | ||
return u16vec3(idx % size_x, div_by_x % size_y, div_by_x / size_y); | ||
} | ||
|
||
#endif // INDEXING_UTILS_U16_H |