This commit implements Model_setOperandValue and enalbes below helpers.
- sizeOfData
- alignBytesNeeded
Signed-off-by: sjsujinkim <sjsujin.kim@samsung.com>
}
}
}
+#endif // REF-ANN
#define COUNT(X) (sizeof(X) / sizeof(X[0]))
const char* kTypeNames[kNumberOfDataTypes] = {
}
return size;
}
+#if 0 // REF-ANN
hidl_memory allocateSharedMemory(int64_t size) {
hidl_memory memory;
return memory;
}
+#endif // REF-ANN
uint32_t alignBytesNeeded(uint32_t index, size_t length) {
uint32_t pattern;
if (length < 2) {
uint32_t extra = (~(index - 1)) & pattern;
return extra;
}
-
+#if 0 // REF-ANN
void logModelToInfo(const Model& model) {
LOG(INFO) << "Model start";
LOG(INFO) << "operands" << toString(model.operands);
abort(); \
} \
} while (0)
-#if 0 // REF-ANN
// Returns the amount of space needed to store a value of the specified
// dimensions and type.
uint32_t sizeOfData(OperandType type, const std::vector<uint32_t>& dimensions);
inline uint32_t sizeOfData(const Operand& operand) {
return sizeOfData(operand.type, operand.dimensions);
}
+#if 0 // REF-ANN
// Returns the name of the operation in ASCII.
const char* getOperationName(OperationType opCode);
// Memory is reference counted by hidl_memory instances, and is deallocated
// once there are no more references.
hidl_memory allocateSharedMemory(int64_t size);
-
+#endif // REF-ANN
// Returns the number of padding bytes needed to align data of the
// specified length. It aligns object of length:
// 2, 3 on a 2 byte boundary,
// TODO: This is arbitrary, more a proof of concept. We need
// to determine what this should be.
uint32_t alignBytesNeeded(uint32_t index, size_t length);
-
+#if 0 // REF-ANN
// Does a detailed LOG(INFO) of the model
void logModelToInfo(const Model& model);
#endif // REF-ANN
}
int ModelBuilder::setOperandValue(uint32_t index, const void* buffer, size_t length) {
- // Dummy Implementation
- return 0;
-#if 0
VLOG(MODEL) << __func__ << " for operand " << index << " size " << length;
if (index >= operandCount()) {
LOG(ERROR) << "ANeuralNetworksModel_setOperandValue setting operand " << index << " of "
}
}
return ANEURALNETWORKS_NO_ERROR;
-#endif
}
int ModelBuilder::copyLargeValuesToSharedMemory() {
#include <vector>
#include <memory>
+#include <string.h> // For memcpy
+ // TODO-NNRT : Remove if the header containing this header is included
#include "HalInterfaces.h"
#include "Utils.h"
int ANeuralNetworksModel_setOperandValue(ANeuralNetworksModel* model, int32_t index,
const void* buffer, size_t length) {
- // Dummy Implementation
- return ANEURALNETWORKS_NO_ERROR;
-
- // Original code for reference
-#if 0
if (!model || !buffer) {
LOG(ERROR) << "ANeuralNetworksModel_setOperandValue passed a nullptr";
return ANEURALNETWORKS_UNEXPECTED_NULL;
}
ModelBuilder* m = reinterpret_cast<ModelBuilder*>(model);
return m->setOperandValue(index, buffer, length);
-#endif
}
int ANeuralNetworksModel_setOperandValueFromMemory(ANeuralNetworksModel* model, int32_t index,