-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Copy a tensor back from the device before ETDump writes it #22095
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7f7c703
Copy a tensor back from the device before ETDump writes it
shoumikhin 80bda29
Document the re2 guard and the shared-build registry ordering
7eab57c
Merge branch 'main' into fix-etdump-device-tensor
shoumikhin dc82fba
Merge branch 'main' into fix-etdump-device-tensor
shoumikhin 74995b7
Address review: reuse aten_bridge device mapping and hide the device-…
shoumikhin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| /* | ||
| * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| * All rights reserved. | ||
| * | ||
| * This source code is licensed under the BSD-style license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| */ | ||
|
|
||
| // The allocator registry is a process wide static with no way to remove an | ||
| // entry, so the "nothing registered for this device" path needs a binary that | ||
| // never registers anything. | ||
|
|
||
| #include <gtest/gtest.h> | ||
| #include <cstdint> | ||
| #include <cstdlib> | ||
|
|
||
| #include <executorch/devtools/etdump/data_sinks/buffer_data_sink.h> | ||
| #include <executorch/devtools/etdump/etdump_flatcc.h> | ||
| #include <executorch/runtime/core/device_allocator.h> | ||
| #include <executorch/runtime/core/portable_type/tensor_impl.h> | ||
| #include <executorch/runtime/platform/runtime.h> | ||
| #include <executorch/test/utils/DeathTest.h> | ||
|
|
||
| using namespace ::executorch::etdump; | ||
| using namespace ::executorch::runtime; | ||
| using namespace ::executorch::runtime::etensor; | ||
|
|
||
| namespace { | ||
|
|
||
| TEST(ETDumpNoDeviceAllocatorTest, LogTensorOnUnregisteredDeviceAborts) { | ||
| runtime_init(); | ||
| ASSERT_EQ(get_device_allocator(DeviceType::CUDA), nullptr); | ||
|
|
||
| // Host memory, so the test fails by not dying rather than by crashing if | ||
| // ETDump ever reads the pointer instead of reporting the missing allocator. | ||
| float data[] = {1.5f, 2.5f, 3.5f, 4.5f}; | ||
| int32_t sizes[] = {4}; | ||
| uint8_t dim_order[] = {0}; | ||
| int32_t strides[] = {1}; | ||
| TensorImpl impl( | ||
| ScalarType::Float, | ||
| 1, | ||
| sizes, | ||
| data, | ||
| dim_order, | ||
| strides, | ||
| TensorShapeDynamism::STATIC, | ||
| DeviceType::CUDA, | ||
| 0); | ||
| Tensor tensor(&impl); | ||
|
|
||
| const size_t debug_buf_size = 2048; | ||
| void* debug_buf = malloc(debug_buf_size); | ||
| auto buffer_data_sink = BufferDataSink::create(debug_buf, debug_buf_size); | ||
| ASSERT_TRUE(buffer_data_sink.ok()); | ||
|
|
||
| ETDumpGen etdump_gen; | ||
| etdump_gen.create_event_block("test_block"); | ||
| etdump_gen.set_data_sink(&buffer_data_sink.get()); | ||
|
|
||
| ET_EXPECT_DEATH( | ||
| etdump_gen.log_evalue(EValue(tensor)), "No device allocator registered"); | ||
|
|
||
| free(debug_buf); | ||
| } | ||
|
|
||
| } // namespace |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.