Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion backends/xnnpack/runtime/XNNWeightsCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,18 @@ size_t XNNWeightsCache::look_up_or_insert(
size_t size) {
size_t offset = context->look_up(context, cache_key);

// XNNPACK can call this with ptr==nullptr when it previously hit the cache
// and skipped packing. We can't validate against the ptr contents in this
// case, so just return the offset. This might actually be a bug in XNNPACK
// since calling look_up_or_insert with ptr==nullptr doesn't really make
// sense...
if (ptr == nullptr) {
return offset;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

worst case we will return SIZE_MAX?
And we can't continue without ptr from here anyway.

}

if (offset != SIZE_MAX) {
void* saved_ptr = context->offset_to_addr(context, offset);
if (0 == memcmp(ptr, saved_ptr, size)) {
if (saved_ptr != nullptr && 0 == memcmp(ptr, saved_ptr, size)) {
return offset;
}
// Failure, cache is out of date
Expand Down
Loading