Skip to content

Commit

Permalink
Update on "[devtool] make datasink as a sepreate directory"
Browse files Browse the repository at this point in the history
this diff make data_sink_base and its childrens as a seperate directory for better structure.

Differential Revision: [D69732404](https://our.internmc.facebook.com/intern/diff/D69732404/)

[ghstack-poisoned]
  • Loading branch information
Gasoonjia committed Feb 20, 2025
2 parents c7be2b4 + eaa6569 commit ffad592
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 8 deletions.
2 changes: 2 additions & 0 deletions devtools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ add_custom_command(
add_library(
etdump ${CMAKE_CURRENT_SOURCE_DIR}/etdump/etdump_flatcc.cpp
${CMAKE_CURRENT_SOURCE_DIR}/etdump/emitter.cpp
${CMAKE_CURRENT_SOURCE_DIR}/etdump/buffer_data_sink.cpp
${CMAKE_CURRENT_SOURCE_DIR}/etdump/buffer_data_sink.h
)

target_link_libraries(
Expand Down
2 changes: 1 addition & 1 deletion devtools/etdump/data_sinks/buffer_data_sink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Result<size_t> BufferDataSink::write(const void* ptr, size_t length) {
return static_cast<size_t>(-1);
}
uint8_t* offset_ptr =
internal::alignPointer(debug_buffer_.data() + offset_, 64);
internal::align_pointer(debug_buffer_.data() + offset_, 64);

// Zero out the padding between data blobs.
size_t n_zero_pad = offset_ptr - debug_buffer_.data() - offset_;
Expand Down
2 changes: 1 addition & 1 deletion devtools/etdump/data_sinks/data_sink_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace etdump {
/**
* DataSinkBase is an abstract class that users can inherit and implement
* to customize the storage and management of debug data in ETDumpGen. This
* class provides an basic and essential interface for writing datablob to a
* class provides a basic and essential interface for writing datablob to a
* user-defined storage, retrieving storage capacity, and tracking the amount of
* data stored.
*/
Expand Down
8 changes: 4 additions & 4 deletions devtools/etdump/etdump_flatcc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ ETDumpGen::ETDumpGen(Span<uint8_t> buffer) {

if (buffer.data() != nullptr) {
builder_ =
(struct flatcc_builder*)internal::alignPointer(buffer.data(), 64);
uintptr_t buffer_with_builder = (uintptr_t)internal::alignPointer(
(struct flatcc_builder*)internal::align_pointer(buffer.data(), 64);
uintptr_t buffer_with_builder = (uintptr_t)internal::align_pointer(
builder_ + sizeof(struct flatcc_builder), 64);
size_t builder_size =
(size_t)(buffer_with_builder - (uintptr_t)buffer.data());
Expand Down Expand Up @@ -630,7 +630,7 @@ size_t ETDumpGen::get_debug_buffer_size() const {
}

size_t ETDumpGen::get_data_sink_size() const {
ET_CHECK_MSG(data_sink_, "Must set data sink before checking its size\n");
ET_CHECK_MSG(data_sink_, "Must set data sink before checking its size");
Result<size_t> ret = data_sink_->get_storage_size();
ET_CHECK_MSG(
ret.ok(),
Expand All @@ -640,7 +640,7 @@ size_t ETDumpGen::get_data_sink_size() const {
}

long ETDumpGen::write_tensor_or_raise_error(Tensor tensor) {
ET_CHECK_MSG(data_sink_, "Must set data sink before writing data\n");
ET_CHECK_MSG(data_sink_, "Must set data sink before writing data");
Result<size_t> ret =
data_sink_->write(tensor.const_data_ptr(), tensor.nbytes());
ET_CHECK_MSG(
Expand Down
2 changes: 1 addition & 1 deletion devtools/etdump/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace executorch {
namespace etdump {
namespace internal {

inline uint8_t* alignPointer(void* ptr, size_t alignment) {
inline uint8_t* align_pointer(void* ptr, size_t alignment) {
intptr_t addr = reinterpret_cast<intptr_t>(ptr);
if ((addr & (alignment - 1)) == 0) {
// Already aligned.
Expand Down
1 change: 0 additions & 1 deletion runtime/core/error.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ enum class Error : error_code_t {
/// Does not have enough resources to perform the requested operation.
OutOfResources = 0x25,


/*
* Delegate errors.
*/
Expand Down

0 comments on commit ffad592

Please sign in to comment.