}
using ::neurun::graph::operand::CachedData;
+ using ::neurun::graph::operand::ExternalData;
- model->deref().setOperandValue(
- ind, nnfw::make_unique<CachedData>(reinterpret_cast<const uint8_t *>(buffer), length));
+ // NNAPI spec in NeuralNetworks.h
+ // For values of length greater than ANEURALNETWORKS_MAX_SIZE_OF_IMMEDIATELY_COPIED_VALUES,
+ // the application is responsible for not changing the content of this region
+ // until all executions using this model have completed
+ if (length <= ANEURALNETWORKS_MAX_SIZE_OF_IMMEDIATELY_COPIED_VALUES)
+ {
+ model->deref().setOperandValue(
+ ind, nnfw::make_unique<CachedData>(reinterpret_cast<const uint8_t *>(buffer), length));
+ }
+ else
+ {
+ model->deref().setOperandValue(
+ ind, nnfw::make_unique<ExternalData>(reinterpret_cast<const uint8_t *>(buffer), length));
+ }
return ANEURALNETWORKS_NO_ERROR;
}