Skip to content

Commit 88e6051

Browse files
committed
Update on "Skip annotate boolean input"
Differential Revision: [D55946526](https://our.internmc.facebook.com/intern/diff/D55946526/) [ghstack-poisoned]
2 parents 04d02c7 + 2007481 commit 88e6051

File tree

70 files changed

+1992
-459
lines changed

Some content is hidden

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

70 files changed

+1992
-459
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/qualcomm/quantizer/utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ def decorator(annotator: Callable):
4242

4343
return decorator
4444

45-
def _is_input_non_float_tensor(node: Node):
45+
def _is_input_float_tensor(node: Node):
4646
"""Check if the input is not a float tensor, so that we can skip quantization for the node
4747
since observers only works with float Tensors
4848
"""
4949
if "val" not in node.meta or not isinstance(node.meta["val"], FakeTensor):
5050
return True
51-
return node.meta["val"].dtype != torch.float32
51+
return node.meta["val"].dtype == torch.float32
5252

5353

5454
def _is_annotated(nodes: List[Node]):
@@ -132,11 +132,11 @@ def annotate_binary(node: Node, quantization_config: QuantizationConfig) -> None
132132

133133
input_qspec_map = {}
134134
input_act0 = node.args[0]
135-
if isinstance(input_act0, Node) and not _is_input_non_float_tensor(input_act0):
135+
if isinstance(input_act0, Node) and _is_input_float_tensor(input_act0):
136136
input_qspec_map[input_act0] = input_act_qspec
137137

138138
input_act1 = node.args[1]
139-
if isinstance(input_act1, Node) and not _is_input_non_float_tensor(input_act1):
139+
if isinstance(input_act1, Node) and _is_input_float_tensor(input_act1):
140140
input_qspec_map[input_act1] = input_act_qspec
141141

142142
node.meta[QUANT_ANNOTATION_KEY] = QuantizationAnnotation(

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);

0 commit comments

Comments
 (0)