ANeuralNetworksMemoryDesc_addOutputRole

Function ANeuralNetworksMemoryDesc_addOutputRole 

Source
pub unsafe extern "C" fn ANeuralNetworksMemoryDesc_addOutputRole(
    desc: *mut ANeuralNetworksMemoryDesc,
    compilation: *const ANeuralNetworksCompilation,
    index: u32,
    frequency: f32,
) -> c_int
Expand description

Specify that a memory object will be playing the role of an output to an execution created from a particular compilation.

The compilation and the output index fully specify an output operand. This function may be invoked multiple times on the same memory descriptor with different output operands, and the same output operand may be specified on multiple memory descriptors. However, specifying the same output operand on the same memory descriptor object more than once will return an error.

The dimensions of the corresponding model operands of all the roles specified by {@link ANeuralNetworksMemoryDesc_addInputRole} and {@link ANeuralNetworksMemoryDesc_addOutputRole} must be compatible with each other. Two dimensions are incompatible if both ranks are fully specified but have different values, or if there is at least one axis that is fully specified in both but has different values.

At least one of {@link ANeuralNetworksMemoryDesc_addInputRole} and {@link ANeuralNetworksMemoryDesc_addOutputRole} must be called on the memory descriptor before invoking {@link ANeuralNetworksMemoryDesc_finish}.

Attempting to modify a memory descriptor once {@link ANeuralNetworksMemoryDesc_finish} has been called will return an error.

See {@link ANeuralNetworksMemoryDesc} for information on multithreaded usage.

Available since API level 30.

@param desc The memory descriptor to be modified. @param compilation The compilation object. It must already have been finished by calling {@link ANeuralNetworksCompilation_finish}, and must outlive the memory descriptor. @param index The index of the output argument we are referencing from the compilation. It is an index into the outputs list passed to {@link ANeuralNetworksModel_identifyInputsAndOutputs}. It is not the index associated with {@link ANeuralNetworksModel_addOperand}. @param frequency A floating-point value within the range (0.0, 1.0]. Describes how likely the memory is to be used in the specified role. This is provided as a hint to optimize the case when multiple roles prefer different memory locations or data layouts.

@return ANEURALNETWORKS_NO_ERROR if successful.