diff options
author | Keith Davis <keith.davis@arm.com> | 2022-10-14 15:50:33 +0100 |
---|---|---|
committer | KeithARM <keith.davis@arm.com> | 2022-10-19 10:33:40 +0000 |
commit | 15f9c68adef324cd0158cea3d021c0f6bef5eecf (patch) | |
tree | 1cd48b345d182fd19efdc40a32e2540befd8f925 /src/armnnUtils | |
parent | 7bbf56598010041ea46c3fa9d32604db777ee26e (diff) | |
download | armnn-15f9c68adef324cd0158cea3d021c0f6bef5eecf.tar.gz |
MLCE-545 INT8 TFLite model execution abnormal
* Add functionality to print output tensors to file in tempdir
* UnitTests
Signed-off-by: Keith Davis <keith.davis@arm.com>
Change-Id: Idfb4c186544187db1fecdfca11c662540f645439
Diffstat (limited to 'src/armnnUtils')
-rw-r--r-- | src/armnnUtils/Filesystem.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/armnnUtils/Filesystem.cpp b/src/armnnUtils/Filesystem.cpp index d917e508d5..1577d2d07c 100644 --- a/src/armnnUtils/Filesystem.cpp +++ b/src/armnnUtils/Filesystem.cpp @@ -5,6 +5,7 @@ #if !defined(ARMNN_DISABLE_FILESYSTEM) #include <armnnUtils/Filesystem.hpp> +#include "armnn/Exceptions.hpp" namespace armnnUtils { @@ -32,6 +33,45 @@ fs::path NamedTempFile(const char* fileName) return namedTempFile; } +/** + * @brief Construct a temporary directory + * + * Given a specified directory name construct a path in the + * system temporary directory. If the directory already exists, it is deleted, + * otherwise create it. This could throw filesystem_error exceptions. + * + * @param path is the path required in the temporary directory. + * @return path consisting of system temporary directory. + */ +std::string CreateDirectory(std::string path) +{ + fs::path tmpDir = fs::temp_directory_path(); + mode_t permissions = 0733; + int result = 0; + + std::string full_path = tmpDir.generic_string() + path; + if (fs::exists(full_path)) + { + fs::remove_all(full_path); + } + +#if defined(_WIN32) + result = _mkdir(full_path.c_str()); // can be used on Windows + armnn::ConditionalThrow<armnn::RuntimeException>((result == 0), "Was unable to create temporary directory"); +#else + result = mkdir(full_path.c_str(), permissions); + armnn::ConditionalThrow<armnn::RuntimeException>((result == 0), "Was unable to create temporary directory"); +#endif + + return full_path + "/"; +} + +FileContents ReadFileContentsIntoString(const std::string path) { + std::ifstream input_file(path); + armnn::ConditionalThrow<armnn::RuntimeException>((input_file.is_open()), "Could not read file contents"); + return FileContents((std::istreambuf_iterator<char>(input_file)), std::istreambuf_iterator<char>()); +} + } // namespace armnnUtils } // namespace Filesystem |