diff options
author | 2018-09-11 15:36:21 -0700 | |
---|---|---|
committer | 2018-09-11 15:45:27 -0700 | |
commit | 6305a6d83552ba6a472cd72398b60d9241467f1f (patch) | |
tree | d02fb52415cefa562db46816c230e7522a702c90 /tensorflow/contrib/lite/nnapi/NeuralNetworksShim.h | |
parent | b1f29d4c618d6bfa85130917848cd7eb89bf0f3b (diff) |
Add an experimental API to allow half precision for FP32 calculation.
PiperOrigin-RevId: 212535448
Diffstat (limited to 'tensorflow/contrib/lite/nnapi/NeuralNetworksShim.h')
-rw-r--r-- | tensorflow/contrib/lite/nnapi/NeuralNetworksShim.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tensorflow/contrib/lite/nnapi/NeuralNetworksShim.h b/tensorflow/contrib/lite/nnapi/NeuralNetworksShim.h index 81dd459223..687944023b 100644 --- a/tensorflow/contrib/lite/nnapi/NeuralNetworksShim.h +++ b/tensorflow/contrib/lite/nnapi/NeuralNetworksShim.h @@ -364,6 +364,9 @@ typedef int (*ANeuralNetworksModel_identifyInputsAndOutputs_fn)( ANeuralNetworksModel* model, uint32_t inputCount, const uint32_t* inputs, uint32_t outputCount, const uint32_t* outputs); +typedef int (*ANeuralNetworksModel_relaxComputationFloat32toFloat16_fn)( + ANeuralNetworksModel* model, bool allow); + typedef int (*ANeuralNetworksExecution_create_fn)( ANeuralNetworksCompilation* compilation, ANeuralNetworksExecution** execution); @@ -656,6 +659,34 @@ inline int ANeuralNetworksModel_identifyInputsAndOutputs( } /** + * Specifies whether {@link ANEURALNETWORKS_TENSOR_FLOAT32} is allowed to be + * calculated with range and/or precision as low as that of the IEEE 754 16-bit + * floating-point format. By default, {@link ANEURALNETWORKS_TENSOR_FLOAT32} + * must be calculated using at least the range and precision of the IEEE 754 + * 32-bit floating-point format. + * + * @param model The model to be modified. + * @param allow 'true' indicates {@link ANEURALNETWORKS_TENSOR_FLOAT32} may be + * calculated with range and/or precision as low as that of the + * IEEE 754 16-bit floating point format. 'false' indicates + * {@link ANEURALNETWORKS_TENSOR_FLOAT32} must be calculated using + * at least the range and precision of the IEEE 754 32-bit floating + * point format. + * + * Attempting to modify a model once {@link ANeuralNetworksModel_finish} has + * been called will return an error. + * + * Available since API level 28. + * + * See {@link ANeuralNetworksModel} for information on multithreaded usage. + */ +inline int ANeuralNetworksModel_relaxComputationFloat32toFloat16( + ANeuralNetworksModel* model, bool allow) { + LOAD_FUNCTION(ANeuralNetworksModel_relaxComputationFloat32toFloat16); + EXECUTE_FUNCTION_RETURN(model, allow); +} + +/** * Create a {@link ANeuralNetworksCompilation} to compile the given model. * This only creates the object. Compilation is only performed once * {@link ANeuralNetworksCompilation_start} is invoked. |