add_subdirectory(backends)
add_subdirectory(actions)
add_subdirectory(tools)
-add_subdirectory(contrib)
+++ /dev/null
-add_subdirectories()
+++ /dev/null
-add_subdirectories()
+++ /dev/null
-add_subdirectory(tflite)
-add_subdirectory(caffe)
-file(GLOB_RECURSE SOURCES "src/*.cpp")
-
-add_library(nnsuite_conv STATIC ${SOURCES})
-set_target_properties(nnsuite_conv PROPERTIES POSITION_INDEPENDENT_CODE ON)
-target_include_directories(nnsuite_conv PUBLIC include)
-target_link_libraries(nnsuite_conv PUBLIC nncc_core)
+add_subdirectory(model)
+add_subdirectory(nnkit-caffe)
+add_subdirectory(nnkit-tflite)
--- /dev/null
+file(GLOB_RECURSE SOURCES "src/*.cpp")
+
+add_library(nnsuite_conv STATIC ${SOURCES})
+set_target_properties(nnsuite_conv PROPERTIES POSITION_INDEPENDENT_CODE ON)
+target_include_directories(nnsuite_conv PUBLIC include)
+target_link_libraries(nnsuite_conv PUBLIC nncc_core)
TestModel(const std::string &ifm_name, const feature::Shape &ifm_shape,
const std::string &ofm_name, const feature::Shape &ofm_shape,
const kernel::Shape &ker_shape, const kernel::Layout &ker_layout, float *ker_data)
- : _ifm_name(ifm_name), _ifm_shape(ifm_shape),
- _ofm_name(ofm_name), _ofm_shape(ofm_shape),
- _ker{ker_shape, ker_layout, ker_data}
+ : _ifm_name(ifm_name), _ifm_shape(ifm_shape), _ofm_name(ofm_name), _ofm_shape(ofm_shape),
+ _ker{ker_shape, ker_layout, ker_data}
{
// DO NOTHING
}
{
const std::string ofm_name{"ofm"};
const feature::Shape ofm_shape{1, 1, 1};
- float ofm_data[1] = { 204.0f }; // EXPECTED
+ float ofm_data[1] = {204.0f}; // EXPECTED
const std::string ifm_name{"ifm"};
const feature::Shape ifm_shape{1, 3, 3};
- float ifm_data[9] = { 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f };
+ float ifm_data[9] = {0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f};
const kernel::Shape ker_shape{1, 1, 3, 3};
- float ker_data[9] = { 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f };
+ float ker_data[9] = {0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f};
using kernel::NCHWLayout;
using tensor::LexicalLayout;
auto backend = ConvBackend::create(model);
- backend->prepare([&] (nnkit::TensorContext &ctx)
- {
+ backend->prepare([&](nnkit::TensorContext &ctx) {
ASSERT_EQ(ctx.size(), 1);
ASSERT_EQ(ctx.name(0), ifm_name);
// TODO Check IFM shape
- auto fill = [&] (const nnkit::TensorContext &, uint32_t, tensor::Accessor<float> &t)
- {
+ auto fill = [&](const nnkit::TensorContext &, uint32_t, tensor::Accessor<float> &t) {
const auto tensor_shape = morph::caffe::as_tensor_shape(ifm_shape);
const auto overlay = tensor::make_overlay<float, LexicalLayout>(tensor_shape, ifm_data);
backend->run();
- backend->teardown([&] (nnkit::TensorContext &ctx)
- {
+ backend->teardown([&](nnkit::TensorContext &ctx) {
ASSERT_EQ(ctx.size(), 1);
ASSERT_EQ(ctx.name(0), ofm_name);
- auto verify = [&] (const nnkit::TensorContext &, uint32_t, const tensor::Reader<float> &t)
- {
+ auto verify = [&](const nnkit::TensorContext &, uint32_t, const tensor::Reader<float> &t) {
const auto tensor_shape = morph::caffe::as_tensor_shape(ofm_shape);
const auto overlay = tensor::make_overlay<float, LexicalLayout>(tensor_shape, ofm_data);
*
* NOTE This function throws std::bac_alloc exception on allocation failure
*/
-template<typename T> T *typed_malloc(void)
+template <typename T> T *typed_malloc(void)
{
if (auto res = reinterpret_cast<T *>(malloc(sizeof(T))))
{
_interp.SetTensorParametersReadWrite(1, kTfLiteFloat32 /* type */, _ifm_name.c_str(),
as_dims(model.ifm_shape()), quantization);
- _interp.SetTensorParametersReadOnly(2, kTfLiteFloat32 /* type */, "kernel" /* name */,
- as_dims(model.ker_shape()), quantization,
- reinterpret_cast<const char *>(_kernel.data()),
- _kernel.size() * sizeof(float));
+ _interp.SetTensorParametersReadOnly(
+ 2, kTfLiteFloat32 /* type */, "kernel" /* name */, as_dims(model.ker_shape()), quantization,
+ reinterpret_cast<const char *>(_kernel.data()), _kernel.size() * sizeof(float));
- _interp.SetTensorParametersReadOnly(3, kTfLiteFloat32 /* type */, "bias" /* name */,
- {static_cast<int>(_bias.size())}, quantization,
- reinterpret_cast<const char *>(_bias.data()),
- _bias.size() * sizeof(float));
+ _interp.SetTensorParametersReadOnly(
+ 3, kTfLiteFloat32 /* type */, "bias" /* name */, {static_cast<int>(_bias.size())},
+ quantization, reinterpret_cast<const char *>(_bias.data()), _bias.size() * sizeof(float));
auto param = typed_malloc<TfLiteConvParams>();
param->activation = kTfLiteActNone;
_interp.AddNodeWithParameters({1, 2, 3}, {0}, nullptr, 0, reinterpret_cast<void *>(param),
- BuiltinOpResolver().FindOp(BuiltinOperator_CONV_2D));
+ BuiltinOpResolver().FindOp(BuiltinOperator_CONV_2D));
_interp.SetInputs({1});
_interp.SetOutputs({0});
TestModel(const std::string &ifm_name, const feature::Shape &ifm_shape,
const std::string &ofm_name, const feature::Shape &ofm_shape,
const kernel::Shape &ker_shape, const kernel::Layout &ker_layout, float *ker_data)
- : _ifm_name(ifm_name), _ifm_shape(ifm_shape),
- _ofm_name(ofm_name), _ofm_shape(ofm_shape),
- _ker{ker_shape, ker_layout, ker_data}
+ : _ifm_name(ifm_name), _ifm_shape(ifm_shape), _ofm_name(ofm_name), _ofm_shape(ofm_shape),
+ _ker{ker_shape, ker_layout, ker_data}
{
// DO NOTHING
}
{
const std::string ofm_name{"ofm"};
const feature::Shape ofm_shape{1, 1, 1};
- float ofm_data[1] = { 204.0f }; // EXPECTED
+ float ofm_data[1] = {204.0f}; // EXPECTED
const std::string ifm_name{"ifm"};
const feature::Shape ifm_shape{1, 3, 3};
- float ifm_data[9] = { 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f };
+ float ifm_data[9] = {0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f};
const kernel::Shape ker_shape{1, 1, 3, 3};
- float ker_data[9] = { 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f };
+ float ker_data[9] = {0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f};
using kernel::NHWCLayout;
using tensor::LexicalLayout;
ConvBackend backend{model};
- backend.prepare([&] (nnkit::TensorContext &ctx)
- {
+ backend.prepare([&](nnkit::TensorContext &ctx) {
ASSERT_EQ(ctx.size(), 1);
ASSERT_EQ(ctx.name(0), ifm_name);
// TODO Check IFM shape
- auto fill = [&] (const nnkit::TensorContext &, uint32_t, tensor::Accessor<float> &t)
- {
+ auto fill = [&](const nnkit::TensorContext &, uint32_t, tensor::Accessor<float> &t) {
const auto tensor_shape = as_tensor_shape(ifm_shape);
const auto overlay = tensor::make_overlay<float, LexicalLayout>(tensor_shape, ifm_data);
backend.run();
- backend.teardown([&] (nnkit::TensorContext &ctx)
- {
+ backend.teardown([&](nnkit::TensorContext &ctx) {
ASSERT_EQ(ctx.size(), 1);
ASSERT_EQ(ctx.name(0), ofm_name);
- auto verify = [&] (const nnkit::TensorContext &, uint32_t, const tensor::Reader<float> &t)
- {
+ auto verify = [&](const nnkit::TensorContext &, uint32_t, const tensor::Reader<float> &t) {
const auto tensor_shape = as_tensor_shape(ofm_shape);
const auto overlay = tensor::make_overlay<float, LexicalLayout>(tensor_shape, ofm_data);