--- /dev/null
+#ifndef __NNFW_UTIL_TENSOR_INDEX_FORMATTER_H__
+#define __NNFW_UTIL_TENSOR_INDEX_FORMATTER_H__
+
+#include "util/tensor/Index.h"
+
+#include <ostream>
+
+namespace nnfw
+{
+namespace util
+{
+namespace tensor
+{
+
+class IndexFormatter
+{
+public:
+ IndexFormatter(const nnfw::util::tensor::Index &index) : _index(index)
+ {
+ // DO NOTHING
+ }
+
+public:
+ const nnfw::util::tensor::Index &index(void) const { return _index; }
+
+private:
+ const nnfw::util::tensor::Index &_index;
+};
+
+std::ostream &operator<<(std::ostream &os, const IndexFormatter &fmt);
+
+} // namespace tensor
+} // namespace util
+} // namespace nnfw
+
+#endif // __NNFW_UTIL_TENSOR_INDEX_FORMATTER_H__
--- /dev/null
+#include "util/tensor/IndexFormatter.h"
+
+#include <cassert>
+
+namespace nnfw
+{
+namespace util
+{
+namespace tensor
+{
+
+std::ostream &operator<<(std::ostream &os, const IndexFormatter &fmt)
+{
+ const auto rank = fmt.index().rank();
+
+ assert(rank > 0);
+
+ os << fmt.index().at(0);
+
+ if (rank > 1)
+ {
+ for (uint32_t axis = 1; axis < rank; ++axis)
+ {
+ os << ", " << fmt.index().at(axis);
+ }
+ }
+
+ return os;
+}
+
+} // namespace tensor
+} // namespace util
+} // namespace nnfw
#include "util/environment.h"
#include "util/fp32.h"
#include "util/tensor/IndexIterator.h"
+#include "util/tensor/IndexFormatter.h"
#include "util/tensor/Zipper.h"
+
#include "support/tflite/TensorView.h"
#include "support/tflite/interp/FlatBufferBuilder.h"
check(interpreter.Invoke());
}
-class TensorIndexFormatter
-{
-public:
- TensorIndexFormatter(const nnfw::util::tensor::Index &index) : _index(index)
- {
- // DO NOTHING
- }
-
-public:
- const nnfw::util::tensor::Index &index(void) const { return _index; }
-
-private:
- const nnfw::util::tensor::Index &_index;
-};
-
-std::ostream &operator<<(std::ostream &os, const TensorIndexFormatter &fmt)
-{
- const auto rank = fmt.index().rank();
-
- assert(rank > 0);
-
- os << fmt.index().at(0);
-
- if (rank > 1)
- {
- for (uint32_t axis = 1; axis < rank; ++axis)
- {
- os << ", " << fmt.index().at(axis);
- }
- }
-
- return os;
-}
-
struct TfLiteTensorDiff
{
nnfw::util::tensor::Index index;
// Print out max_diff
if (max_diff.relative_diff > 0)
{
- std::cout << " Max Diff at [" << TensorIndexFormatter(max_diff.index) << "]" << std::endl;
+ std::cout << " Max Diff at [" << nnfw::util::tensor::IndexFormatter(max_diff.index) << "]" << std::endl;
std::cout << " expected: " << max_diff.expected << std::endl;
std::cout << " obtained: " << max_diff.obtained << std::endl;
std::cout << " relative diff: " << max_diff.relative_diff << std::endl;
{
for (const auto &diff : diffs)
{
- std::cout << " Diff at [" << TensorIndexFormatter(diff.index) << "]" << std::endl;
+ std::cout << " Diff at [" << nnfw::util::tensor::IndexFormatter(diff.index) << "]" << std::endl;
std::cout << " expected: " << diff.expected << std::endl;
std::cout << " obtained: " << diff.obtained << std::endl;
std::cout << " relative diff: " << diff.relative_diff << std::endl;