${CMAKE_CURRENT_SOURCE_DIR}/CpuExecutor.cpp
${CMAKE_CURRENT_SOURCE_DIR}/OperationsUtils.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Utils.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/NNFWKernels.cpp
${CMAKE_CURRENT_SOURCE_DIR}/operations/Activation.cpp
${CMAKE_CURRENT_SOURCE_DIR}/operations/Conv2D.cpp
${CMAKE_CURRENT_SOURCE_DIR}/operations/Concatenation.cpp
#include "NeuralNetworks.h"
#include "Operations.h"
+#include "NNFWKernels.h"
+
#include <sys/mman.h>
namespace android {
VLOG(CPUEXE) << "request: " << toString(request);
#endif
+ // Prepare NNFW_KERNELS
+ android::nn::init_nnfw_kernels();
+
mModel = &model;
mRequest = &request; // TODO check if mRequest is needed
initializeRunTimeInfo(modelPoolInfos, requestPoolInfos);
padding_top, padding_bottom,
stride_width, stride_height,
&outShape) &&
- setInfoAndAllocateIfNeeded(&output, outShape) &&
- convFloat32(reinterpret_cast<const float*>(input.buffer), input.shape(),
+ setInfoAndAllocateIfNeeded(&output, outShape);
+
+ auto it = nnfw_kernels_convFloat32.end();
+ auto target = std::getenv("NNFW_KERNEL_convFloat32");
+ if (target)
+ {
+ it = nnfw_kernels_convFloat32.find(target);
+ }
+ if (it == nnfw_kernels_convFloat32.end())
+ {
+ it = nnfw_kernels_convFloat32.find("fallback");
+ }
+ auto func = it->second;
+
+ success = success && func(reinterpret_cast<const float*>(input.buffer), input.shape(),
reinterpret_cast<const float*>(filter.buffer), filter.shape(),
reinterpret_cast<const float*>(bias.buffer), bias.shape(),
padding_left, padding_right,
--- /dev/null
+#include "CpuExecutor.h"
+#include "NeuralNetworks.h"
+#include "Operations.h"
+
+#include "NNFWKernels.h"
+
+#include <map>
+
+namespace android {
+namespace nn {
+
+NNFW_KERNELS_convFloat32 nnfw_kernels_convFloat32;
+
+void init_nnfw_kernels()
+{
+ nnfw_kernels_convFloat32["fallback"] = convFloat32;
+ return;
+}
+
+} // namespace nn
+} // namespace android
--- /dev/null
+#ifndef __NNFW_KERNELS_H__
+#define __NNFW_KERNELS_H__
+
+#include "CpuExecutor.h"
+#include "NeuralNetworks.h"
+#include "Operations.h"
+
+#include <map>
+
+namespace android {
+namespace nn {
+
+#define NNFW_KERNEL(Name, Ret, Params) \
+ typedef Ret (*KERNEL_##Name) Params; \
+ typedef std::map<std::string, KERNEL_##Name> NNFW_KERNELS_##Name; \
+ extern NNFW_KERNELS_##Name nnfw_kernels_##Name;
+
+// TODO-NNRT: Let's make a sparate list file and include file
+NNFW_KERNEL(convFloat32, bool,
+ (const float* inputData, const Shape& inputShape,
+ const float* filterData, const Shape& filterShape,
+ const float* biasData, const Shape& biasShape,
+ int32_t padding_left, int32_t padding_right,
+ int32_t padding_top, int32_t padding_bottom,
+ int32_t stride_width, int32_t stride_height,
+ int32_t activation,
+ float* outputData, const Shape& outputShape)
+ );
+#undef NNFW_KERNEL
+
+void init_nnfw_kernels();
+
+} // namespace nn
+} // namespace android
+#endif // __NNFW_KERNELS_H__