return ANEURALNETWORKS_NO_ERROR;
#endif
}
-#if 0 // Memory.h is needed
int ModelBuilder::setOperandValueFromMemory(uint32_t index, const Memory* memory, uint32_t offset,
size_t length) {
- // Dummy Implementation
- return 0;
-#if 0
VLOG(MODEL) << __func__ << " for operand " << index << " offset " << offset << " size " << length;
if (index >= operandCount()) {
LOG(ERROR) << "ANeuralNetworksModel_setOperandValueFromMemory setting operand " << index
operand.location = {
.poolIndex = mMemories.add(memory), .offset = offset, .length = neededLength};
return ANEURALNETWORKS_NO_ERROR;
-#endif
}
-#endif
int ModelBuilder::addOperation(ANeuralNetworksOperationType type, uint32_t inputCount,
const uint32_t* inputs, uint32_t outputCount,
#ifndef ANDROID_ML_NN_RUNTIME_MODEL_BUILDER_H
#define ANDROID_ML_NN_RUNTIME_MODEL_BUILDER_H
+#include "Memory.h"
#include "NeuralNetworks.h"
#include <vector>
#include "HalInterfaces.h"
#include "Utils.h"
-#if 0
-#include "Memory.h"
-#include "NeuralNetworks.h"
-#endif
namespace android {
namespace nn {
// Adds an operand to the model.
int addOperand(const ANeuralNetworksOperandType& type);
int setOperandValue(uint32_t index, const void* buffer, size_t length);
-#if 0 // Memory.h is needed.
int setOperandValueFromMemory(uint32_t index, const Memory* memory, uint32_t offset,
size_t length);
-#endif
int addOperation(ANeuralNetworksOperationType type, uint32_t inputCount, const uint32_t* inputs,
uint32_t outputCount, const uint32_t* outputs);
int identifyInputsAndOutputs(uint32_t inputCount, const uint32_t* inputs, uint32_t outputCount,
const Operand& getOperand(uint32_t index) const { return mOperands[index]; }
const Operation& getOperation(uint32_t index) const { return mOperations[index]; }
-#if 0 // Memory.h is needed.
const MemoryTracker& getMemories() const { return mMemories; }
-#endif
const std::vector<Operation>& getOperations() const { return mOperations; }
const uint8_t* getPointerToOperandValue(uint32_t offset) const {
return mSmallOperandValues.data() + offset;
// the mOperandIndexes table.
std::vector<uint32_t> mInputIndexes;
std::vector<uint32_t> mOutputIndexes;
-#if 0 // Memory.h is needed.
+
MemoryTracker mMemories;
-#endif
+
// The value of the small operands that are defined at model
// creation time.
std::vector<uint8_t> mSmallOperandValues;
int ANeuralNetworksModel_setOperandValueFromMemory(ANeuralNetworksModel* model, int32_t index,
const ANeuralNetworksMemory* memory,
size_t offset, size_t length) {
- // Dummy Implementation
- return ANEURALNETWORKS_NO_ERROR;
-
- // Original code for reference
-#if 0
if (!model || !memory) {
LOG(ERROR) << "ANeuralNetworksModel_setOperandValue passed a nullptr";
return ANEURALNETWORKS_UNEXPECTED_NULL;
const Memory* mem = reinterpret_cast<const Memory*>(memory);
ModelBuilder* m = reinterpret_cast<ModelBuilder*>(model);
return m->setOperandValueFromMemory(index, mem, offset, length);
-#endif
}
int ANeuralNetworksModel_addOperation(ANeuralNetworksModel* model,