$(NNTRAINER_ROOT)/nntrainer/dataset/databuffer_factory.cpp \
$(NNTRAINER_ROOT)/nntrainer/dataset/databuffer_func.cpp \
$(NNTRAINER_ROOT)/nntrainer/dataset/databuffer_file.cpp \
+ $(NNTRAINER_ROOT)/nntrainer/compiler/ini_interpreter.cpp \
$(NNTRAINER_ROOT)/nntrainer/tensor/tensor.cpp \
$(NNTRAINER_ROOT)/nntrainer/tensor/lazy_tensor.cpp \
$(NNTRAINER_ROOT)/nntrainer/tensor/manager.cpp \
$(NNTRAINER_ROOT)/nntrainer/utils/ini_wrapper.cpp \
$(NNTRAINER_ROOT)/nntrainer/utils/parse_util.cpp \
$(NNTRAINER_ROOT)/nntrainer/utils/profiler.cpp \
- $(NNTRAINER_ROOT)/nntrainer/utils/profiler.cpp \
- $(NNTRAINER_ROOT)/nntrainer/compiler/node_exporter.cpp \
+ $(NNTRAINER_ROOT)/nntrainer/utils/node_exporter.cpp \
$(NNTRAINER_ROOT)/nntrainer/app_context.cpp
# Add tflite backbone building
#include <node_exporter.h>
-
+// SPDX-License-Identifier: Apache-2.0
+/**
+ * Copyright (C) 2021 Jihoon Lee <jhoon.it.lee@samsung.com>
+ *
+ * @file node_exporter.cpp
+ * @date 09 April 2021
+ * @brief NNTrainer Node exporter
+ * @see https://github.com/nnstreamer/nntrainer
+ * @author Jihoon Lee <jhoon.it.lee@samsung.com>
+ * @bug No known bugs except for NYI items
+ */
namespace nntrainer {
template <>
const std::vector<std::pair<std::string, std::string>> &
Exporter::get_result<ExportMethods::METHOD_STRINGVECTOR>() {
if (!is_exported) {
- throw std::invalid_argument("This exporter is not exported anything yet");
+ throw std::invalid_argument("This exporter has not exported anything yet");
}
return stored_result;
* Copyright (C) 2021 Jihoon Lee <jhoon.it.lee@samsung.com>
*
* @file node_exporter.h
- * @date 08 April 2021
+ * @date 09 April 2021
* @brief NNTrainer Node exporter
* @see https://github.com/nnstreamer/nntrainer
* @author Jihoon Lee <jhoon.it.lee@samsung.com>
template <typename... Ts>
void save_result(const std::tuple<Ts...> &props, ExportMethods method) {
switch (method) {
+
case ExportMethods::METHOD_STRINGVECTOR: {
+
+ /**
+ * @brief function to pass to the iterate_prop, this saves the property to
+ * stored_result
+ *
+ * @param prop property property to pass
+ * @param index index of the current property
+ */
auto callable = [this](auto &&prop, size_t index) {
std::string key = std::remove_reference_t<decltype(prop)>::key;
stored_result.emplace_back(key, to_string(prop));
*
* @file unittest_properties.h
* @date 09 April 2021
- * @brief This file contains test and specification of properties
+ * @brief This file contains test and specification of properties and exporter
* @see https://github.com/nnstreamer/nntrainer
* @author Jihoon Lee <jhoon.it.lee@samsung.com>
* @bug No known bugs except for NYI items
*/
#include <gtest/gtest.h>
+#include <utility>
+
#include <base_properties.h>
+#include <nntrainer_error.h>
+#include <node_exporter.h>
#include <util_func.h>
namespace { /**< define a property for testing */
}
}
+/// @todo convert this to typed param test
TEST(BasicProperty, valid_p) {
- { /** set -> get / to_string */
+ { /** set -> get / to_string, int*/
NumBanana b;
b.set(123);
EXPECT_EQ(b.get(), 123);
EXPECT_EQ(nntrainer::to_string(b), "123");
-
- QualityOfBanana q;
- q.set("this is good");
- EXPECT_EQ(q.get(), "this is good");
- EXPECT_EQ(nntrainer::to_string(q), "this is good");
}
- { /**< from_string -> get / to_string */
+ { /**< from_string -> get / to_string, int*/
NumBanana b;
nntrainer::from_string("3", b);
EXPECT_EQ(b.get(), 3);
EXPECT_EQ(nntrainer::to_string(b), "3");
+ }
+
+ { /** set -> get / to_string, string*/
+ QualityOfBanana q;
+ q.set("this is good");
+ EXPECT_EQ(q.get(), "this is good");
+ EXPECT_EQ(nntrainer::to_string(q), "this is good");
+ }
+ { /**< from_string -> get / to_string, string prop */
QualityOfBanana q;
nntrainer::from_string("this is good", q);
EXPECT_EQ(q.get(), "this is good");
EXPECT_EQ(nntrainer::to_string(q), "this is good");
}
+
+ { /**< exporter test */
+ auto props = std::make_tuple(NumBanana(), QualityOfBanana());
+
+ nntrainer::Exporter e;
+ e.save_result(props, nntrainer::ExportMethods::METHOD_STRINGVECTOR);
+
+ auto result = e.get_result<nntrainer::ExportMethods::METHOD_STRINGVECTOR>();
+
+ auto pair = std::pair<std::string, std::string>("num_banana", "1");
+ EXPECT_EQ(result[0], pair);
+
+ auto pair2 = std::pair<std::string, std::string>("quality_banana", "");
+ EXPECT_EQ(result[1], pair2);
+ }
}
TEST(BasicProperty, setNotValid_01_n) {
EXPECT_THROW(nntrainer::from_string("invalid_str", q), std::invalid_argument);
}
+TEST(Exporter, invalidMethods_n) {
+ auto props = std::make_tuple(NumBanana(), QualityOfBanana());
+
+ nntrainer::Exporter e;
+ EXPECT_THROW(e.save_result(props, nntrainer::ExportMethods::METHOD_UNDEFINED),
+ nntrainer::exception::not_supported);
+}
+
+TEST(Exporter, notExported_n) {
+ auto props = std::make_tuple(NumBanana(), QualityOfBanana());
+
+ nntrainer::Exporter e;
+ /// intended comment
+ // e.save_result(props, nntrainer::ExportMethods::METHOD_STRINGVECTOR);
+
+ EXPECT_THROW(e.get_result<nntrainer::ExportMethods::METHOD_STRINGVECTOR>(),
+ std::invalid_argument);
+}
+
/**
* @brief Main gtest
*/