Introduce generator functions for default TfLiteGlCompileOptions.
Every new instance of TfLiteGlCompileOptions should be populated through DefaultTfLiteGlCompileOptions() call to avoid breaking changes when new option is introduced. PiperOrigin-RevId: 262918305
This commit is contained in:
parent
c005054786
commit
d9fbce7831
@ -462,6 +462,14 @@ TfLiteStatus DelegateCopyToBufferHandle(TfLiteContext* context,
|
||||
} // namespace gpu
|
||||
} // namespace tflite
|
||||
|
||||
TfLiteGlCompileOptions DefaultTfLiteGlCompileOptions() {
|
||||
TfLiteGlCompileOptions options;
|
||||
options.precision_loss_allowed = 0;
|
||||
options.preferred_gl_object_type = TFLITE_GL_OBJECT_TYPE_FASTEST;
|
||||
options.dynamic_batch_enabled = 0;
|
||||
return options;
|
||||
}
|
||||
|
||||
TfLiteDelegate* TfLiteGpuDelegateCreate(
|
||||
const TfLiteGpuDelegateOptions* options) {
|
||||
TFLITE_LOG_PROD_ONCE(tflite::TFLITE_LOG_INFO,
|
||||
|
@ -47,6 +47,9 @@ enum TfLiteGlObjectType {
|
||||
};
|
||||
|
||||
// Shader compilation options.
|
||||
// Always use DefaultTfLiteGlCompileOptions() method to create new instance
|
||||
// of TfLiteGlCompileOptions, otherwise every new added option may break
|
||||
// inference.
|
||||
// TODO(impjdi): Unify with opengl::CompilationOptions.
|
||||
struct TFL_CAPI_EXPORT TfLiteGlCompileOptions {
|
||||
// When set to zero, computations are carried out in 32-bit floating point.
|
||||
@ -71,6 +74,12 @@ struct TFL_CAPI_EXPORT TfLiteGlCompileOptions {
|
||||
int32_t dynamic_batch_enabled;
|
||||
};
|
||||
|
||||
// Populates TfLiteGlCompileOptions as follows:
|
||||
// precision_loss_allowed = 0;
|
||||
// preferred_gl_object_type = TFLITE_GL_OBJECT_TYPE_FASTEST;
|
||||
// dynamic_batch_enabled = 0;
|
||||
TFL_CAPI_EXPORT TfLiteGlCompileOptions DefaultTfLiteGlCompileOptions();
|
||||
|
||||
struct TFL_CAPI_EXPORT TfLiteGpuDelegateOptions {
|
||||
const uint8_t* metadata; // Internal.
|
||||
TfLiteGlCompileOptions compile_options;
|
||||
|
Loading…
x
Reference in New Issue
Block a user