Skip to content

Commit

Permalink
replace PadSequence with Append, use updated model path
Browse files Browse the repository at this point in the history
  • Loading branch information
edgchen1 committed Sep 25, 2024
1 parent eddbb41 commit 94f5ec9
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions app/src/main/cpp/native-lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ std::string RunPhi3(const char* model_path) {
tokenizer->Encode(prompt.c_str(), *sequences);
const size_t num_tokens = sequences->SequenceCount(0);
LogF("num_tokens: %zu", num_tokens);
sequences->PadSequence(space_token, seq_len, 0);
for (size_t i = num_tokens; i < seq_len; ++i) {
sequences->Append(space_token, 0);
}

std::array<float, seq_len> attn_mask{};
for (size_t i = 0; i < std::min(seq_len, num_tokens); ++i) {
Expand Down Expand Up @@ -89,6 +91,6 @@ Java_com_example_phi3splittest_MainActivity_runPhi3(JNIEnv *env, jobject thiz) {
const auto adsp_library_path = std::getenv("ADSP_LIBRARY_PATH");
LogF("ADSP_LIBRARY_PATH = %s", (adsp_library_path != nullptr) ? adsp_library_path : "not set");

std::string result = RunPhi3("/data/local/tmp/phi3-split/phi3-split-qnn-updated");
std::string result = RunPhi3("/data/local/tmp/phi3-split/phi3.5-split-qnn");
return env->NewStringUTF(result.c_str());
}

0 comments on commit 94f5ec9

Please sign in to comment.