Skip to content

Commit f9616a7

Browse files
committed
Remove deprecated string_view aliases, migrate callers to std::string_view
Migrate the remaining executorch::aten::string_view callers (the data-map APIs and op_linalg_svd) to std::string_view, then delete the deprecated torch::executor and executorch::runtime::etensor string_view aliases. portable_type/string_view.h held only those aliases and is removed; exec_aten.h and scalar_type_util.h now include <string_view> directly. This parallels the optional cleanup in the previous commit. The data-map header signatures (NamedDataMap and its overrides) move together since the underlying type is unchanged.
1 parent 5ba484e commit f9616a7

15 files changed

Lines changed: 28 additions & 63 deletions

File tree

backends/cadence/generic/operators/op_linalg_svd.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ std::tuple<Tensor&, Tensor&, Tensor&> linalg_svd_out(
261261
const Tensor& A,
262262
bool full_matrices,
263263
bool compute_uv,
264-
std::optional<::executorch::aten::string_view> driver,
264+
std::optional<std::string_view> driver,
265265
Tensor& U,
266266
Tensor& S,
267267
Tensor& Vh) {

backends/cadence/generic/operators/op_linalg_svd.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ linalg_svd_out(
2626
const ::executorch::aten::Tensor& A,
2727
bool full_matrices,
2828
bool compute_uv,
29-
std::optional<::executorch::aten::string_view> driver,
29+
std::optional<std::string_view> driver,
3030
::executorch::aten::Tensor& U,
3131
::executorch::aten::Tensor& S,
3232
::executorch::aten::Tensor& Vh);

extension/flat_tensor/flat_tensor_data_map.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ bool is_aligned(const void* data) {
4949
}
5050

5151
Result<const flat_tensor_flatbuffer::NamedData*> get_named_data(
52-
executorch::aten::string_view key,
52+
std::string_view key,
5353
const flatbuffers::Vector<
5454
flatbuffers::Offset<flat_tensor_flatbuffer::NamedData>>* named_data,
5555
const flatbuffers::Vector<
@@ -127,7 +127,7 @@ Result<const TensorLayout> create_tensor_layout(
127127
} // namespace
128128

129129
ET_NODISCARD Result<const TensorLayout> FlatTensorDataMap::get_tensor_layout(
130-
executorch::aten::string_view key) const {
130+
std::string_view key) const {
131131
Result<uint64_t> segment_end_offset = get_segment_end_offset(header_);
132132
if (!segment_end_offset.ok()) {
133133
return segment_end_offset.error();
@@ -144,7 +144,7 @@ ET_NODISCARD Result<const TensorLayout> FlatTensorDataMap::get_tensor_layout(
144144
}
145145

146146
ET_NODISCARD Result<FreeableBuffer> FlatTensorDataMap::get_data(
147-
executorch::aten::string_view key) const {
147+
std::string_view key) const {
148148
Result<uint64_t> segment_end_offset = get_segment_end_offset(header_);
149149
if (!segment_end_offset.ok()) {
150150
return segment_end_offset.error();
@@ -170,7 +170,7 @@ ET_NODISCARD Result<FreeableBuffer> FlatTensorDataMap::get_data(
170170
}
171171

172172
ET_NODISCARD Error FlatTensorDataMap::load_data_into(
173-
ET_UNUSED executorch::aten::string_view key,
173+
ET_UNUSED std::string_view key,
174174
ET_UNUSED void* buffer,
175175
ET_UNUSED size_t size) const {
176176
Result<uint64_t> segment_end_offset = get_segment_end_offset(header_);

extension/flat_tensor/flat_tensor_data_map.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class FlatTensorDataMap final
5454
ET_NODISCARD
5555
executorch::runtime::Result<
5656
const executorch::ET_RUNTIME_NAMESPACE::TensorLayout>
57-
get_tensor_layout(executorch::aten::string_view key) const override;
57+
get_tensor_layout(std::string_view key) const override;
5858

5959
/**
6060
* Retrieve read-only data for the specified key.
@@ -65,7 +65,7 @@ class FlatTensorDataMap final
6565
*/
6666
ET_NODISCARD
6767
executorch::runtime::Result<executorch::runtime::FreeableBuffer> get_data(
68-
executorch::aten::string_view key) const override;
68+
std::string_view key) const override;
6969

7070
/**
7171
* Loads the data of the specified tensor into the provided buffer.
@@ -78,7 +78,7 @@ class FlatTensorDataMap final
7878
* @returns an Error indicating if the load was successful.
7979
*/
8080
ET_NODISCARD executorch::runtime::Error load_data_into(
81-
executorch::aten::string_view key,
81+
std::string_view key,
8282
void* buffer,
8383
size_t size) const override;
8484

extension/named_data_map/merged_data_map.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
#include <unordered_map>
1313
#include <vector>
1414

15-
using executorch::aten::string_view;
1615
using executorch::ET_RUNTIME_NAMESPACE::NamedDataMap;
1716
using executorch::ET_RUNTIME_NAMESPACE::TensorLayout;
1817
using executorch::runtime::Error;
1918
using executorch::runtime::FreeableBuffer;
2019
using executorch::runtime::Result;
2120
using executorch::runtime::Span;
21+
using std::string_view;
2222

2323
namespace executorch::extension {
2424
namespace ET_MERGED_DATA_MAP_NAMESPACE {

extension/named_data_map/merged_data_map.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class MergedDataMap final
4848
ET_NODISCARD
4949
executorch::runtime::Result<
5050
const executorch::ET_RUNTIME_NAMESPACE::TensorLayout>
51-
get_tensor_layout(executorch::aten::string_view key) const override;
51+
get_tensor_layout(std::string_view key) const override;
5252

5353
/**
5454
* Retrieve read-only data for the specified key.
@@ -59,7 +59,7 @@ class MergedDataMap final
5959
*/
6060
ET_NODISCARD
6161
executorch::runtime::Result<executorch::runtime::FreeableBuffer> get_data(
62-
executorch::aten::string_view key) const override;
62+
std::string_view key) const override;
6363

6464
/**
6565
* Loads the data of the specified tensor into the provided buffer.
@@ -72,7 +72,7 @@ class MergedDataMap final
7272
* @returns an Error indicating if the load was successful.
7373
*/
7474
ET_NODISCARD executorch::runtime::Error load_data_into(
75-
executorch::aten::string_view key,
75+
std::string_view key,
7676
void* buffer,
7777
size_t size) const override;
7878

runtime/core/exec_aten/exec_aten.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#pragma once
1010

1111
#include <optional>
12+
#include <string_view>
1213

1314
#include <executorch/runtime/core/error.h> // @manual
1415
#include <executorch/runtime/core/result.h> // @manual
@@ -46,7 +47,6 @@
4647
#include <executorch/runtime/core/portable_type/qint_types.h> // @manual
4748
#include <executorch/runtime/core/portable_type/scalar.h> // @manual
4849
#include <executorch/runtime/core/portable_type/scalar_type.h> // @manual
49-
#include <executorch/runtime/core/portable_type/string_view.h> // @manual
5050
#include <executorch/runtime/core/portable_type/tensor.h> // @manual
5151
#include <executorch/runtime/core/portable_type/tensor_options.h> // @manual
5252

runtime/core/exec_aten/util/scalar_type_util.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ using ScalarType = at::ScalarType;
4747
} // namespace executorch
4848
#else // !USE_ATEN_LIB
4949
#include <executorch/runtime/core/portable_type/scalar_type.h>
50-
#include <executorch/runtime/core/portable_type/string_view.h>
50+
#include <string_view>
5151
namespace executorch {
5252
namespace aten {
5353
using ScalarType = torch::executor::ScalarType;

runtime/core/named_data_map.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ class NamedDataMap {
3131
* @return Result containing TensorLayout.
3232
*/
3333
ET_NODISCARD virtual Result<const TensorLayout> get_tensor_layout(
34-
executorch::aten::string_view key) const = 0;
34+
std::string_view key) const = 0;
3535
/**
3636
* Get data by key.
3737
*
3838
* @param key Name of the data.
3939
* @return Result containing a FreeableBuffer.
4040
*/
4141
ET_NODISCARD virtual Result<FreeableBuffer> get_data(
42-
executorch::aten::string_view key) const = 0;
42+
std::string_view key) const = 0;
4343

4444
/**
4545
* Loads data corresponding to the key into the provided buffer.
@@ -51,10 +51,8 @@ class NamedDataMap {
5151
* `size` bytes of memory.
5252
* @returns an Error indicating if the load was successful.
5353
*/
54-
ET_NODISCARD virtual Error load_data_into(
55-
executorch::aten::string_view key,
56-
void* buffer,
57-
size_t size) const = 0;
54+
ET_NODISCARD virtual Error
55+
load_data_into(std::string_view key, void* buffer, size_t size) const = 0;
5856

5957
/**
6058
* Get the number of keys in the NamedDataMap.

runtime/core/portable_type/string_view.h

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)