diff --git a/backends/apple/coreml/runtime/inmemoryfs/inmemory_filesystem.cpp b/backends/apple/coreml/runtime/inmemoryfs/inmemory_filesystem.cpp index bddb7e4d410..f699316cfdb 100644 --- a/backends/apple/coreml/runtime/inmemoryfs/inmemory_filesystem.cpp +++ b/backends/apple/coreml/runtime/inmemoryfs/inmemory_filesystem.cpp @@ -10,7 +10,6 @@ #include #include #include -#include #include #if __has_include() @@ -22,7 +21,8 @@ namespace filesystem = std::experimental::filesystem; } #endif -#include +#include "range.hpp" +#include "reversed_memory_stream.hpp" namespace { using namespace inmemoryfs; diff --git a/backends/apple/coreml/runtime/inmemoryfs/inmemory_filesystem.hpp b/backends/apple/coreml/runtime/inmemoryfs/inmemory_filesystem.hpp index fedf4190334..d0ace1a5250 100644 --- a/backends/apple/coreml/runtime/inmemoryfs/inmemory_filesystem.hpp +++ b/backends/apple/coreml/runtime/inmemoryfs/inmemory_filesystem.hpp @@ -8,14 +8,15 @@ #pragma once #include -#include #include -#include #include #include #include #include +#include "inmemory_filesystem_metadata.hpp" +#include "memory_buffer.hpp" + namespace inmemoryfs { /// A class representing an in-memory file system. @@ -29,36 +30,36 @@ class InMemoryFileSystem final { DirectoryExpected, // If path is not a directory. FileExpected, // If the path is not a file. }; - + /// Options for loading file content. enum class FileLoadOption: int8_t { Malloc = 1, // Copy file contents into memory. MMap, // Memory map file contents. LazyMMap // Memory map file contents but lazily. }; - + /// The error category for `InMemoryFileSystem`. struct ErrorCategory final: public std::error_category { public: inline const char* name() const noexcept override { return "InMemoryFileSystem"; } - + std::string message(int code) const override; }; - + struct Attributes { time_t modificationTime; - + inline Attributes() noexcept: modificationTime(time(0)) {} }; - + using MetadataWriter = std::function; using MetadataWriterInMemory = std::function; using MetadataReader = std::function(std::istream&)>; - + /// A class representing an in-memory node. This could either be a file node or a directory node. class InMemoryNode { public: @@ -67,7 +68,7 @@ class InMemoryFileSystem final { File = 0, /// Node is a File. Directory /// Node is a Directory. }; - + /// Constructs an in-memory node instance. /// /// @param name The name of the Node. It must be unique in the enclosing Directory. @@ -78,38 +79,38 @@ class InMemoryFileSystem final { attributes_(std::move(attributes)), kind_(kind) {} - + InMemoryNode(InMemoryNode const&) = delete; InMemoryNode& operator=(InMemoryNode const&) = delete; - + inline virtual ~InMemoryNode() {} - + /// Returns the node attributes. inline Attributes attributes() const noexcept { return attributes_; } - + /// Sets the node attributes. /// /// @param attributes The node attributes. inline void set_attributes(Attributes attributes) noexcept { attributes_ = std::move(attributes); } - + /// Returns the node kind, possible values are `File` and `Directory`. inline Kind kind() const noexcept { return kind_; } - + /// Returns the name of the node. inline const std::string& name() const noexcept { return name_; } - + inline void set_name(std::string name) noexcept { std::swap(name_, name); } - + /// Returns `true` if the node is a directory otherwise `false`. inline bool isDirectory() const noexcept { switch (kind_) { @@ -119,58 +120,58 @@ class InMemoryFileSystem final { return false; } } - + /// Returns `true` if the node is a file otherwise `false`. inline bool isFile() const noexcept { return !isDirectory(); } - + private: std::string name_; InMemoryFileSystem::Attributes attributes_; const Kind kind_; }; - + /// Constructs an`InMemoryFileSystem` instance with an empty root and the specified name. /// /// @param rootName The name of the root node. explicit InMemoryFileSystem(std::string rootName = "root") noexcept; - + /// Constructs an`InMemoryFileSystem` instance with the specified root. /// /// @param root The root node. explicit InMemoryFileSystem(std::unique_ptr root) noexcept :root_(std::move(root)) {} - + InMemoryFileSystem(InMemoryFileSystem const&) = delete; InMemoryFileSystem& operator=(InMemoryFileSystem const&) = delete; - + virtual ~InMemoryFileSystem() {} - + /// Returns the root. InMemoryNode *root() const noexcept { return root_.get(); } - + /// Checks if the node at the specified path is a directory. /// /// @param canonical_path The path components from the root. /// @retval `true` if the node at the specified path is a directory otherwise `false`. bool is_directory(const std::vector& canonical_path) noexcept; - + /// Checks if the node at the specified path is a file. /// /// @param canonical_path The path components from the root. /// @retval `true` if the node at the specified path is a file otherwise `false`. bool is_file(const std::vector& canonical_path) noexcept; - + /// Checks if the node at the specified path exists. /// /// @param canonical_path The path components from the root. /// @retval `true` if the node at the specified path exists. bool exists(const std::vector& canonical_path) const noexcept; - + /// Retrieves the canonical path of all the child nodes at the specified path. The node /// at the specified path must be a directory otherwise it returns an empty vector with the `error` /// populated. @@ -180,7 +181,7 @@ class InMemoryFileSystem final { /// @retval paths to all the items at the specified path. std::vector> get_item_paths(const std::vector& canonical_path, std::error_code& error) const noexcept; - + /// Retrieves the attributes of the item at the specified path. /// /// @param canonical_path The path components from the root. @@ -188,7 +189,7 @@ class InMemoryFileSystem final { /// @retval The item attributes at the specified path. std::optional get_attributes(const std::vector& canonical_path, std::error_code& error) const noexcept; - + /// Retrieves the contents of the file at the specified path. /// /// @param canonical_path The path components from the root. @@ -196,7 +197,7 @@ class InMemoryFileSystem final { /// @retval The file contents or `nullptr` if the item at the specified path is not a file. std::shared_ptr get_file_content(const std::vector& canonical_path, std::error_code& error) const noexcept; - + /// Creates an in-memory directory at the specified path. /// /// @param canonical_path The path components from the root. @@ -208,7 +209,7 @@ class InMemoryFileSystem final { Attributes attributes, bool create_intermediate_directories, std::error_code& error) noexcept; - + /// Creates an in-memory file at the specified path. /// /// @param canonical_path The path components from the root. @@ -222,7 +223,7 @@ class InMemoryFileSystem final { Attributes attributes, bool overwrite, std::error_code& error) noexcept; - + /// Removes the item at the specified path. /// /// @param canonical_path The path components from the root. @@ -230,7 +231,7 @@ class InMemoryFileSystem final { /// @retval `true` if the item is removed otherwise `false`. bool remove_item(const std::vector& canonical_path, std::error_code& error) noexcept; - + /// Sets the attributes at the specified path. /// /// @param canonical_path The path components from the root. @@ -239,7 +240,7 @@ class InMemoryFileSystem final { bool set_attributes(const std::vector& canonical_path, Attributes attributes, std::error_code& error) noexcept; - + /// Writes the item at the specified path to the filesystem. /// /// @param canonical_path The path components from the root. @@ -251,7 +252,7 @@ class InMemoryFileSystem final { const std::string& dst_path, bool recursive, std::error_code& error) const noexcept; - + /// Renames the item at the specified path, if there is already an item with the same name then /// the rename would fail. /// @@ -262,7 +263,7 @@ class InMemoryFileSystem final { bool rename_item(const std::vector& canonical_path, const std::string& name, std::error_code& error) noexcept; - + /// Creates an`InMemoryFileSystem` from the filesystem path. /// /// The structure of the `InMemoryFileSystem` is identical to the structure of the filesystem at the @@ -275,7 +276,7 @@ class InMemoryFileSystem final { static std::unique_ptr make_from_directory(const std::string& path, FileLoadOption option, std::error_code& error) noexcept; - + /// Serializes the item at the specified path and writes it to the stream. /// /// The structure of the `InMemoryFileSystem` is identical to the structure of the filesystem at the @@ -292,7 +293,7 @@ class InMemoryFileSystem final { const MetadataWriter& metadata_writer, std::ostream& ostream, std::error_code& error) const noexcept; - + /// Serializes the item at the specified path and writes it to the stream. /// /// The structure of the `InMemoryFileSystem` is identical to the structure of the filesystem at the @@ -309,7 +310,7 @@ class InMemoryFileSystem final { const MetadataWriterInMemory& metadata_writer, void *dst, std::error_code& error) const noexcept; - + /// Computes the size of the buffer that would be needed to serialized the item at the specified path. /// /// @param canonical_path The path components from the root. @@ -319,7 +320,7 @@ class InMemoryFileSystem final { size_t get_buffer_size_for_serialization(const std::vector& canonical_path, size_t alignment, const MetadataWriter& metadata_writer) const noexcept; - + /// Constructs an `InMemoryFileSystem` instance from the buffer contents. /// /// @param buffer The memory buffer. @@ -327,7 +328,7 @@ class InMemoryFileSystem final { /// @retval The constructed `InMemoryFileSystem` or `nullptr` if the deserialization failed. static std::unique_ptr make_from_buffer(const std::shared_ptr& buffer, const MetadataReader& metadata_reader) noexcept; - + private: const std::unique_ptr root_; }; diff --git a/backends/apple/coreml/runtime/inmemoryfs/inmemory_filesystem_metadata.hpp b/backends/apple/coreml/runtime/inmemoryfs/inmemory_filesystem_metadata.hpp index d9a807a7fc7..4f183205b05 100644 --- a/backends/apple/coreml/runtime/inmemoryfs/inmemory_filesystem_metadata.hpp +++ b/backends/apple/coreml/runtime/inmemoryfs/inmemory_filesystem_metadata.hpp @@ -7,11 +7,12 @@ #pragma once -#include #include #include #include -#include + +#include "memory_buffer.hpp" +#include "range.hpp" namespace inmemoryfs { @@ -27,4 +28,3 @@ struct InMemoryFileSystemMetadata { }; } // namespace inmemoryfs - diff --git a/backends/apple/coreml/runtime/inmemoryfs/inmemory_filesystem_py.cpp b/backends/apple/coreml/runtime/inmemoryfs/inmemory_filesystem_py.cpp index 90bc0eb3e1b..66ffa697654 100644 --- a/backends/apple/coreml/runtime/inmemoryfs/inmemory_filesystem_py.cpp +++ b/backends/apple/coreml/runtime/inmemoryfs/inmemory_filesystem_py.cpp @@ -6,13 +6,9 @@ // Please refer to the license found in the LICENSE file in the root directory of the source tree. -#include #include #include -#include -#include -#include -#include +#include #include #include #include @@ -21,6 +17,13 @@ #include #include +#include +#include + +#include "inmemory_filesystem_utils.hpp" +#include "memory_buffer.hpp" +#include "memory_stream.hpp" + #if __has_include() #include #elif __has_include() diff --git a/backends/apple/coreml/runtime/inmemoryfs/inmemory_filesystem_utils.cpp b/backends/apple/coreml/runtime/inmemoryfs/inmemory_filesystem_utils.cpp index 1dffacf15a5..a7810e23db3 100644 --- a/backends/apple/coreml/runtime/inmemoryfs/inmemory_filesystem_utils.cpp +++ b/backends/apple/coreml/runtime/inmemoryfs/inmemory_filesystem_utils.cpp @@ -5,14 +5,17 @@ // // Please refer to the license found in the LICENSE file in the root directory of the source tree. -#include -#include -#include +#include "inmemory_filesystem_utils.hpp" + #include -#include -#include #include +#include + +#include "inmemory_filesystem_metadata.hpp" +#include "inmemory_filesystem_metadata_keys.hpp" +#include "json_util.hpp" + namespace inmemoryfs { using json = nlohmann::json; diff --git a/backends/apple/coreml/runtime/inmemoryfs/inmemory_filesystem_utils.mm b/backends/apple/coreml/runtime/inmemoryfs/inmemory_filesystem_utils.mm index 1f018e3c74a..309b95e8d85 100644 --- a/backends/apple/coreml/runtime/inmemoryfs/inmemory_filesystem_utils.mm +++ b/backends/apple/coreml/runtime/inmemoryfs/inmemory_filesystem_utils.mm @@ -6,15 +6,18 @@ // Please refer to the license found in the LICENSE file in the root directory of the source tree. #import "inmemory_filesystem_utils.hpp" -#import -#import -#import + #import -#import -#import #import #import +#import + +#import "inmemory_filesystem_metadata.hpp" +#import "inmemory_filesystem_metadata_keys.hpp" +#import "json_util.hpp" +#import "objc_json_serde.h" + namespace executorchcoreml { namespace serde { namespace json { @@ -29,13 +32,13 @@ static id to_json(const Range& range) { to_string(RangeKeys::kSize) : to_json_value(range.size) }; } - + static void from_json(id json, Range& range) { NSDictionary *json_dict = SAFE_CAST(json, NSDictionary); if (!json_dict) { return; } - + from_json_value(json_dict[to_string(RangeKeys::kOffset)], range.offset); from_json_value(json_dict[to_string(RangeKeys::kSize)], range.size); } @@ -51,13 +54,13 @@ static id to_json(const InMemoryNodeMetadata& node) { to_string(InMemoryNodeMetadataKeys::kKind) : to_json_value(node.kind) }; } - + static void from_json(id json, InMemoryNodeMetadata& node) { NSDictionary *json_dict = SAFE_CAST(json, NSDictionary); if (!json_dict) { return; } - + from_json_value(json_dict[to_string(InMemoryNodeMetadataKeys::kName)], node.name); from_json_value(json_dict[to_string(InMemoryNodeMetadataKeys::kDataRegion)], node.data_region); from_json_value(json_dict[to_string(InMemoryNodeMetadataKeys::kChildIndices)], node.child_name_to_indices_map); @@ -72,13 +75,13 @@ static id to_json(const InMemoryFileSystemMetadata& fs) { to_string(InMemoryFileSystemMetadataKeys::kNodes) : to_json_value(fs.nodes) }; } - + static void from_json(id json, InMemoryFileSystemMetadata& fs) { NSDictionary *json_dict = SAFE_CAST(json, NSDictionary); if (!json_dict) { return; } - + from_json_value(json_dict[to_string(InMemoryFileSystemMetadataKeys::kNodes)], fs.nodes); } }; @@ -114,7 +117,7 @@ size_t write_metadata_to_buffer(const InMemoryFileSystemMetadata& metadata, void if (!json_object) { return std::optional(); } - + InMemoryFileSystemMetadata metadata; Converter::from_json(to_json_object(json_object.value()), metadata); return metadata; @@ -132,7 +135,7 @@ bool serialize(const InMemoryFileSystem& file_system, write_metadata_to_stream(fs_metadata, stream); return true; }; - + return file_system.serialize(canonical_path, alignment, metadata_writer, ostream, ec); } @@ -145,7 +148,7 @@ bool serialize(const InMemoryFileSystem& file_system, void *metadata_dst) { return ::write_metadata_to_buffer(fs_metadata, metadata_dst); }; - + return file_system.serialize(canonical_path, alignment, metadata_writer, dst, ec); } @@ -156,7 +159,7 @@ size_t get_buffer_size_for_serialization(const InMemoryFileSystem& file_system, std::ostream& stream) { return ::write_metadata_to_stream(fs_metadata, stream); }; - + return file_system.get_buffer_size_for_serialization(canonical_path, alignment, metadata_writer); } @@ -164,7 +167,7 @@ size_t get_buffer_size_for_serialization(const InMemoryFileSystem& file_system, InMemoryFileSystem::MetadataReader metadata_reader = [](std::istream& stream) { return ::read_metadata_from_stream(stream); }; - + return InMemoryFileSystem::make_from_buffer(buffer, metadata_reader); } } // namespace inmemoryfs diff --git a/backends/apple/coreml/runtime/inmemoryfs/memory_buffer.cpp b/backends/apple/coreml/runtime/inmemoryfs/memory_buffer.cpp index 61b50a54655..c4485569d56 100644 --- a/backends/apple/coreml/runtime/inmemoryfs/memory_buffer.cpp +++ b/backends/apple/coreml/runtime/inmemoryfs/memory_buffer.cpp @@ -5,9 +5,10 @@ // // Please refer to the license found in the LICENSE file in the root directory of the source tree. -#include +#include "memory_buffer.hpp" #include +#include #include #include #include diff --git a/backends/apple/coreml/runtime/inmemoryfs/memory_buffer.hpp b/backends/apple/coreml/runtime/inmemoryfs/memory_buffer.hpp index e6e33f5ce26..5243401e2df 100644 --- a/backends/apple/coreml/runtime/inmemoryfs/memory_buffer.hpp +++ b/backends/apple/coreml/runtime/inmemoryfs/memory_buffer.hpp @@ -8,12 +8,13 @@ #pragma once #include -#include #include #include #include #include +#include "range.hpp" + namespace inmemoryfs { /// A class representing a memory buffer. class MemoryBuffer: public std::enable_shared_from_this { @@ -23,38 +24,38 @@ class MemoryBuffer: public std::enable_shared_from_this { MMap = 0, // If the buffer is memory mapped. Malloc , // If the buffer is heap allocated. }; - + enum class ReadOption: uint8_t { Malloc = 0, MMap, LazyMMap }; - + inline MemoryBuffer(void *data, size_t size, Kind kind = Kind::Malloc, std::shared_ptr parent = nullptr) noexcept: - data_(data), + data_(data), size_(size), kind_(kind), parent_(parent) {} - + MemoryBuffer(const MemoryBuffer &) = delete; MemoryBuffer &operator=(const MemoryBuffer &) = delete; - + virtual ~MemoryBuffer() noexcept {} - + /// Returns the underlying data. virtual inline void *data() noexcept { return data_; } - + /// Returns the size of the buffer. inline const size_t size() const noexcept { return size_; } - + /// Loads the contents of the buffer. /// /// - For a malloced buffer, the method is a no op, content is loaded at the initialization time. @@ -65,12 +66,12 @@ class MemoryBuffer: public std::enable_shared_from_this { inline virtual bool load(std::error_code& error) noexcept { return true; } - + /// Returns the kind of the buffer. inline const Kind kind() const noexcept { return kind_; } - + /// Returns the offset range that would be used when writing the buffer content. /// /// @param proposed_offset The proposed offset. @@ -78,7 +79,7 @@ class MemoryBuffer: public std::enable_shared_from_this { inline virtual std::pair get_offset_range(size_t proposed_offset) const noexcept { return {proposed_offset, proposed_offset}; } - + /// Returns the revised range that must be used for writing. /// /// @param dst The destination pointer. @@ -87,7 +88,7 @@ class MemoryBuffer: public std::enable_shared_from_this { inline virtual Range get_revised_range_for_writing(void *dst, Range proposed_range) const noexcept { return proposed_range; } - + /// Writes the contents of the buffer to the destination buffer at the given offset. /// /// @param dst The destination pointer. @@ -97,13 +98,13 @@ class MemoryBuffer: public std::enable_shared_from_this { virtual bool write(void *dst, size_t offset, std::error_code& error) noexcept; - + /// Slices a buffer. /// /// @param range The memory range. /// @retval The sliced buffer if the region is inside the buffer otherwise `nullptr`. virtual std::shared_ptr slice(Range range) noexcept; - + /// Reads the file content at the specified path. /// /// @param file_path The file path. @@ -116,7 +117,7 @@ class MemoryBuffer: public std::enable_shared_from_this { const std::vector& ranges, ReadOption option, std::error_code& error); - + /// Reads the whole file content at the specified path. /// /// @param file_path The file path. @@ -127,28 +128,28 @@ class MemoryBuffer: public std::enable_shared_from_this { read_file_content(const std::string& file_path, ReadOption option, std::error_code& error); - + /// Constructs a `MemoryBuffer`. /// /// @param size The size of the buffer. /// @param alignment The address alignment. static std::unique_ptr make_using_malloc(size_t size, size_t alignment = 1); - - + + /// Constructs a `MemoryBuffer` from memory allocated using `mmap`. /// /// @param size The size of the buffer. static std::unique_ptr make_using_mmap(size_t size); - + /// Constructs a `MemoryBuffer` without copying data. /// /// @param data The buffer content. /// @param size The size of the buffer. static std::unique_ptr make_unowned(void *data, size_t size); - + /// Constructs a `MemoryBuffer` with copying data. /// /// @param data The buffer content. diff --git a/backends/apple/coreml/runtime/inmemoryfs/memory_stream.cpp b/backends/apple/coreml/runtime/inmemoryfs/memory_stream.cpp index 5078db66e80..cb634234c5c 100644 --- a/backends/apple/coreml/runtime/inmemoryfs/memory_stream.cpp +++ b/backends/apple/coreml/runtime/inmemoryfs/memory_stream.cpp @@ -7,6 +7,8 @@ #include "memory_stream.hpp" +#include + namespace inmemoryfs { MemoryStreamBuf::MemoryStreamBuf(const std::shared_ptr& buffer) noexcept : buffer_(buffer) { diff --git a/backends/apple/coreml/runtime/inmemoryfs/memory_stream.hpp b/backends/apple/coreml/runtime/inmemoryfs/memory_stream.hpp index a5f40f26b5f..f7a8100f74f 100644 --- a/backends/apple/coreml/runtime/inmemoryfs/memory_stream.hpp +++ b/backends/apple/coreml/runtime/inmemoryfs/memory_stream.hpp @@ -7,18 +7,18 @@ #pragma once -#include - #include #include +#include "memory_buffer.hpp" + namespace inmemoryfs { /// A class representing an in-memory stream buffer. class MemoryStreamBuf: public std::streambuf { public: ~MemoryStreamBuf() = default; - + /// Constructs a `MemoryStreamBuf` from a `MemoryBuffer`. /// /// @param buffer The memory buffer. @@ -31,7 +31,7 @@ class MemoryStreamBuf: public std::streambuf { /// @param dir The seek direction. /// @retval The stream position. pos_type iseekoff(off_type offset, std::ios_base::seekdir dir); - + /// Called by `seekof` if the `openmode` is output. /// /// @param offset The offset value relative to the `dir`. @@ -44,7 +44,7 @@ class MemoryStreamBuf: public std::streambuf { /// @param which The open mode. /// @retval The stream position. pos_type seekpos(pos_type pos, std::ios_base::openmode which) override; - + /// Called by the public member function `pubseekoff` to alter the stream position. /// /// @param offset The offset value relative to the `dir`. @@ -74,18 +74,18 @@ class MemoryStreamBuf: public std::streambuf { /// /// Returns the value of the current character, converted to a value of type int. std::streambuf::int_type uflow() override; - + /// Called by other member functions to put a character into the controlled output sequence. /// /// Returns the value of the character that's put into the stream, converted to a value of type int. int_type overflow(int_type ch) override; - + /// Retrieves characters from the controlled input sequence and stores them in the array pointed by s, /// until either n characters have been extracted or the end of the sequence is reached. /// /// Returns the number of characters copied. std::streamsize xsgetn(char *s, std::streamsize n) override; - + /// Writes characters from the array pointed to by s into the controlled output sequence, /// until either n characters have been written or the end of the output sequence is reached. /// @@ -122,4 +122,3 @@ class MemoryOStream final : public std::ostream { }; } - diff --git a/backends/apple/coreml/runtime/inmemoryfs/reversed_memory_stream.cpp b/backends/apple/coreml/runtime/inmemoryfs/reversed_memory_stream.cpp index e38b9d08b19..7fe6c26ca41 100644 --- a/backends/apple/coreml/runtime/inmemoryfs/reversed_memory_stream.cpp +++ b/backends/apple/coreml/runtime/inmemoryfs/reversed_memory_stream.cpp @@ -7,6 +7,8 @@ #include "reversed_memory_stream.hpp" +#include + namespace inmemoryfs { ReversedIMemoryStreamBuf::ReversedIMemoryStreamBuf(std::shared_ptr buffer) noexcept diff --git a/backends/apple/coreml/runtime/inmemoryfs/reversed_memory_stream.hpp b/backends/apple/coreml/runtime/inmemoryfs/reversed_memory_stream.hpp index 1827af36413..09b3606bfe0 100644 --- a/backends/apple/coreml/runtime/inmemoryfs/reversed_memory_stream.hpp +++ b/backends/apple/coreml/runtime/inmemoryfs/reversed_memory_stream.hpp @@ -7,18 +7,18 @@ #pragma once -#include - #include #include +#include "memory_buffer.hpp" + namespace inmemoryfs { /// A class for reading an in-memory stream buffer in reverse. class ReversedIMemoryStreamBuf: public std::streambuf { public: ~ReversedIMemoryStreamBuf() = default; - + /// Constructs a `ReversedIMemoryStreamBuf` from a `MemoryBuffer`. /// /// @param buffer The memory buffer. @@ -50,7 +50,7 @@ class ReversedIMemoryStreamBuf: public std::streambuf { /// /// Returns the value of the current character, converted to a value of type int. std::streambuf::int_type uflow() override; - + /// Retrieves characters from the controlled input sequence and stores them in the array pointed by s, /// until either n characters have been extracted or the end of the sequence is reached. /// @@ -60,7 +60,7 @@ class ReversedIMemoryStreamBuf: public std::streambuf { private: /// Reads the character at the specified position. std::streambuf::int_type read(char *pos); - + const std::shared_ptr buffer_; char *start_; char *current_; @@ -70,7 +70,7 @@ class ReversedIMemoryStreamBuf: public std::streambuf { /// A class for reading an in-memory buffer in reverse. class ReversedIMemoryStream final : public std::istream { public: - + /// Constructs a `ReversedIMemoryStream` from a `MemoryBuffer`. /// /// @param buffer The memory buffer. @@ -83,4 +83,3 @@ class ReversedIMemoryStream final : public std::istream { }; } - diff --git a/backends/apple/coreml/runtime/util/json_util.cpp b/backends/apple/coreml/runtime/util/json_util.cpp index 80605c55e8f..a7592541a49 100644 --- a/backends/apple/coreml/runtime/util/json_util.cpp +++ b/backends/apple/coreml/runtime/util/json_util.cpp @@ -6,7 +6,7 @@ // // Please refer to the license found in the LICENSE file in the root directory of the source tree. -#include +#include "json_util.hpp" #include #include diff --git a/backends/apple/coreml/runtime/util/objc_json_serde.mm b/backends/apple/coreml/runtime/util/objc_json_serde.mm index 0f55d4b5919..9102046a759 100644 --- a/backends/apple/coreml/runtime/util/objc_json_serde.mm +++ b/backends/apple/coreml/runtime/util/objc_json_serde.mm @@ -7,7 +7,7 @@ // Please refer to the license found in the LICENSE file in the root directory of the source tree. -#import +#import "objc_json_serde.h" namespace executorchcoreml { namespace serde {