Skip to content

Commit 807bc08

Browse files
dbortpytorchbot
authored andcommitted
s/exec_aten::/executorch::aten::/ for extension/**/*.h (#6032)
Summary: Pull Request resolved: #6032 Migrate all extension headers to use the new aten namespace, so that they act as good examples for users. The .cpp code can migrate later. Reviewed By: lucylq Differential Revision: D64079593 fbshipit-source-id: 62164cd6ec3238e21e896813f185d0c1446ef527 (cherry picked from commit 69c2c76)
1 parent 40358fa commit 807bc08

File tree

9 files changed

+279
-293
lines changed

9 files changed

+279
-293
lines changed

extension/android/jni/jni_layer_constants.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ constexpr static int kTensorDTypeBits4x2 = 20;
3737
constexpr static int kTensorDTypeBits8 = 21;
3838
constexpr static int kTensorDTypeBits16 = 22;
3939

40-
using exec_aten::ScalarType;
40+
using executorch::aten::ScalarType;
4141

4242
const std::unordered_map<ScalarType, int> scalar_type_to_java_dtype = {
4343
{ScalarType::Byte, kTensorDTypeUInt8},

extension/kernel_util/make_boxed_from_unboxed_functor.h

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,12 @@ struct decay_if_not_tensor final {
6666
using type = std::decay_t<T>;
6767
};
6868
template <>
69-
struct decay_if_not_tensor<exec_aten::Tensor&> final {
70-
using type = exec_aten::Tensor&;
69+
struct decay_if_not_tensor<executorch::aten::Tensor&> final {
70+
using type = executorch::aten::Tensor&;
7171
};
7272
template <>
73-
struct decay_if_not_tensor<const exec_aten::Tensor&> final {
74-
using type = const exec_aten::Tensor&;
73+
struct decay_if_not_tensor<const executorch::aten::Tensor&> final {
74+
using type = const executorch::aten::Tensor&;
7575
};
7676

7777
template <class T>
@@ -82,29 +82,30 @@ struct evalue_to_arg final {
8282
};
8383

8484
template <>
85-
struct evalue_to_arg<exec_aten::Tensor&> final {
86-
static exec_aten::Tensor& call(executorch::runtime::EValue& v) {
85+
struct evalue_to_arg<executorch::aten::Tensor&> final {
86+
static executorch::aten::Tensor& call(executorch::runtime::EValue& v) {
8787
return v.toTensor();
8888
}
8989
};
9090

9191
template <>
92-
struct evalue_to_arg<const exec_aten::Tensor&> final {
93-
static const exec_aten::Tensor& call(executorch::runtime::EValue& v) {
92+
struct evalue_to_arg<const executorch::aten::Tensor&> final {
93+
static const executorch::aten::Tensor& call(executorch::runtime::EValue& v) {
9494
return v.toTensor();
9595
}
9696
};
9797

9898
template <class T>
99-
struct evalue_to_arg<exec_aten::optional<T>> final {
100-
static exec_aten::optional<T> call(executorch::runtime::EValue& v) {
99+
struct evalue_to_arg<executorch::aten::optional<T>> final {
100+
static executorch::aten::optional<T> call(executorch::runtime::EValue& v) {
101101
return v.toOptional<T>();
102102
}
103103
};
104104

105105
template <class T>
106-
struct evalue_to_arg<exec_aten::ArrayRef<exec_aten::optional<T>>> final {
107-
static exec_aten::ArrayRef<exec_aten::optional<T>> call(
106+
struct evalue_to_arg<executorch::aten::ArrayRef<executorch::aten::optional<T>>>
107+
final {
108+
static executorch::aten::ArrayRef<executorch::aten::optional<T>> call(
108109
executorch::runtime::EValue& v) {
109110
return v.toListOptionalTensor();
110111
}

extension/llm/runner/image_prefiller.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class ImagePrefiller {
3030
* It's passed as reference and will be updated inside this function.
3131
* @return The next token of the LLM Module after prefill.
3232
*/
33-
virtual ::executorch::runtime::Result<exec_aten::Tensor> prefill(
33+
virtual ::executorch::runtime::Result<executorch::aten::Tensor> prefill(
3434
Image& image,
3535
int64_t& start_pos) = 0;
3636

extension/llm/runner/text_decoder_runner.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class TextDecoderRunner {
3737
* Module.
3838
* @return The output of the LLM Module. This will be a tensor of logits.
3939
*/
40-
virtual ::executorch::runtime::Result<exec_aten::Tensor> step(
40+
virtual ::executorch::runtime::Result<executorch::aten::Tensor> step(
4141
TensorPtr& input,
4242
TensorPtr& start_pos);
4343

@@ -66,7 +66,8 @@ class TextDecoderRunner {
6666
* @param logits_tensor The logits tensor.
6767
* @return The next token.
6868
*/
69-
inline int32_t logits_to_token(const exec_aten::Tensor& logits_tensor) {
69+
inline int32_t logits_to_token(
70+
const executorch::aten::Tensor& logits_tensor) {
7071
int32_t result = 0;
7172
ET_SWITCH_THREE_TYPES(
7273
Float,

extension/llm/runner/text_token_generator.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class TextTokenGenerator {
5353
int64_t pos = start_pos; // position in the sequence
5454

5555
std::vector<uint64_t> token_data; // allocate space for the tokens
56-
std::vector<exec_aten::SizesType> token_shape;
56+
std::vector<executorch::aten::SizesType> token_shape;
5757

5858
// Token after prefill
5959
uint64_t cur_token = tokens.back();
@@ -70,8 +70,10 @@ class TextTokenGenerator {
7070
}
7171

7272
// initialize tensor wrappers
73-
auto tokens_managed =
74-
from_blob(token_data.data(), token_shape, exec_aten::ScalarType::Long);
73+
auto tokens_managed = from_blob(
74+
token_data.data(), token_shape, executorch::aten::ScalarType::Long);
75+
auto start_pos_managed =
76+
from_blob(&pos, {1}, executorch::aten::ScalarType::Long);
7577

7678
auto start_pos_managed = from_blob(&pos, {1}, exec_aten::ScalarType::Long);
7779

@@ -82,7 +84,7 @@ class TextTokenGenerator {
8284
text_decoder_runner_->step(tokens_managed, start_pos_managed);
8385

8486
ET_CHECK_OK_OR_RETURN_ERROR(logits_res.error());
85-
exec_aten::Tensor& logits_tensor = logits_res.get();
87+
executorch::aten::Tensor& logits_tensor = logits_res.get();
8688

8789
prev_token = cur_token;
8890

0 commit comments

Comments
 (0)