From 417557704527319166e511d778ef57ddee713c2b Mon Sep 17 00:00:00 2001 From: lucylq Date: Fri, 31 Jan 2025 12:04:21 -0800 Subject: [PATCH 1/3] [executorch] Create target for named_data_map ^ Differential Revision: [D68972364](https://our.internmc.facebook.com/intern/diff/D68972364/) [ghstack-poisoned] --- runtime/core/targets.bzl | 16 +++++++++++++++- runtime/core/tensor_layout.cpp | 2 +- runtime/core/tensor_layout.h | 2 +- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/runtime/core/targets.bzl b/runtime/core/targets.bzl index 61351b083bf..0a6297bb6cd 100644 --- a/runtime/core/targets.bzl +++ b/runtime/core/targets.bzl @@ -41,7 +41,6 @@ def define_common_targets(): "defines.h", "error.h", "freeable_buffer.h", - "named_data_map.h", "result.h", "span.h", ], @@ -118,6 +117,7 @@ def define_common_targets(): ], ) + runtime.cxx_library( name = "tag", srcs = ["tag.cpp"], @@ -133,6 +133,20 @@ def define_common_targets(): ], ) + runtime.cxx_library( + name = "named_data_map", + exported_headers = [ + "named_data_map.h", + ], + visibility = [ + "//executorch/...", + "@EXECUTORCH_CLIENTS", + ], + exported_deps = [ + ":tensor_layout", + ], + ) + runtime.cxx_library( name = "tensor_layout", srcs = ["tensor_layout.cpp"], diff --git a/runtime/core/tensor_layout.cpp b/runtime/core/tensor_layout.cpp index 07106e6c7e4..748a43fc5d6 100644 --- a/runtime/core/tensor_layout.cpp +++ b/runtime/core/tensor_layout.cpp @@ -30,7 +30,7 @@ Result calculate_nbytes( } } // namespace -Result TensorLayout::create( +Result TensorLayout::create( Span sizes, Span dim_order, executorch::aten::ScalarType scalar_type) { diff --git a/runtime/core/tensor_layout.h b/runtime/core/tensor_layout.h index dcd0a2af839..6ad04f19fbd 100644 --- a/runtime/core/tensor_layout.h +++ b/runtime/core/tensor_layout.h @@ -33,7 +33,7 @@ class ET_EXPERIMENTAL TensorLayout final { * @param[in] scalar_type The scalar type of the tensor. * @return A Result containing the TensorLayout on success, or an error. */ - static executorch::runtime::Result create( + static executorch::runtime::Result create( Span sizes, Span dim_order, executorch::aten::ScalarType scalar_type); From 9edf8ec442430f1e91053d9fbb01d50526de82a7 Mon Sep 17 00:00:00 2001 From: lucylq Date: Fri, 31 Jan 2025 12:10:00 -0800 Subject: [PATCH 2/3] Update on "[executorch] Create target for named_data_map" ^ Differential Revision: [D68972364](https://our.internmc.facebook.com/intern/diff/D68972364/) [ghstack-poisoned] --- runtime/core/targets.bzl | 1 - 1 file changed, 1 deletion(-) diff --git a/runtime/core/targets.bzl b/runtime/core/targets.bzl index 0a6297bb6cd..c3535688f63 100644 --- a/runtime/core/targets.bzl +++ b/runtime/core/targets.bzl @@ -117,7 +117,6 @@ def define_common_targets(): ], ) - runtime.cxx_library( name = "tag", srcs = ["tag.cpp"], From 2a87d025a37884d5d814096837e6b3b1e52b167d Mon Sep 17 00:00:00 2001 From: lucylq Date: Fri, 31 Jan 2025 15:47:38 -0800 Subject: [PATCH 3/3] Update on "[executorch] Create target for named_data_map" ^ Differential Revision: [D68972364](https://our.internmc.facebook.com/intern/diff/D68972364/) [ghstack-poisoned] --- runtime/core/tensor_layout.h | 8 ++++---- runtime/core/test/tensor_layout_test.cpp | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/runtime/core/tensor_layout.h b/runtime/core/tensor_layout.h index 6ad04f19fbd..c2c3833f528 100644 --- a/runtime/core/tensor_layout.h +++ b/runtime/core/tensor_layout.h @@ -77,16 +77,16 @@ class ET_EXPERIMENTAL TensorLayout final { scalar_type_(scalar_type), nbytes_(nbytes) {} /// The sizes of the tensor. - Span sizes_; + const Span sizes_; /// The dim order of the tensor. - Span dim_order_; + const Span dim_order_; /// The scalar type of the tensor. - executorch::aten::ScalarType scalar_type_; + const executorch::aten::ScalarType scalar_type_; /// The size in bytes of the tensor. - size_t nbytes_; + const size_t nbytes_; }; } // namespace runtime diff --git a/runtime/core/test/tensor_layout_test.cpp b/runtime/core/test/tensor_layout_test.cpp index 3e032788eab..0039745f77b 100644 --- a/runtime/core/test/tensor_layout_test.cpp +++ b/runtime/core/test/tensor_layout_test.cpp @@ -26,7 +26,7 @@ TEST(TestTensorLayout, Ctor) { Span sizes_span = {sizes.data(), sizes.size()}; Span dim_order_span = {dim_order.data(), dim_order.size()}; - Result layout_res = + Result layout_res = TensorLayout::create(sizes_span, dim_order_span, ScalarType::Float); EXPECT_TRUE(layout_res.ok()); @@ -50,7 +50,7 @@ TEST(TestTensorLayout, Ctor_InvalidDimOrder) { Span sizes_span = {sizes.data(), sizes.size()}; Span dim_order_span = {dim_order.data(), dim_order.size()}; - Result layout_res = + Result layout_res = TensorLayout::create(sizes_span, dim_order_span, ScalarType::Float); EXPECT_EQ(layout_res.error(), Error::InvalidArgument); } @@ -61,7 +61,7 @@ TEST(TestTensorLayout, Ctor_InvalidSizes) { Span sizes_span = {sizes.data(), sizes.size()}; Span dim_order_span = {dim_order.data(), dim_order.size()}; - Result layout_res = + Result layout_res = TensorLayout::create(sizes_span, dim_order_span, ScalarType::Float); EXPECT_EQ(layout_res.error(), Error::InvalidArgument); } @@ -72,7 +72,7 @@ TEST(TestTensorLayout, Ctor_SizesDimOrderMismatch) { Span sizes_span = {sizes.data(), sizes.size()}; Span dim_order_span = {dim_order.data(), dim_order.size()}; - Result layout_res = + Result layout_res = TensorLayout::create(sizes_span, dim_order_span, ScalarType::Float); EXPECT_EQ(layout_res.error(), Error::InvalidArgument); }