-
Notifications
You must be signed in to change notification settings - Fork 323
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor our `OpUtils.*`, `StagingUtils.*`, and `Utils.*` which have accumulated helper functions during the redesign. We split them and move them into two new folders: 1. `ops/utils`: Used by files in `ops/` and `ops/impl/`. 2. `ops/impl/utils`: Used only by files in `ops/impl/`. In general, this helps to unflatten the `ops/` directory: ``` [jorgep31415@devvm15882.vll0 /data/users/jorgep31415/fbsource/xplat/executorch/backends/vulkan/runtime/graph/ops (98b0e789c)]$ tree . ├── ExecuteNode.cpp ├── ExecuteNode.h ├── impl │ ├── Arithmetic.cpp │ ├── Arithmetic.h │ ├── Staging.cpp │ ├── Staging.h │ └── utils │ ├── DimUtils.h │ ├── ScalarUtils.h │ ├── TensorUtils.cpp │ └── TensorUtils.h ├── OperatorRegistry.cpp ├── OperatorRegistry.h ├── PrepackNode.cpp ├── PrepackNode.h └── utils ├── BindingUtils.cpp ├── BindingUtils.h ├── StagingUtils.cpp └── StagingUtils.h 3 directories, 18 files ``` Since we're heavily updating include declarations, we also introduce the convention to only include the VK-API via ``` #include <ATen/native/vulkan/api/api.h> ``` instead of including more specific files, e.g., ``` #include <ATen/native/vulkan/api/Tensor.h> ``` Differential Revision: [D54690346](https://our.internmc.facebook.com/intern/diff/D54690346/) [ghstack-poisoned]
- Loading branch information
1 parent
3326dc3
commit 2a96ea8
Showing
20 changed files
with
126 additions
and
105 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
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
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
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
39 changes: 39 additions & 0 deletions
39
backends/vulkan/runtime/graph/ops/impl/utils/ScalarUtils.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,39 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#ifdef USE_VULKAN_API | ||
|
||
#include <ATen/native/vulkan/api/api.h> | ||
|
||
#include <executorch/backends/vulkan/runtime/graph/containers/Value.h> | ||
|
||
namespace at { | ||
namespace native { | ||
namespace vulkan { | ||
|
||
template <typename T> | ||
T extract_scalar(const Value& value) { | ||
if (value.isInt()) { | ||
return static_cast<T>(value.toInt()); | ||
} | ||
if (value.isDouble()) { | ||
return static_cast<T>(value.toDouble()); | ||
} | ||
if (value.isBool()) { | ||
return static_cast<T>(value.toBool()); | ||
} | ||
VK_THROW("Cannot extract scalar from Value with type ", value.type()); | ||
} | ||
|
||
} // namespace vulkan | ||
} // namespace native | ||
} // namespace at | ||
|
||
#endif /* USE_VULKAN_API */ |
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
28 changes: 28 additions & 0 deletions
28
backends/vulkan/runtime/graph/ops/impl/utils/TensorUtils.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,28 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#ifdef USE_VULKAN_API | ||
|
||
#include <ATen/native/vulkan/api/api.h> | ||
|
||
namespace at { | ||
namespace native { | ||
namespace vulkan { | ||
|
||
api::utils::uvec3 adaptive_work_group_size( | ||
const api::utils::uvec3& global_work_group); | ||
|
||
api::utils::ivec4 get_size_as_ivec4(const vTensor& t); | ||
|
||
} // namespace vulkan | ||
} // namespace native | ||
} // namespace at | ||
|
||
#endif /* USE_VULKAN_API */ |
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
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
Oops, something went wrong.