Skip to content

Commit 89b7e89

Browse files
digantdesaifacebook-github-bot
authored andcommitted
Don't print really large output tensors (#448)
Summary: Pull Request resolved: #448 We have better ways to debug this. [This](https://github.com/pytorch/executorch/actions/runs/6271144311/job/170303) job has compressed log >2 GiB. And most of it is coming from these output tensor prints. Might also help with timeouts and long running CI jobs. Reviewed By: kirklandsign Differential Revision: D49538590 fbshipit-source-id: 9ef0fd9f5eff07d8ac159fe3294ab6ff5c736131
1 parent c19b58f commit 89b7e89

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

examples/executor_runner/executor_runner.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,19 @@ int main(int argc, char** argv) {
177177
// readable way.
178178
auto output_tensor = output.toTensor();
179179
auto data_output = output_tensor.const_data_ptr<float>();
180-
for (size_t j = 0; j < output_tensor.numel(); ++j) {
180+
181+
ssize_t max_print_element_count = 10000;
182+
if (output_tensor.numel() > max_print_element_count) {
183+
ET_LOG(
184+
Info,
185+
"Output tensor is too large, printing first %ld elements out of %ld",
186+
max_print_element_count,
187+
output_tensor.numel());
188+
} else {
189+
max_print_element_count = output_tensor.numel();
190+
}
191+
192+
for (size_t j = 0; j < max_print_element_count; ++j) {
181193
ET_LOG(Info, "%f", data_output[j]);
182194
}
183195
}

0 commit comments

Comments
 (0)