diff options
author | Isabella Gottardi <isabella.gottardi@arm.com> | 2019-07-16 11:48:51 +0100 |
---|---|---|
committer | Manuel Bottini <manuel.bottini@arm.com> | 2019-07-16 16:34:59 +0000 |
commit | 2ea3761416aab259d9d84620dba2e011bcb5d880 (patch) | |
tree | 61dc530fb18cf83ee45286837326d6be0196fcfa /utils/GraphUtils.h | |
parent | ba27e4467dfc04e23ce9483330be062e9aaebdc5 (diff) | |
download | ComputeLibrary-2ea3761416aab259d9d84620dba2e011bcb5d880.tar.gz |
COMPMID-2336: Fix InPlaceMutator condition and add SaveNumpyAccessor
Change-Id: I223a688cfc19465f8581f691b32891cefd375907
Signed-off-by: Isabella Gottardi <isabella.gottardi@arm.com>
Reviewed-on: https://review.mlplatform.org/c/1555
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Reviewed-by: Pablo Marquez <pablo.tello@arm.com>
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Reviewed-by: Michalis Spyrou <michalis.spyrou@arm.com>
Diffstat (limited to 'utils/GraphUtils.h')
-rw-r--r-- | utils/GraphUtils.h | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/utils/GraphUtils.h b/utils/GraphUtils.h index 88221c7dc8..fe19eb3196 100644 --- a/utils/GraphUtils.h +++ b/utils/GraphUtils.h @@ -167,6 +167,31 @@ private: std::ostream &_output_stream; }; +/** SaveNumPy accessor class */ +class SaveNumPyAccessor final : public graph::ITensorAccessor +{ +public: + /** Constructor + * + * @param[in] npy_name Npy file name. + * @param[in] is_fortran (Optional) If true, save tensor in fortran order. + */ + SaveNumPyAccessor(const std::string npy_name, const bool is_fortran = false); + /** Allow instances of this class to be move constructed */ + SaveNumPyAccessor(SaveNumPyAccessor &&) = default; + /** Prevent instances of this class from being copied (As this class contains pointers) */ + SaveNumPyAccessor(const SaveNumPyAccessor &) = delete; + /** Prevent instances of this class from being copied (As this class contains pointers) */ + SaveNumPyAccessor &operator=(const SaveNumPyAccessor &) = delete; + + // Inherited methods overriden: + bool access_tensor(ITensor &tensor) override; + +private: + const std::string _npy_name; + const bool _is_fortran; +}; + /** Image accessor class */ class ImageAccessor final : public graph::ITensorAccessor { @@ -558,6 +583,27 @@ inline std::unique_ptr<graph::ITensorAccessor> get_npy_output_accessor(const std } } +/** Generates appropriate npy output accessor according to the specified npy_path + * + * @note If npy_path is empty will generate a DummyAccessor else will generate a SaveNpyAccessor + * + * @param[in] npy_name Npy filename. + * @param[in] is_fortran (Optional) If true, save tensor in fortran order. + * + * @return An appropriate tensor accessor + */ +inline std::unique_ptr<graph::ITensorAccessor> get_save_npy_output_accessor(const std::string &npy_name, const bool is_fortran = false) +{ + if(npy_name.empty()) + { + return arm_compute::support::cpp14::make_unique<DummyAccessor>(0); + } + else + { + return arm_compute::support::cpp14::make_unique<SaveNumPyAccessor>(npy_name, is_fortran); + } +} + /** Permutes a given tensor shape given the input and output data layout * * @param[in] tensor_shape Tensor shape to permute |