aboutsummaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorIsabella Gottardi <isabella.gottardi@arm.com>2019-11-05 17:50:27 +0000
committerGeorgios Pinitas <georgios.pinitas@arm.com>2019-11-14 13:32:30 +0000
commitcd4e9abf7a165f15ccd10ac4541365d4f8a6db19 (patch)
tree442cb14065b866065c1e2837490ae36731a38eef /utils
parentee8cf3287265436d0d12effa36e876dc251eee8c (diff)
downloadComputeLibrary-cd4e9abf7a165f15ccd10ac4541365d4f8a6db19.tar.gz
COMPMID-2452: Add mnist example
* Add small-mnist example * Add PrintAccessor * Add DequantizationLayer graph node Change-Id: I7bc8011e5a602f40fa3c47b231a2a69c804e78c2 Signed-off-by: Isabella Gottardi <isabella.gottardi@arm.com> Reviewed-on: https://review.mlplatform.org/c/2274 Comments-Addressed: Arm Jenkins <bsgcomp@arm.com> Tested-by: Arm Jenkins <bsgcomp@arm.com> Reviewed-by: Giorgio Arena <giorgio.arena@arm.com> Reviewed-by: Georgios Pinitas <georgios.pinitas@arm.com>
Diffstat (limited to 'utils')
-rw-r--r--utils/GraphUtils.cpp13
-rw-r--r--utils/GraphUtils.h38
2 files changed, 51 insertions, 0 deletions
diff --git a/utils/GraphUtils.cpp b/utils/GraphUtils.cpp
index e07e26f2fd..71bfc372fe 100644
--- a/utils/GraphUtils.cpp
+++ b/utils/GraphUtils.cpp
@@ -223,6 +223,19 @@ bool NumPyAccessor::access_tensor(ITensor &tensor)
return false;
}
+#ifdef ARM_COMPUTE_ASSERTS_ENABLED
+PrintAccessor::PrintAccessor(std::ostream &output_stream, IOFormatInfo io_fmt)
+ : _output_stream(output_stream), _io_fmt(io_fmt)
+{
+}
+
+bool PrintAccessor::access_tensor(ITensor &tensor)
+{
+ tensor.print(_output_stream, _io_fmt);
+ return false;
+}
+#endif /* ARM_COMPUTE_ASSERTS_ENABLED */
+
SaveNumPyAccessor::SaveNumPyAccessor(std::string npy_name, const bool is_fortran)
: _npy_name(std::move(npy_name)), _is_fortran(is_fortran)
{
diff --git a/utils/GraphUtils.h b/utils/GraphUtils.h
index bc0822cc89..d6bae3ea3f 100644
--- a/utils/GraphUtils.h
+++ b/utils/GraphUtils.h
@@ -199,6 +199,33 @@ private:
const bool _is_fortran;
};
+/** Print accessor class
+ * @note The print accessor will print only when asserts are enabled.
+ * */
+class PrintAccessor final : public graph::ITensorAccessor
+{
+public:
+ /** Constructor
+ *
+ * @param[out] output_stream (Optional) Output stream
+ * @param[in] io_fmt (Optional) Format information
+ */
+ PrintAccessor(std::ostream &output_stream = std::cout, IOFormatInfo io_fmt = IOFormatInfo());
+ /** Allow instances of this class to be move constructed */
+ PrintAccessor(PrintAccessor &&) = default;
+ /** Prevent instances of this class from being copied (As this class contains pointers) */
+ PrintAccessor(const PrintAccessor &) = delete;
+ /** Prevent instances of this class from being copied (As this class contains pointers) */
+ PrintAccessor &operator=(const PrintAccessor &) = delete;
+
+ // Inherited methods overriden:
+ bool access_tensor(ITensor &tensor) override;
+
+private:
+ std::ostream &_output_stream;
+ IOFormatInfo _io_fmt;
+};
+
/** Image accessor class */
class ImageAccessor final : public graph::ITensorAccessor
{
@@ -615,6 +642,17 @@ inline std::unique_ptr<graph::ITensorAccessor> get_save_npy_output_accessor(cons
}
}
+/** Generates print tensor accessor
+ *
+ * @param[out] output_stream (Optional) Output stream
+ *
+ * @return A print tensor accessor
+ */
+inline std::unique_ptr<graph::ITensorAccessor> get_print_output_accessor(std::ostream &output_stream = std::cout)
+{
+ return arm_compute::support::cpp14::make_unique<PrintAccessor>(output_stream);
+}
+
/** Permutes a given tensor shape given the input and output data layout
*
* @param[in] tensor_shape Tensor shape to permute