Skip to content

Commit 29c1ad8

Browse files
committed
Update on "[XNNPACK][Weights Cache] Initial Weights Cache Design with NamedDataMap"
XNNWeightsCache Design with NamedDataMap. The intent of the weights cache is for tensors to be loaded (via name) through the named data map. APIs to be used by XNNCompiler: - load_unpacked_data - Takes in a string name (tensor name). The weights cache loads the data for this string from the named data map and returns the pointer. It also creates a mapping of this pointer to the name which is later used by the XNNPACK's internal weight cache implementation - free_unpacked_data - Frees all the unpacked data loaded from NamedDataMap. This is only safe to call after xnn_create_runtime has been called. This is because create_runtime takes unpacked data pointers and packs them into a separate buffer. - a couple getter methods - get_packed_data_names - get_unpacked_data_names - get_num_packed_data - get() (get's the xnn_weights_cache object) Internal APIs used by XNNPACK Library - look_up - takes a cache key (weight and bias pointers) and looks up the offset to the packed weight if it exists - look_up_or_insert - takes a cache key and pointer to packed weights and looks_up the offset if it exists, or inserts a new packed weight into the cache and returns that offset - offset_to_addr - gets offset and returns address to packed pointer - reserve_space - returns memory address with appropriate sie for XNNPACK to populate with packed weights ( I want to use the runtime_allocator for this but i don't think we have the right sizes, so for now we are just using a string buffer and resizing it) - is_finalized - since this cache doesn't necessarily need to care about a finalized state we always return true. - delete_cache - deletes cache Differential Revision: [D70885917](https://our.internmc.facebook.com/intern/diff/D70885917/) [ghstack-poisoned]
2 parents 870ba5f + ef529d7 commit 29c1ad8

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

backends/xnnpack/test/targets.bzl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,15 @@ def define_common_targets():
2727
third_party_dep("FP16"),
2828
"//executorch/runtime/core/exec_aten/testing_util:tensor_util",
2929
"//executorch/runtime/core/exec_aten/util:scalar_type_util",
30+
"//executorch/backends/xnnpack:xnnpack_backend",
3031
],
3132
)
3233

3334
runtime.cxx_test(
3435
name = "test_xnn_weights_cache",
3536
srcs = ["runtime/test_xnn_weights_cache.cpp"],
3637
deps = [
38+
third_party_dep("XNNPACK"),
3739
"//executorch/backends/xnnpack:xnnpack_backend",
3840
"//executorch/runtime/executor:pte_data_map",
3941
"//executorch/extension/data_loader:file_data_loader",

exir/backend/test/test_backend_with_named_data_map.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def false_branch(self, x):
6767

6868
def forward(self, x, y):
6969
z = x / y
70-
z = torch.cond(z > 1, self.true_branch, self.false_branch, [x])
70+
z = torch.cond(z.sum() > 0, self.true_branch, self.false_branch, [x])
7171
return z - z
7272

7373
ep = to_edge(torch.export.export(M(), (torch.randn(1, 2), torch.randn(1, 2))))

0 commit comments

Comments
 (0)