Skip to content

Commit 7d9897a

Browse files
fix: use & instead of *
1 parent 1413826 commit 7d9897a

5 files changed

Lines changed: 8 additions & 14 deletions

File tree

packages/react-native-executorch/common/runner/multimodal_decoder_runner.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
namespace executorch::extension::llm {
1717
class MultimodalDecoderRunner : public TextDecoderRunner {
1818
public:
19-
explicit MultimodalDecoderRunner(Module *module, IOManager *io_manager)
19+
explicit MultimodalDecoderRunner(Module &module, IOManager *io_manager)
2020
: TextDecoderRunner(module, io_manager) {}
2121

2222
inline ::executorch::runtime::Result<::executorch::aten::Tensor>

packages/react-native-executorch/common/runner/multimodal_runner.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ Error MultimodalRunner::load_subcomponents() {
4444

4545
Stats *stats_ptr = &stats_;
4646

47-
mm_decoder_runner_ = std::make_unique<MultimodalDecoderRunner>(
48-
module_.get(), io_manager_.get());
47+
mm_decoder_runner_ =
48+
std::make_unique<MultimodalDecoderRunner>(*module_, io_manager_.get());
4949
IEncoder *image_encoder = nullptr;
5050
auto enc_it = encoders_.find(MultimodalType::Image);
5151
if (enc_it != encoders_.end()) {

packages/react-native-executorch/common/runner/text_decoder_runner.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ namespace llm {
2121
// NOTE: we observed ~2x loading performance increase on iPhone 15
2222
// and a ~5% improvement on Galaxy S22 by switching to
2323
// FileDataLoader instead of MmapDataLoader + UseMlockIgnoreErrors.
24-
TextDecoderRunner::TextDecoderRunner(Module *module, IOManager *io_manager,
24+
TextDecoderRunner::TextDecoderRunner(Module &module, IOManager *io_manager,
2525
float temperature, float topp)
26-
: module_(module), io_manager_(io_manager), temperature_(temperature),
26+
: module_(&module), io_manager_(io_manager), temperature_(temperature),
2727
topp_(topp) {}
2828

2929
// This function is functional, meaning it shouldn't modify any state of the

packages/react-native-executorch/common/runner/text_decoder_runner.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ namespace llm {
1919

2020
class TextDecoderRunner {
2121
public:
22-
explicit TextDecoderRunner(Module *module, IOManager *io_manager,
22+
explicit TextDecoderRunner(Module &module, IOManager *io_manager,
2323
float temperature = 0.8F, float topp = 0.9F);
2424

2525
virtual ~TextDecoderRunner() = default;
@@ -99,13 +99,7 @@ class TextDecoderRunner {
9999
}
100100

101101
protected:
102-
/**
103-
* Note: TextDecoderRunner does not own the Module or IOManager instance. It
104-
* is expected that the outer class (likely Runner) manages the lifecycle of
105-
* them. This means that the responsibility for creating, maintaining, and
106-
* destroying the Module lies outside of TextDecoderRunner. Ensure that the
107-
* Module remains valid for the duration of TextDecoderRunner's usage.
108-
*/
102+
// Non-owning. The runner (BaseLLMRunner) owns the Module and outlives this.
109103
Module *module_;
110104
IOManager *io_manager_;
111105
bool should_stop_{false};

packages/react-native-executorch/common/runner/text_runner.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Error TextRunner::load_subcomponents() {
2828
Stats *stats_ptr = &stats_;
2929

3030
text_decoder_runner_ = std::make_unique<TextDecoderRunner>(
31-
module_.get(), io_manager_.get(), config_.temperature, config_.topp);
31+
*module_, io_manager_.get(), config_.temperature, config_.topp);
3232
text_prefiller_ = std::make_unique<TextPrefiller>(
3333
text_decoder_runner_.get(), config_.enable_kv_cache,
3434
config_.enable_dynamic_shape, config_.max_seq_len);

0 commit comments

Comments
 (0)