Skip to content

Commit 61d6a8b

Browse files
committed
Update on "[executorch][core] NamedDataMap interface"
Add NamedDataMap interface to runtime. Differential Revision: [D66834552](https://our.internmc.facebook.com/intern/diff/D66834552/) [ghstack-poisoned]
2 parents d2089a0 + 3eb8ff7 commit 61d6a8b

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

runtime/core/named_data_map.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,28 +46,30 @@ class ET_EXPERIMENTAL NamedDataMap {
4646
* Loads data corresponding to the fqn into the provided buffer.
4747
*
4848
* @param fqn Fully qualified name of the tensor.
49-
* @param size The number of bytes to load.
49+
* @param size The number of bytes to load. Use `get_metadata` to retrieve the
50+
* size of the tensor for a given fqn.
5051
* @param buffer The buffer to load the data into. Must point to at least
5152
* `size` bytes of memory.
52-
* @return An error code on if the load was successful.
53+
* @return Result containing the number of bytes written on success.
5354
*/
54-
ET_NODISCARD virtual Error
55+
ET_NODISCARD virtual Result<size_t>
5556
load_data_into(const char* fqn, size_t size, void* buffer) const = 0;
5657

5758
/**
5859
* Get the number of keys in the NamedDataMap.
5960
*
6061
* @return Result containing the number of keys.
6162
*/
62-
ET_NODISCARD virtual Result<int> get_num_keys() const = 0;
63+
ET_NODISCARD virtual Result<size_t> get_num_keys() const = 0;
6364

6465
/**
6566
* Get the key at the given index.
6667
*
6768
* @param index The index of the key to retrieve.
68-
* @return Result containing the key at the given index.
69+
* @return Result containing the key at the given index. Note: the returned
70+
* pointer is only valid for the lifetime of the DataMap.
6971
*/
70-
ET_NODISCARD virtual Result<const char*> get_key(int index) const = 0;
72+
ET_NODISCARD virtual Result<const char*> get_key(size_t index) const = 0;
7173
};
7274

7375
} // namespace runtime

0 commit comments

Comments
 (0)