-
Notifications
You must be signed in to change notification settings - Fork 66
/
Copy pathmain.cpp
28 lines (27 loc) · 824 Bytes
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <glog/logging.h>
#include <iostream>
#include <memory>
#include "base/alloc.h"
#include "base/buffer.h"
#include "model/llama2.h"
#include "tensor/tensor.h"
#include "base/tick.h"
int main(int argc, char* argv[]) {
if (argc != 3) {
LOG(INFO) << "Usage: ./demo checkpoint_path tokenizer_path ";
return -1;
}
std::shared_ptr<base::CPUDeviceAllocator> alloc =
std::make_shared<base::CPUDeviceAllocator>();
const char* checkpoint_path = argv[1]; // e.g. out/model.bin
const char* tokenizer_path = argv[2];
model::LLama2Model model(tokenizer_path, checkpoint_path);
model.init(base::DeviceType::kDeviceCPU);
std::string sentence = "Hi everyone";
const auto& tokens = model.encode(sentence);
TICK(A)
const auto s = model.forward(tokens, 32);
TOCK(A)
LOG(INFO) << s;
return 0;
}