Skip to content

Commit 2007481

Browse files
committed
Update base for Update on "Skip annotate boolean input"
Differential Revision: [D55946526](https://our.internmc.facebook.com/intern/diff/D55946526/) [ghstack-poisoned]
2 parents 5d299fe + e733f2d commit 2007481

File tree

69 files changed

+1988
-455
lines changed

Some content is hidden

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

69 files changed

+1988
-455
lines changed

CMakeLists.txt

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -352,23 +352,27 @@ add_subdirectory(schema)
352352
# Only contains primitive operators; does not contain portable kernels or other
353353
# full operators. Does not contain any backends.
354354
#
355-
356-
add_library(executorch ${_executorch__srcs})
357-
target_link_libraries(executorch PRIVATE program_schema)
358-
target_link_options_shared_lib(executorch)
355+
add_library(executorch_no_prim_ops ${_executorch_no_prim_ops__srcs})
356+
target_link_libraries(executorch_no_prim_ops PRIVATE program_schema)
359357
# Check if dl exists for this toolchain and only then link it.
360358
find_library(DL_LIBRARY_EXISTS NAMES dl)
361359
# Check if the library was found
362360
if(DL_LIBRARY_EXISTS)
363-
target_link_libraries(executorch PRIVATE dl) # For dladdr()
361+
target_link_libraries(executorch_no_prim_ops PRIVATE dl) # For dladdr()
364362
endif()
365-
target_include_directories(executorch PUBLIC ${_common_include_directories})
366-
target_compile_options(executorch PUBLIC ${_common_compile_options})
363+
target_include_directories(executorch_no_prim_ops PUBLIC ${_common_include_directories})
364+
target_compile_options(executorch_no_prim_ops PUBLIC ${_common_compile_options})
367365
if(MAX_KERNEL_NUM)
368-
target_compile_definitions(executorch
366+
target_compile_definitions(executorch_no_prim_ops
369367
PRIVATE MAX_KERNEL_NUM=${MAX_KERNEL_NUM})
370368
endif()
371369

370+
add_library(executorch ${_executorch__srcs})
371+
target_link_libraries(executorch PRIVATE executorch_no_prim_ops)
372+
target_include_directories(executorch PUBLIC ${_common_include_directories})
373+
target_compile_options(executorch PUBLIC ${_common_compile_options})
374+
target_link_options_shared_lib(executorch)
375+
372376
#
373377
# portable_ops_lib: A library to register core ATen ops using portable kernels,
374378
# see kernels/portable/CMakeLists.txt.
@@ -406,7 +410,7 @@ endif()
406410
# Install `executorch` library as well as `executorch-config.cmake` under
407411
# ${CMAKE_INSTALL_PREFIX}/
408412
install(
409-
TARGETS executorch
413+
TARGETS executorch executorch_no_prim_ops
410414
DESTINATION lib
411415
INCLUDES
412416
DESTINATION ${_common_include_directories})

backends/apple/coreml/runtime/workspace/executorchcoreml.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@
100100
C9E7D7952AB3F9BF00CCAE5D /* ETCoreMLModelManagerTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = C9E7D78D2AB3F9BF00CCAE5D /* ETCoreMLModelManagerTests.mm */; };
101101
C9E7D7962AB3F9BF00CCAE5D /* KeyValueStoreTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = C9E7D78E2AB3F9BF00CCAE5D /* KeyValueStoreTests.mm */; };
102102
C9E7D7A22AB3FBB200CCAE5D /* CoreMLBackendDelegateTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = C9E7D7A12AB3FBB200CCAE5D /* CoreMLBackendDelegateTests.mm */; };
103+
F24817E52BC655E100E80D98 /* libexecutorch_no_prim_ops.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F24817E42BC655E100E80D98 /* libexecutorch_no_prim_ops.a */; };
103104
/* End PBXBuildFile section */
104105

105106
/* Begin PBXCopyFilesBuildPhase section */
@@ -297,6 +298,7 @@
297298
C9EA3DB22B71A2B200B7D7BD /* CoreML.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreML.framework; path = System/Library/Frameworks/CoreML.framework; sourceTree = SDKROOT; };
298299
C9EA3FDE2B73EEA000B7D7BD /* libsqlite3.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libsqlite3.tbd; path = usr/lib/libsqlite3.tbd; sourceTree = SDKROOT; };
299300
C9EA3FE52B73EF6300B7D7BD /* Accelerate.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Accelerate.framework; path = System/Library/Frameworks/Accelerate.framework; sourceTree = SDKROOT; };
301+
F24817E42BC655E100E80D98 /* libexecutorch_no_prim_ops.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libexecutorch_no_prim_ops.a; path = ../libraries/libexecutorch_no_prim_ops.a; sourceTree = "<group>"; };
300302
/* End PBXFileReference section */
301303

302304
/* Begin PBXFrameworksBuildPhase section */
@@ -305,6 +307,7 @@
305307
buildActionMask = 2147483647;
306308
files = (
307309
C94D510F2ABDF87500AF47FD /* Accelerate.framework in Frameworks */,
310+
F24817E52BC655E100E80D98 /* libexecutorch_no_prim_ops.a in Frameworks */,
308311
C94D510E2ABDF86800AF47FD /* libsqlite3.tbd in Frameworks */,
309312
C94D50D92ABD7B2400AF47FD /* CoreML.framework in Frameworks */,
310313
C99883862B95AD7D000953A3 /* libprotobuf-lite.a in Frameworks */,
@@ -523,6 +526,7 @@
523526
C96560942AABFDCE005F8126 /* libsqlite3.tbd */,
524527
C96560922AABF992005F8126 /* CoreML.framework */,
525528
C96560902AABF982005F8126 /* Accelerate.framework */,
529+
F24817E42BC655E100E80D98 /* libexecutorch_no_prim_ops.a */,
526530
C965608D2AABF72A005F8126 /* libexecutorch.a */,
527531
);
528532
name = "Recovered References";

backends/apple/coreml/scripts/build_tests.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ cmake --build "$CMAKE_PROTOBUF_BUILD_DIR_PATH" -j9 -t libprotobuf-lite
5959
echo "ExecuTorch: Copying libraries"
6060
mkdir "$LIBRARIES_DIR_PATH"
6161
cp -f "$CMAKE_EXECUTORCH_BUILD_DIR_PATH/libexecutorch.a" "$LIBRARIES_DIR_PATH"
62+
cp -f "$CMAKE_EXECUTORCH_BUILD_DIR_PATH/libexecutorch_no_prim_ops.a" "$LIBRARIES_DIR_PATH"
6263
cp -f "$CMAKE_PROTOBUF_BUILD_DIR_PATH/libprotobuf-lite.a" "$LIBRARIES_DIR_PATH"
6364

6465
#Copy ExecuTorch headers

backends/vulkan/runtime/VulkanBackend.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,26 +77,26 @@ api::StorageType get_storage_type(
7777
const vkgraph::VkStorageType& vk_storage_type) {
7878
switch (vk_storage_type) {
7979
case vkgraph::VkStorageType::BUFFER:
80-
return api::StorageType::BUFFER;
80+
return api::kBuffer;
8181
case vkgraph::VkStorageType::TEXTURE_3D:
82-
return api::StorageType::TEXTURE_3D;
82+
return api::kTexture3D;
8383
case vkgraph::VkStorageType::TEXTURE_2D:
84-
return api::StorageType::TEXTURE_2D;
84+
return api::kTexture2D;
8585
default:
8686
break;
8787
}
88-
return api::StorageType::UNKNOWN;
88+
VK_THROW("Invalid storage type encountered!");
8989
}
9090

9191
api::GPUMemoryLayout get_memory_layout(
9292
const vkgraph::VkMemoryLayout& vk_memory_layout) {
9393
switch (vk_memory_layout) {
9494
case vkgraph::VkMemoryLayout::TENSOR_WIDTH_PACKED:
95-
return api::GPUMemoryLayout::TENSOR_WIDTH_PACKED;
95+
return api::kWidthPacked;
9696
case vkgraph::VkMemoryLayout::TENSOR_HEIGHT_PACKED:
97-
return api::GPUMemoryLayout::TENSOR_HEIGHT_PACKED;
97+
return api::kHeightPacked;
9898
case vkgraph::VkMemoryLayout::TENSOR_CHANNELS_PACKED:
99-
return api::GPUMemoryLayout::TENSOR_CHANNELS_PACKED;
99+
return api::kChannelsPacked;
100100
default:
101101
break;
102102
}

backends/vulkan/runtime/api/Runtime.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,22 @@
1616
namespace vkcompute {
1717
namespace api {
1818

19+
#define PRINT_CASE(name) \
20+
case MemoryAccessType::name: \
21+
out << #name; \
22+
break;
23+
24+
std::ostream& operator<<(std::ostream& out, const MemoryAccessType& tag) {
25+
switch (tag) {
26+
PRINT_CASE(NONE)
27+
PRINT_CASE(READ)
28+
PRINT_CASE(WRITE)
29+
}
30+
return out;
31+
}
32+
33+
#undef PRINT_CASE
34+
1935
namespace {
2036

2137
void find_requested_layers_and_extensions(

backends/vulkan/runtime/api/Shader.cpp

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,38 +23,19 @@ ShaderInfo::ShaderInfo()
2323
0u,
2424
} {}
2525

26-
ShaderInfo::ShaderInfo(
27-
std::string name,
28-
const uint32_t* const spirv_bin,
29-
const uint32_t size,
30-
std::vector<VkDescriptorType> layout)
31-
: src_code{
32-
spirv_bin,
33-
size,
34-
},
35-
kernel_name{std::move(name)},
36-
kernel_layout{std::move(layout)} {}
37-
3826
ShaderInfo::ShaderInfo(
3927
std::string name,
4028
const uint32_t* const spirv_bin,
4129
const uint32_t size,
4230
std::vector<VkDescriptorType> layout,
43-
const std::vector<uint32_t>& tile_size,
44-
const StorageType bias_storage_type,
45-
const StorageType weight_storage_type)
31+
const utils::uvec3 tile_size)
4632
: src_code{
4733
spirv_bin,
4834
size,
4935
},
5036
kernel_name{std::move(name)},
5137
kernel_layout{std::move(layout)},
52-
tile_size(tile_size),
53-
bias_storage_type(bias_storage_type),
54-
weight_storage_type(weight_storage_type) {
55-
for (uint64_t i = 0; i < tile_size.size(); ++i) {
56-
out_tile_size.data[i] = tile_size[i];
57-
}
38+
out_tile_size(tile_size) {
5839
}
5940

6041
bool operator==(const ShaderInfo& _1, const ShaderInfo& _2) {

backends/vulkan/runtime/api/Shader.h

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -62,25 +62,14 @@ struct ShaderInfo final {
6262
// Shader Metadata
6363
utils::uvec3 out_tile_size{1u, 1u, 1u};
6464

65-
std::vector<uint32_t> tile_size;
66-
StorageType bias_storage_type{StorageType::UNKNOWN};
67-
StorageType weight_storage_type{StorageType::UNKNOWN};
68-
6965
explicit ShaderInfo();
70-
explicit ShaderInfo(std::string, const char*);
71-
explicit ShaderInfo(
72-
std::string,
73-
const uint32_t*,
74-
const uint32_t,
75-
std::vector<VkDescriptorType>);
66+
7667
explicit ShaderInfo(
7768
std::string,
7869
const uint32_t*,
7970
const uint32_t,
8071
std::vector<VkDescriptorType>,
81-
const std::vector<uint32_t>& tile_size,
82-
const StorageType bias_storage_type,
83-
const StorageType weight_storage_type);
72+
const utils::uvec3 tile_size);
8473
};
8574

8675
bool operator==(const ShaderInfo& _1, const ShaderInfo& _2);

backends/vulkan/runtime/api/Tensor.cpp

Lines changed: 26 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -67,20 +67,20 @@ std::vector<int64_t> calc_strides(
6767
const api::GPUMemoryLayout memory_layout,
6868
const api::StorageType storage_type) {
6969
switch (storage_type) {
70-
case api::StorageType::BUFFER:
70+
case api::kBuffer:
7171
switch (memory_layout) {
72-
case api::GPUMemoryLayout::TENSOR_WIDTH_PACKED:
72+
case api::kWidthPacked:
7373
return calc_contiguous_strides(sizes);
7474
break;
75-
case api::GPUMemoryLayout::TENSOR_CHANNELS_PACKED:
75+
case api::kChannelsPacked:
7676
return calc_channels_last_strides(sizes);
7777
break;
7878
default:
7979
VK_THROW("Invalid memory format used to create vTensor!");
8080
}
8181
break;
82-
case api::StorageType::TEXTURE_3D:
83-
case api::StorageType::TEXTURE_2D:
82+
case api::kTexture3D:
83+
case api::kTexture2D:
8484
return std::vector<int64_t>(sizes.size());
8585
default:
8686
VK_THROW("Invalid storage type used to create vTensor!");
@@ -99,10 +99,8 @@ std::vector<int64_t> calc_gpu_sizes(
9999
const std::vector<int64_t>& sizes,
100100
const api::GPUMemoryLayout memory_layout,
101101
const api::StorageType storage_type) {
102-
VK_CHECK_COND(storage_type != api::StorageType::UNKNOWN);
103-
104102
std::vector<int64_t> gpu_sizes;
105-
if (storage_type == api::StorageType::BUFFER) {
103+
if (storage_type == api::kBuffer) {
106104
gpu_sizes.resize(sizes.size());
107105
for (size_t i = 0; i < sizes.size(); i++) {
108106
gpu_sizes.at(i) = sizes.at(i);
@@ -127,21 +125,21 @@ std::vector<int64_t> calc_gpu_sizes(
127125

128126
size_t ndim = gpu_sizes.size();
129127
switch (memory_layout) {
130-
case api::GPUMemoryLayout::TENSOR_WIDTH_PACKED:
128+
case api::kWidthPacked:
131129
if (ndim >= 1) {
132130
gpu_sizes.at(ndim - 1) =
133131
api::utils::align_up(api::utils::val_at(-1, sizes), INT64_C(4));
134132
}
135133
break;
136134

137-
case api::GPUMemoryLayout::TENSOR_HEIGHT_PACKED:
135+
case api::kHeightPacked:
138136
if (ndim >= 2) {
139137
gpu_sizes.at(ndim - 2) =
140138
api::utils::align_up(api::utils::val_at(-2, sizes), INT64_C(4));
141139
}
142140
break;
143141

144-
case api::GPUMemoryLayout::TENSOR_CHANNELS_PACKED:
142+
case api::kChannelsPacked:
145143
if (ndim >= 3) {
146144
gpu_sizes.at(ndim - 3) =
147145
api::utils::align_up(api::utils::val_at(-3, sizes), INT64_C(4));
@@ -162,7 +160,7 @@ api::utils::uvec3 create_image_extents(
162160
const api::GPUMemoryLayout memory_layout) {
163161
size_t ndim = gpu_sizes.size();
164162

165-
if (storage_type == api::StorageType::BUFFER) {
163+
if (storage_type == api::kBuffer) {
166164
// image extents do not apply to buffer storage
167165
return {0u, 0u, 0u};
168166
} else {
@@ -177,15 +175,15 @@ api::utils::uvec3 create_image_extents(
177175
uint32_t batch = safe_downcast<uint32_t>(val_at(-4, gpu_sizes));
178176

179177
switch (memory_layout) {
180-
case api::GPUMemoryLayout::TENSOR_WIDTH_PACKED:
178+
case api::kWidthPacked:
181179
VK_CHECK_COND(width % 4 == 0, "Channels must be divisible by 4!");
182180
width /= 4;
183181
break;
184-
case api::GPUMemoryLayout::TENSOR_HEIGHT_PACKED:
182+
case api::kHeightPacked:
185183
VK_CHECK_COND(height % 4 == 0, "Channels must be divisible by 4!");
186184
height /= 4;
187185
break;
188-
case api::GPUMemoryLayout::TENSOR_CHANNELS_PACKED:
186+
case api::kChannelsPacked:
189187
VK_CHECK_COND(channels % 4 == 0, "Channels must be divisible by 4!");
190188
channels /= 4;
191189
break;
@@ -326,41 +324,35 @@ std::shared_ptr<api::UniformParamsBuffer> vTensor::extents_ubo() {
326324

327325
VmaAllocationCreateInfo vTensor::get_allocation_create_info() const {
328326
switch (storage_type()) {
329-
case api::StorageType::BUFFER:
327+
case api::kBuffer:
330328
return view_->buffer_.allocation_create_info();
331-
case api::StorageType::TEXTURE_2D:
332-
case api::StorageType::TEXTURE_3D:
329+
case api::kTexture2D:
330+
case api::kTexture3D:
333331
return view_->image_.allocation_create_info();
334-
case api::StorageType::UNKNOWN:
335-
break;
336332
}
337333
return {};
338334
}
339335

340336
VkMemoryRequirements vTensor::get_memory_requirements() const {
341337
switch (storage_type()) {
342-
case api::StorageType::BUFFER:
338+
case api::kBuffer:
343339
return view_->buffer_.get_memory_requirements();
344-
case api::StorageType::TEXTURE_2D:
345-
case api::StorageType::TEXTURE_3D:
340+
case api::kTexture2D:
341+
case api::kTexture3D:
346342
return view_->image_.get_memory_requirements();
347-
case api::StorageType::UNKNOWN:
348-
break;
349343
}
350344
return {};
351345
}
352346

353347
void vTensor::bind_allocation(const api::MemoryAllocation& allocation) {
354348
switch (storage_type()) {
355-
case api::StorageType::BUFFER:
349+
case api::kBuffer:
356350
view_->buffer_.bind_allocation(allocation);
357351
break;
358-
case api::StorageType::TEXTURE_2D:
359-
case api::StorageType::TEXTURE_3D:
352+
case api::kTexture2D:
353+
case api::kTexture3D:
360354
view_->image_.bind_allocation(allocation);
361355
break;
362-
case api::StorageType::UNKNOWN:
363-
break;
364356
}
365357
}
366358

@@ -397,7 +389,7 @@ void vTensor::reallocate(const std::vector<int64_t>& new_sizes) {
397389

398390
void vTensor::virtual_resize(const std::vector<int64_t>& new_sizes) {
399391
update_size_metadata(new_sizes);
400-
if (storage_type() == api::StorageType::BUFFER) {
392+
if (storage_type() == api::kBuffer) {
401393
if (gpu_nbytes() > view_->buffer_.mem_size()) {
402394
VK_THROW(
403395
"Cannot virtual_resize a vTensor with sizes that require a larger "
@@ -446,11 +438,11 @@ api::VulkanImage allocate_image(
446438
VkImageViewType image_view_type = VK_IMAGE_VIEW_TYPE_3D;
447439

448440
switch (storage_type) {
449-
case api::StorageType::TEXTURE_3D:
441+
case api::kTexture3D:
450442
image_type = VK_IMAGE_TYPE_3D;
451443
image_view_type = VK_IMAGE_VIEW_TYPE_3D;
452444
break;
453-
case api::StorageType::TEXTURE_2D:
445+
case api::kTexture2D:
454446
image_type = VK_IMAGE_TYPE_2D;
455447
image_view_type = VK_IMAGE_VIEW_TYPE_2D;
456448
break;
@@ -481,7 +473,7 @@ api::VulkanBuffer allocate_buffer(
481473
api::Adapter* adapter_ptr = context_ptr->adapter_ptr();
482474

483475
switch (storage_type) {
484-
case api::StorageType::BUFFER:
476+
case api::kBuffer:
485477
break;
486478
default:
487479
// Return an empty VulkanBuffer if Buffer storage is not used

0 commit comments

Comments
 (0)