Skip to content

Commit 60de118

Browse files
committed
Update base for Update on "Move builder.py into extension"
This PR does the following things: - rename `LlamaEdgeManager` to `LLMEdgeManager` - clean up some unused parameters: `weight_type`, `use_sdpa_with_kv_cache` - move `model.params.max_seq_len` out of `builder.py` - move `builder.py` into `extension/llm/export` Differential Revision: [D59493975](https://our.internmc.facebook.com/intern/diff/D59493975/) [ghstack-poisoned]
2 parents 2d9c6b5 + b10b763 commit 60de118

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+749
-703
lines changed

CMakeLists.txt

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -485,24 +485,26 @@ if(MAX_KERNEL_NUM)
485485
)
486486
endif()
487487

488-
# shared version
489-
add_library(
490-
executorch_no_prim_ops_shared SHARED ${_executorch_no_prim_ops__srcs}
491-
)
492-
target_link_libraries(executorch_no_prim_ops_shared PRIVATE program_schema)
493-
if(DL_LIBRARY_EXISTS)
494-
target_link_libraries(executorch_no_prim_ops_shared PRIVATE dl) # For dladdr()
495-
endif()
496-
target_include_directories(
497-
executorch_no_prim_ops_shared PUBLIC ${_common_include_directories}
498-
)
499-
target_compile_options(
500-
executorch_no_prim_ops_shared PUBLIC ${_common_compile_options}
501-
)
502-
if(MAX_KERNEL_NUM)
503-
target_compile_definitions(
504-
executorch_no_prim_ops_shared PRIVATE MAX_KERNEL_NUM=${MAX_KERNEL_NUM}
488+
if(EXECUTORCH_BUILD_PYBIND)
489+
# shared version
490+
add_library(
491+
executorch_no_prim_ops_shared SHARED ${_executorch_no_prim_ops__srcs}
492+
)
493+
target_link_libraries(executorch_no_prim_ops_shared PRIVATE program_schema)
494+
if(DL_LIBRARY_EXISTS)
495+
target_link_libraries(executorch_no_prim_ops_shared PRIVATE dl) # For dladdr()
496+
endif()
497+
target_include_directories(
498+
executorch_no_prim_ops_shared PUBLIC ${_common_include_directories}
499+
)
500+
target_compile_options(
501+
executorch_no_prim_ops_shared PUBLIC ${_common_compile_options}
505502
)
503+
if(MAX_KERNEL_NUM)
504+
target_compile_definitions(
505+
executorch_no_prim_ops_shared PRIVATE MAX_KERNEL_NUM=${MAX_KERNEL_NUM}
506+
)
507+
endif()
506508
endif()
507509

508510
#
@@ -553,7 +555,7 @@ endif()
553555
# Install `executorch` library as well as `executorch-config.cmake` under
554556
# ${CMAKE_INSTALL_PREFIX}/
555557
install(
556-
TARGETS executorch executorch_no_prim_ops executorch_no_prim_ops_shared
558+
TARGETS executorch executorch_no_prim_ops
557559
DESTINATION lib
558560
INCLUDES
559561
DESTINATION ${_common_include_directories}

backends/vulkan/TARGETS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ runtime.python_library(
2626
"//executorch/backends/transforms:fuse_batch_norm_with_conv",
2727
"//executorch/backends/transforms:fuse_conv_with_clamp",
2828
"//executorch/backends/transforms:fuse_view_copy",
29+
"//executorch/backends/transforms:mean_to_sum_div",
2930
"//executorch/backends/transforms:remove_clone_ops",
3031
"//executorch/exir:graph_module",
3132
"//executorch/exir/_serialize:_bindings",

backends/vulkan/partitioner/supported_ops.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,10 @@ def __contains__(self, op):
8484
]
8585

8686
REDUCTION_OPS = [
87+
exir_ops.edge.aten.mean.dim,
8788
exir_ops.edge.aten.sum.dim_IntList,
88-
exir_ops.edge.aten._softmax.default,
8989
exir_ops.edge.aten._log_softmax.default,
90+
exir_ops.edge.aten._softmax.default,
9091
]
9192

9293
NORMALIZATION_OPS = [

backends/vulkan/runtime/VulkanBackend.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -76,30 +76,30 @@ vkapi::ScalarType get_scalar_type(const vkgraph::VkDataType& vk_datatype) {
7676
}
7777
}
7878

79-
vkapi::StorageType get_storage_type(
79+
utils::StorageType get_storage_type(
8080
const vkgraph::VkStorageType& vk_storage_type) {
8181
switch (vk_storage_type) {
8282
case vkgraph::VkStorageType::BUFFER:
83-
return vkapi::kBuffer;
83+
return utils::kBuffer;
8484
case vkgraph::VkStorageType::TEXTURE_3D:
85-
return vkapi::kTexture3D;
85+
return utils::kTexture3D;
8686
case vkgraph::VkStorageType::TEXTURE_2D:
87-
return vkapi::kTexture2D;
87+
return utils::kTexture2D;
8888
default:
8989
break;
9090
}
9191
VK_THROW("Invalid storage type encountered!");
9292
}
9393

94-
vkapi::GPUMemoryLayout get_memory_layout(
94+
utils::GPUMemoryLayout get_memory_layout(
9595
const vkgraph::VkMemoryLayout& vk_memory_layout) {
9696
switch (vk_memory_layout) {
9797
case vkgraph::VkMemoryLayout::TENSOR_WIDTH_PACKED:
98-
return vkapi::kWidthPacked;
98+
return utils::kWidthPacked;
9999
case vkgraph::VkMemoryLayout::TENSOR_HEIGHT_PACKED:
100-
return vkapi::kHeightPacked;
100+
return utils::kHeightPacked;
101101
case vkgraph::VkMemoryLayout::TENSOR_CHANNELS_PACKED:
102-
return vkapi::kChannelsPacked;
102+
return utils::kChannelsPacked;
103103
default:
104104
break;
105105
}
@@ -115,16 +115,16 @@ GraphConfig get_graph_config(ArrayRef<CompileSpec>& compile_specs) {
115115
if (strcmp(spec.key, "storage_type_override") == 0) {
116116
ET_CHECK_MSG(value_size == sizeof(int32_t), "Unexpected value size!");
117117
int value_as_int = static_cast<int>(getUInt32LE(value_data));
118-
vkapi::StorageType storage_type =
119-
static_cast<vkapi::StorageType>(value_as_int);
118+
utils::StorageType storage_type =
119+
static_cast<utils::StorageType>(value_as_int);
120120

121121
config.set_storage_type_override(storage_type);
122122
}
123123
if (strcmp(spec.key, "memory_layout_override") == 0) {
124124
ET_CHECK_MSG(value_size == sizeof(uint32_t), "Unexpected value size!");
125125
uint32_t value_as_int = getUInt32LE(value_data);
126-
vkapi::GPUMemoryLayout memory_layout =
127-
static_cast<vkapi::GPUMemoryLayout>(value_as_int);
126+
utils::GPUMemoryLayout memory_layout =
127+
static_cast<utils::GPUMemoryLayout>(value_as_int);
128128

129129
config.set_memory_layout_override(memory_layout);
130130
}
@@ -172,15 +172,15 @@ class GraphBuilder {
172172

173173
void add_tensor_to_graph(const uint32_t fb_id, VkTensorPtr tensor_fb) {
174174
const vkapi::ScalarType& dtype = get_scalar_type(tensor_fb->datatype());
175-
vkapi::StorageType storage_type =
175+
utils::StorageType storage_type =
176176
tensor_fb->storage_type() == vkgraph::VkStorageType::DEFAULT_STORAGE
177177
? compute_graph_->suggested_storage_type()
178178
: get_storage_type(tensor_fb->storage_type());
179179

180180
UIntVector dims_fb = tensor_fb->dims();
181181
const std::vector<int64_t> dims_vector(dims_fb->cbegin(), dims_fb->cend());
182182

183-
vkapi::GPUMemoryLayout memory_layout =
183+
utils::GPUMemoryLayout memory_layout =
184184
tensor_fb->memory_layout() == vkgraph::VkMemoryLayout::DEFAULT_LAYOUT
185185
? compute_graph_->suggested_memory_layout(dims_vector)
186186
: get_memory_layout(tensor_fb->memory_layout());

backends/vulkan/runtime/api/Context.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
#include <executorch/backends/vulkan/runtime/api/Context.h>
1010

11-
#include <executorch/backends/vulkan/runtime/api/vk_api/VkUtils.h>
11+
#include <executorch/backends/vulkan/runtime/vk_api/VkUtils.h>
1212

1313
#ifndef VULKAN_DESCRIPTOR_POOL_SIZE
1414
#define VULKAN_DESCRIPTOR_POOL_SIZE 1024u

backends/vulkan/runtime/api/Context.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010

1111
// @lint-ignore-every CLANGTIDY facebook-hte-BadMemberName
1212

13-
#include <executorch/backends/vulkan/runtime/api/utils/MacroUtils.h>
14-
15-
#include <executorch/backends/vulkan/runtime/api/vk_api/Adapter.h>
16-
#include <executorch/backends/vulkan/runtime/api/vk_api/Command.h>
17-
#include <executorch/backends/vulkan/runtime/api/vk_api/Descriptor.h>
18-
#include <executorch/backends/vulkan/runtime/api/vk_api/Fence.h>
19-
#include <executorch/backends/vulkan/runtime/api/vk_api/QueryPool.h>
20-
#include <executorch/backends/vulkan/runtime/api/vk_api/Runtime.h>
13+
#include <executorch/backends/vulkan/runtime/utils/MacroUtils.h>
14+
15+
#include <executorch/backends/vulkan/runtime/vk_api/Adapter.h>
16+
#include <executorch/backends/vulkan/runtime/vk_api/Command.h>
17+
#include <executorch/backends/vulkan/runtime/vk_api/Descriptor.h>
18+
#include <executorch/backends/vulkan/runtime/vk_api/Fence.h>
19+
#include <executorch/backends/vulkan/runtime/vk_api/QueryPool.h>
20+
#include <executorch/backends/vulkan/runtime/vk_api/Runtime.h>
2121

2222
namespace vkcompute {
2323
namespace api {

backends/vulkan/runtime/api/ShaderRegistry.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
// @lint-ignore-every CLANGTIDY facebook-hte-BadMemberName
1212

13-
#include <executorch/backends/vulkan/runtime/api/vk_api/Shader.h>
13+
#include <executorch/backends/vulkan/runtime/vk_api/Shader.h>
1414

1515
#include <string>
1616
#include <unordered_map>

backends/vulkan/runtime/api/api.h

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,23 @@
99
#pragma once
1010

1111
#include <executorch/backends/vulkan/runtime/api/Context.h>
12-
#include <executorch/backends/vulkan/runtime/api/ParamsBuffer.h>
1312
#include <executorch/backends/vulkan/runtime/api/ShaderRegistry.h>
14-
#include <executorch/backends/vulkan/runtime/api/StorageBuffer.h>
15-
#include <executorch/backends/vulkan/runtime/api/Tensor.h>
1613

17-
#include <executorch/backends/vulkan/runtime/api/utils/VecUtils.h>
14+
#include <executorch/backends/vulkan/runtime/api/containers/ParamsBuffer.h>
15+
#include <executorch/backends/vulkan/runtime/api/containers/StorageBuffer.h>
16+
#include <executorch/backends/vulkan/runtime/api/containers/Tensor.h>
1817

19-
#include <executorch/backends/vulkan/runtime/api/vk_api/Adapter.h>
20-
#include <executorch/backends/vulkan/runtime/api/vk_api/Command.h>
21-
#include <executorch/backends/vulkan/runtime/api/vk_api/Descriptor.h>
22-
#include <executorch/backends/vulkan/runtime/api/vk_api/Fence.h>
23-
#include <executorch/backends/vulkan/runtime/api/vk_api/Pipeline.h>
24-
#include <executorch/backends/vulkan/runtime/api/vk_api/Runtime.h>
25-
#include <executorch/backends/vulkan/runtime/api/vk_api/Shader.h>
18+
#include <executorch/backends/vulkan/runtime/utils/VecUtils.h>
2619

27-
#include <executorch/backends/vulkan/runtime/api/vk_api/memory/Allocation.h>
28-
#include <executorch/backends/vulkan/runtime/api/vk_api/memory/Allocator.h>
29-
#include <executorch/backends/vulkan/runtime/api/vk_api/memory/Buffer.h>
30-
#include <executorch/backends/vulkan/runtime/api/vk_api/memory/Image.h>
20+
#include <executorch/backends/vulkan/runtime/vk_api/Adapter.h>
21+
#include <executorch/backends/vulkan/runtime/vk_api/Command.h>
22+
#include <executorch/backends/vulkan/runtime/vk_api/Descriptor.h>
23+
#include <executorch/backends/vulkan/runtime/vk_api/Fence.h>
24+
#include <executorch/backends/vulkan/runtime/vk_api/Pipeline.h>
25+
#include <executorch/backends/vulkan/runtime/vk_api/Runtime.h>
26+
#include <executorch/backends/vulkan/runtime/vk_api/Shader.h>
27+
28+
#include <executorch/backends/vulkan/runtime/vk_api/memory/Allocation.h>
29+
#include <executorch/backends/vulkan/runtime/vk_api/memory/Allocator.h>
30+
#include <executorch/backends/vulkan/runtime/vk_api/memory/Buffer.h>
31+
#include <executorch/backends/vulkan/runtime/vk_api/memory/Image.h>

backends/vulkan/runtime/api/ParamsBuffer.cpp renamed to backends/vulkan/runtime/api/containers/ParamsBuffer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* LICENSE file in the root directory of this source tree.
77
*/
88

9-
#include <executorch/backends/vulkan/runtime/api/ParamsBuffer.h>
9+
#include <executorch/backends/vulkan/runtime/api/containers/ParamsBuffer.h>
1010

1111
#include <cstring>
1212

backends/vulkan/runtime/api/ParamsBuffer.h renamed to backends/vulkan/runtime/api/containers/ParamsBuffer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
#include <executorch/backends/vulkan/runtime/api/Context.h>
1414

15-
#include <executorch/backends/vulkan/runtime/api/vk_api/memory/Buffer.h>
15+
#include <executorch/backends/vulkan/runtime/vk_api/memory/Buffer.h>
1616

1717
namespace vkcompute {
1818
namespace api {

backends/vulkan/runtime/api/StorageBuffer.h renamed to backends/vulkan/runtime/api/containers/StorageBuffer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
#include <executorch/backends/vulkan/runtime/api/Context.h>
1414

15-
#include <executorch/backends/vulkan/runtime/api/vk_api/memory/Buffer.h>
15+
#include <executorch/backends/vulkan/runtime/vk_api/memory/Buffer.h>
1616

1717
namespace vkcompute {
1818
namespace api {

0 commit comments

Comments
 (0)