Skip to content

Commit 722bced

Browse files
larryliu0820facebook-github-bot
authored andcommitted
Mark extension/llm examples/llama2 and examples/llava C++ APIs experimental (#6125)
Summary: experimental As titled. Pull Request resolved: #6125 Reviewed By: lucylq Differential Revision: D64198599 Pulled By: larryliu0820 fbshipit-source-id: c2540fbebf255347467302a61112784e5b5e5b61
1 parent 4204e50 commit 722bced

File tree

17 files changed

+27
-19
lines changed

17 files changed

+27
-19
lines changed

examples/models/llama2/runner/runner.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
namespace example {
2828

29-
class Runner {
29+
class ET_EXPERIMENTAL Runner {
3030
public:
3131
explicit Runner(
3232
const std::string& model_path,

examples/models/llava/runner/llava_image_prefiller.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
namespace example {
1717

18-
class LlavaImagePrefiller
18+
class ET_EXPERIMENTAL LlavaImagePrefiller
1919
: public ::executorch::extension::llm::ImagePrefiller {
2020
public:
2121
LlavaImagePrefiller(::executorch::extension::Module* module)

examples/models/llava/runner/llava_runner.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121

2222
namespace example {
2323

24-
class LlavaRunner : public ::executorch::extension::llm::MultimodalRunner {
24+
class ET_EXPERIMENTAL LlavaRunner
25+
: public ::executorch::extension::llm::MultimodalRunner {
2526
public:
2627
explicit LlavaRunner(
2728
const std::string& model_path,

examples/models/llava/runner/llava_text_decoder_runner.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
namespace example {
1616

17-
class LlavaTextDecoderRunner
17+
class ET_EXPERIMENTAL LlavaTextDecoderRunner
1818
: public executorch::extension::llm::TextDecoderRunner {
1919
public:
2020
LlavaTextDecoderRunner(

extension/llm/runner/image.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@
1111
#pragma once
1212
#include <cstdint>
1313
// patternlint-disable-next-line executorch-cpp-nostdinc
14+
#include <executorch/runtime/platform/compiler.h>
1415
#include <vector>
1516

1617
namespace executorch {
1718
namespace extension {
1819
namespace llm {
1920

20-
struct Image {
21+
struct ET_EXPERIMENTAL Image {
2122
// Assuming NCHW format
2223
std::vector<uint8_t> data;
2324
int32_t width;

extension/llm/runner/image_prefiller.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@
1212

1313
#include <executorch/extension/llm/runner/image.h>
1414
#include <executorch/extension/module/module.h>
15+
#include <executorch/runtime/platform/compiler.h>
1516

1617
namespace executorch {
1718
namespace extension {
1819
namespace llm {
1920

2021
// Assuming kv cache and parallel prefill are enabled.
21-
class ImagePrefiller {
22+
class ET_EXPERIMENTAL ImagePrefiller {
2223
public:
2324
explicit ImagePrefiller(::executorch::extension::Module* module)
2425
: module_(module) {}

extension/llm/runner/multimodal_runner.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ namespace executorch {
3636
namespace extension {
3737
namespace llm {
3838

39-
class MultimodalRunner {
39+
class ET_EXPERIMENTAL MultimodalRunner {
4040
public:
4141
explicit MultimodalRunner(
4242
const std::string& model_path,

extension/llm/runner/stats.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ namespace executorch {
1919
namespace extension {
2020
namespace llm {
2121

22-
struct Stats {
22+
struct ET_EXPERIMENTAL Stats {
2323
// Scaling factor for timestamps - in this case, we use ms.
2424
const long SCALING_FACTOR_UNITS_PER_SECOND = 1000;
2525
// Time stamps for the different stages of the execution

extension/llm/runner/text_decoder_runner.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@
1313
#include <executorch/extension/llm/sampler/sampler.h>
1414
#include <executorch/extension/module/module.h>
1515
#include <executorch/extension/tensor/tensor.h>
16+
#include <executorch/runtime/platform/compiler.h>
1617
// patternlint-disable-next-line executorch-cpp-nostdinc
1718
#include <functional>
1819

1920
namespace executorch {
2021
namespace extension {
2122
namespace llm {
2223

23-
class TextDecoderRunner {
24+
class ET_EXPERIMENTAL TextDecoderRunner {
2425
public:
2526
TextDecoderRunner(
2627
Module* module,

extension/llm/runner/text_prefiller.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ namespace executorch {
2020
namespace extension {
2121
namespace llm {
2222

23-
class TextPrefiller {
23+
class ET_EXPERIMENTAL TextPrefiller {
2424
public:
2525
TextPrefiller(
2626
TextDecoderRunner* text_decoder_runner,

extension/llm/runner/text_token_generator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace executorch {
1818
namespace extension {
1919
namespace llm {
2020

21-
class TextTokenGenerator {
21+
class ET_EXPERIMENTAL TextTokenGenerator {
2222
public:
2323
TextTokenGenerator(
2424
Tokenizer* tokenizer,

extension/llm/runner/util.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*/
88

99
#pragma once
10+
#include <executorch/runtime/platform/compiler.h>
1011
#include <stdio.h>
1112
#include <time.h>
1213
#include <cctype>
@@ -18,7 +19,7 @@ namespace executorch {
1819
namespace extension {
1920
namespace llm {
2021

21-
void inline safe_printf(const char* piece) {
22+
ET_EXPERIMENTAL void inline safe_printf(const char* piece) {
2223
// piece might be a raw byte token, and we only want to print printable chars
2324
// or whitespace because some of the other bytes can be various control codes,
2425
// backspace, etc.
@@ -40,7 +41,7 @@ void inline safe_printf(const char* piece) {
4041
// ----------------------------------------------------------------------------
4142
// utilities: time
4243

43-
long inline time_in_ms() {
44+
ET_EXPERIMENTAL long inline time_in_ms() {
4445
// return time in milliseconds, for benchmarking the model speed
4546
struct timespec time;
4647
clock_gettime(CLOCK_REALTIME, &time);
@@ -54,7 +55,7 @@ long inline time_in_ms() {
5455
// RSS: Resident Set Size, the amount of memory currently in the RAM for this
5556
// process. These values are approximate, and are only used for logging
5657
// purposes.
57-
size_t inline get_rss_bytes() {
58+
ET_EXPERIMENTAL size_t inline get_rss_bytes() {
5859
#if defined(__linux__) || defined(__ANDROID__) || defined(__unix__)
5960
struct rusage r_usage;
6061
if (getrusage(RUSAGE_SELF, &r_usage) == 0) {

extension/llm/sampler/sampler.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,20 @@
1919
#endif
2020

2121
#include <executorch/runtime/core/exec_aten/exec_aten.h>
22+
#include <executorch/runtime/platform/compiler.h>
2223

2324
namespace executorch {
2425
namespace extension {
2526
namespace llm {
2627
// A simple llama2 sampler.
2728

2829
template <typename T>
29-
struct ProbIndex {
30+
struct ET_EXPERIMENTAL ProbIndex {
3031
T prob;
3132
int32_t index;
3233
}; // struct used when sorting probabilities during top-p sampling
3334

34-
class Sampler {
35+
class ET_EXPERIMENTAL Sampler {
3536
public:
3637
Sampler(
3738
int32_t vocab_size,

extension/llm/sampler/targets.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@ def define_common_targets():
2323
] if aten else [],
2424
exported_deps = [
2525
"//executorch/runtime/core/exec_aten:lib" + aten_suffix,
26+
"//executorch/runtime/platform:compiler",
2627
],
2728
)

extension/llm/tokenizer/bpe_tokenizer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ struct TokenIndex {
2222

2323
// A simple Byte Pair Encoding (BPE) Tokenizer. Note that the current C++ code
2424
// won't work with this class, it needs to go through tokenizer.py first.
25-
class BPETokenizer : public Tokenizer {
25+
class ET_EXPERIMENTAL BPETokenizer : public Tokenizer {
2626
public:
2727
explicit BPETokenizer();
2828
~BPETokenizer() override;

extension/llm/tokenizer/tiktoken.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ using Encoder = std::unordered_map<std::string, uint64_t>;
2222
using Decoder = std::unordered_map<uint64_t, std::string>;
2323
using Re2UPtr = std::unique_ptr<re2::RE2>;
2424

25-
class Tiktoken : public Tokenizer {
25+
class ET_EXPERIMENTAL Tiktoken : public Tokenizer {
2626
public:
2727
/**
2828
* @param[in] special_tokens List of special tokens including bos, eos;

extension/llm/tokenizer/tokenizer.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@
1616

1717
#include <executorch/runtime/core/error.h>
1818
#include <executorch/runtime/core/result.h>
19+
#include <executorch/runtime/platform/compiler.h>
1920

2021
namespace executorch {
2122
namespace extension {
2223
namespace llm {
2324

2425
// A tokenizer interface.
25-
class Tokenizer {
26+
class ET_EXPERIMENTAL Tokenizer {
2627
public:
2728
explicit Tokenizer() {}
2829
virtual ~Tokenizer() {}

0 commit comments

Comments
 (0)