Skip to content

Commit 3c40a8b

Browse files
committed
Update
[ghstack-poisoned]
2 parents cece5bc + 2be4e94 commit 3c40a8b

File tree

6 files changed

+39
-17
lines changed

6 files changed

+39
-17
lines changed

.ci/scripts/gather_test_models.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def model_should_run_on_event(model: str, event: str) -> bool:
9090
We put higher priority and fast models to pull request and rest to push.
9191
"""
9292
if event == "pull_request":
93-
return model in ["mv3", "vit", "qwen2_5"] # TODO: remove, just to test the ci
93+
return model in ["mv3", "vit"]
9494
elif event == "push":
9595
# These are super slow. Only run it periodically
9696
return model not in ["dl3", "edsr", "emformer_predict"]
@@ -104,8 +104,12 @@ def model_should_run_on_target_os(model: str, target_os: str) -> bool:
104104
For example, a big model can be disabled in macos due to the limited macos resources.
105105
"""
106106
if target_os == "macos":
107+
# Disabled in macos due to limited resources, and should stay that way even if
108+
# we otherwise re-enable.
107109
return model not in ["llava"]
108-
return True
110+
# Disabled globally because we have test-llava-runner-linux that does a more
111+
# comprehensive E2E test of llava.
112+
return model not in ["llava"]
109113

110114

111115
def export_models_for_ci() -> dict[str, dict]:

extension/flat_tensor/flat_tensor_data_map.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ ET_NODISCARD Result<FreeableBuffer> FlatTensorDataMap::get_data(
141141
DataLoader::SegmentInfo(DataLoader::SegmentInfo::Type::External));
142142
}
143143

144-
ET_NODISCARD Result<size_t> FlatTensorDataMap::load_data_into(
144+
ET_NODISCARD Error FlatTensorDataMap::load_data_into(
145145
ET_UNUSED const char* key,
146146
ET_UNUSED void* buffer,
147147
ET_UNUSED size_t size) const {
@@ -156,7 +156,7 @@ ET_NODISCARD Result<size_t> FlatTensorDataMap::load_data_into(
156156
return tensor_layout.error();
157157
}
158158
ET_CHECK_OR_RETURN_ERROR(
159-
size < tensor_layout.get().nbytes(),
159+
size <= tensor_layout.get().nbytes(),
160160
InvalidArgument,
161161
"Buffer size %zu is smaller than tensor size %zu",
162162
size,
@@ -187,6 +187,7 @@ ET_NODISCARD Result<const char*> FlatTensorDataMap::get_key(
187187
if (index < 0 || index >= flat_tensor_->tensors()->size()) {
188188
return Error::InvalidArgument;
189189
}
190+
190191
return flat_tensor_->tensors()->Get(index)->fully_qualified_name()->c_str();
191192
}
192193

extension/flat_tensor/flat_tensor_data_map.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class FlatTensorDataMap final : public executorch::runtime::NamedDataMap {
7575
*
7676
* @returns an Error indicating if the load was successful.
7777
*/
78-
ET_NODISCARD executorch::runtime::Result<size_t>
78+
ET_NODISCARD executorch::runtime::Error
7979
load_data_into(const char* key, void* buffer, size_t size) const override;
8080

8181
/**

extension/flat_tensor/test/flat_tensor_data_map_test.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,26 @@ TEST_F(FlatTensorDataMapTest, FlatTensorDataMap_Keys) {
137137
Result<const char*> key2_res = data_map->get_key(2);
138138
EXPECT_EQ(key2_res.error(), Error::InvalidArgument);
139139
}
140+
141+
TEST_F(FlatTensorDataMapTest, FlatTensorDataMap_LoadInto) {
142+
Result<FlatTensorDataMap> data_map =
143+
FlatTensorDataMap::load(data_map_loader_.get());
144+
EXPECT_EQ(data_map.error(), Error::Ok);
145+
146+
// get the metadata
147+
auto meta_data_res = data_map->get_metadata("a");
148+
ASSERT_EQ(meta_data_res.error(), Error::Ok);
149+
150+
// get data blob
151+
void* data = malloc(meta_data_res->nbytes());
152+
auto load_into_error =
153+
data_map->load_data_into("a", data, meta_data_res->nbytes());
154+
ASSERT_EQ(load_into_error, Error::Ok);
155+
156+
// Check tensor data is correct.
157+
float* data_a = static_cast<float*>(data);
158+
for (int i = 0; i < 4; i++) {
159+
EXPECT_EQ(data_a[i], 3.0);
160+
}
161+
free(data);
162+
}

runtime/core/named_data_map.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,9 @@ class ET_EXPERIMENTAL NamedDataMap {
5353
* size of the data for a given key.
5454
* @param buffer The buffer to load the data into. Must point to at least
5555
* `size` bytes of memory.
56-
* @return Result containing the number of bytes written on success. This will
57-
* fail if the buffer is too small.
56+
* @returns an Error indicating if the load was successful.
5857
*/
59-
ET_NODISCARD virtual Result<size_t>
58+
ET_NODISCARD virtual Error
6059
load_data_into(const char* key, void* buffer, size_t size) const = 0;
6160

6261
/**

runtime/executor/tensor_parser_exec_aten.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -224,17 +224,12 @@ ET_NODISCARD Result<void*> getTensorDataPtr(
224224
if (!planned_ptr.ok()) {
225225
return planned_ptr.error();
226226
}
227-
auto size =
227+
auto load_error =
228228
named_data_map->load_data_into(fqn, planned_ptr.get(), nbytes);
229-
if (size.error() != Error::Ok) {
230-
return size.error();
229+
if (load_error != Error::Ok) {
230+
return load_error;
231231
}
232-
ET_CHECK_OR_RETURN_ERROR(
233-
size.get() == nbytes,
234-
InvalidExternalData,
235-
"Expected to load %zu bytes, actually loaded %u bytes",
236-
nbytes,
237-
static_cast<unsigned int>(size.get()));
232+
238233
return planned_ptr;
239234
}
240235
}

0 commit comments

Comments
 (0)