summaryrefslogtreecommitdiff
path: root/runtimes/libs/misc/src/tensor/IndexFormatter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'runtimes/libs/misc/src/tensor/IndexFormatter.cpp')
-rw-r--r--runtimes/libs/misc/src/tensor/IndexFormatter.cpp49
1 files changed, 49 insertions, 0 deletions
diff --git a/runtimes/libs/misc/src/tensor/IndexFormatter.cpp b/runtimes/libs/misc/src/tensor/IndexFormatter.cpp
new file mode 100644
index 000000000..c949db7a8
--- /dev/null
+++ b/runtimes/libs/misc/src/tensor/IndexFormatter.cpp
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "misc/tensor/IndexFormatter.h"
+
+#include <cassert>
+
+namespace nnfw
+{
+namespace misc
+{
+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 misc
+} // namespace nnfw