Skip to content

Commit

Permalink
Sync from upstream TF.
Browse files Browse the repository at this point in the history
  • Loading branch information
TFLM-bot committed Feb 7, 2025
1 parent ef64591 commit b044512
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tensorflow/lite/core/c/c_api_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ extern "C" {
#ifdef TFL_COMPILE_LIBRARY
#define TFL_CAPI_EXPORT __declspec(dllexport)
#else
#define TFL_CAPI_EXPORT __declspec(dllimport)
#define TFL_CAPI_EXPORT
#endif // TFL_COMPILE_LIBRARY
#else
#define TFL_CAPI_EXPORT __attribute__((visibility("default")))
Expand Down
12 changes: 11 additions & 1 deletion tensorflow/lite/core/c/common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,8 @@ TfLiteAllocationStrategy TfLiteTensorGetAllocationStrategy(
return kTfLiteAllocationStrategyUnknown;
case kTfLiteVariantObject:
return kTfLiteAllocationStrategyNew;
case kTfLiteNonCpu:
return kTfLiteAllocationStrategyUnknown;
}
return kTfLiteAllocationStrategyUnknown;
}
Expand All @@ -428,6 +430,8 @@ TfLiteRunStability TfLiteTensorGetBufferAddressStability(
return kTfLiteRunStabilityUnknown;
case kTfLiteVariantObject:
return kTfLiteRunStabilityAcrossRuns;
case kTfLiteNonCpu:
return kTfLiteRunStabilityUnknown;
}
return kTfLiteRunStabilityUnknown;
}
Expand All @@ -451,6 +455,8 @@ TfLiteRunStability TfLiteTensorGetDataStability(const TfLiteTensor* const t) {
return kTfLiteRunStabilityUnknown;
case kTfLiteVariantObject:
return kTfLiteRunStabilitySingleRun;
case kTfLiteNonCpu:
return kTfLiteRunStabilityUnknown;
}
return kTfLiteRunStabilityUnknown;
}
Expand All @@ -477,11 +483,13 @@ TfLiteRunStep TfLiteTensorGetDataKnownStep(const TfLiteTensor* t) {
return kTfLiteRunStepUnknown;
case kTfLiteVariantObject:
return kTfLiteRunStepEval;
case kTfLiteNonCpu:
return kTfLiteRunStepUnknown;
}
return kTfLiteRunStepUnknown;
}

// Returns the operation steop when the shape of a tensor is computed.
// Returns the operation step when the shape of a tensor is computed.
//
// Some operations can precompute the shape of their results before the
// evaluation step. This makes the shape available earlier for subsequent
Expand All @@ -504,6 +512,8 @@ TfLiteRunStep TfLiteTensorGetShapeKnownStep(const TfLiteTensor* t) {
return kTfLiteRunStepUnknown;
case kTfLiteVariantObject:
return kTfLiteRunStepEval;
case kTfLiteNonCpu:
return kTfLiteRunStepUnknown;
}
return kTfLiteRunStepUnknown;
}
Expand Down
4 changes: 4 additions & 0 deletions tensorflow/lite/core/c/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,9 @@ typedef union TfLitePtrUnion {
/// * `kTfLiteVariantObject`: Allocation is an arbitrary type-erased C++
/// object.
/// Allocation and deallocation are done through `new` and `delete`.
/// * `kTfLiteNonCpu`: Tensor buffer is in non-CPU memory, such as AHWB, GPU
/// memory. This tensor is not accessed by the CPU.
/// This is only used by LiteRt API.
typedef enum TfLiteAllocationType {
kTfLiteMemNone = 0,
kTfLiteMmapRo,
Expand All @@ -405,6 +408,7 @@ typedef enum TfLiteAllocationType {
kTfLitePersistentRo,
kTfLiteCustom,
kTfLiteVariantObject,
kTfLiteNonCpu,
} TfLiteAllocationType;

/// Memory allocation strategies.
Expand Down

0 comments on commit b044512

Please sign in to comment.