|
15 | 15 |
|
16 | 16 | #include <executorch/backends/vulkan/runtime/graph/ops/utils/ShaderNameUtils.h> |
17 | 17 |
|
| 18 | +#include <executorch/backends/vulkan/runtime/utils/StorageUtils.h> |
| 19 | + |
18 | 20 | namespace vkcompute { |
19 | 21 |
|
| 22 | +using utils::GPUMemoryLayout; |
| 23 | +using utils::StorageType; |
| 24 | + |
20 | 25 | void check_embedding_args( |
21 | 26 | const api::vTensor& weight, |
22 | 27 | const api::vTensor& in, |
23 | 28 | const api::vTensor& out) { |
24 | | - VK_CHECK_COND(check_packed_dim_is(weight, WHCN::kChannelsDim)); |
| 29 | + // The packing logic may not be trivial here. Input and output are Channel |
| 30 | + // Packed, which is default for the Vulkan backend. However, weight vector is |
| 31 | + // height-packed instead of channel-packed for space reason. |
| 32 | + VK_CHECK_COND(check_packed_dim_is(weight, WHCN::kHeightDim)); |
25 | 33 | VK_CHECK_COND(check_packed_dim_is(in, WHCN::kChannelsDim)); |
26 | 34 | VK_CHECK_COND(check_packed_dim_is(out, WHCN::kChannelsDim)); |
27 | 35 | } |
@@ -58,7 +66,12 @@ void add_embedding_node( |
58 | 66 | void embedding(ComputeGraph& graph, const std::vector<ValueRef>& args) { |
59 | 67 | ValueRef in = args[1]; |
60 | 68 | ValueRef out = args[5]; |
61 | | - ValueRef weight = prepack_standard_like(graph, args[0], out); |
| 69 | + |
| 70 | + ValueRef weight = prepack_standard( |
| 71 | + graph, |
| 72 | + args[0], |
| 73 | + StorageType::TEXTURE_2D, |
| 74 | + GPUMemoryLayout::TENSOR_HEIGHT_PACKED); |
62 | 75 |
|
63 | 76 | add_embedding_node(graph, weight, in, out); |
64 | 77 | } |
|
0 commit comments