Skip to content

Commit 2cc853c

Browse files
ai-edge-botcopybara-github
authored andcommitted
Add TFLITE_XNNPACK_DELEGATE_FLAG_DISABLE_SUBGRAPH_RESHAPING flag
PiperOrigin-RevId: 775262522
1 parent be95cda commit 2cc853c

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

tflite/delegates/xnnpack/xnnpack_delegate.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,8 @@ class Delegate {
700700
}
701701

702702
bool enable_subgraph_reshaping() const {
703-
return true;
703+
return (options_.flags &
704+
TFLITE_XNNPACK_DELEGATE_FLAG_DISABLE_SUBGRAPH_RESHAPING) == 0;
704705
}
705706

706707
bool enable_slinky() const {

tflite/delegates/xnnpack/xnnpack_delegate.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ extern "C" {
5656
// to avoid using faster codepaths that are numerically inconsistent with any
5757
// other codepath that could be used in the same compiled delegate.
5858
#define TFLITE_XNNPACK_DELEGATE_FLAG_SLOW_CONSISTENT_ARITHMETIC 0x00000200
59+
// Disable XNNPack subgraph reshaping. This means that models with dynamic
60+
// tensors are not supported.
61+
#define TFLITE_XNNPACK_DELEGATE_FLAG_DISABLE_SUBGRAPH_RESHAPING 0x00000400
5962

6063
struct TfLiteXNNPackDelegateWeightsCache;
6164

@@ -74,6 +77,7 @@ typedef struct {
7477
// - TFLITE_XNNPACK_DELEGATE_FLAG_TRANSIENT_INDIRECTION_BUFFER
7578
// - TFLITE_XNNPACK_DELEGATE_FLAG_ENABLE_LATEST_OPERATORS
7679
// - TFLITE_XNNPACK_DELEGATE_FLAG_ENABLE_SUBGRAPH_RESHAPING
80+
// - TFLITE_XNNPACK_DELEGATE_FLAG_DISABLE_SUBGRAPH_RESHAPING
7781
// - TFLITE_XNNPACK_DELEGATE_FLAG_SLOW_CONSISTENT_ARITHMETIC
7882
uint32_t flags;
7983
// Cache for packed weights, can be shared between multiple instances of

0 commit comments

Comments
 (0)