Skip to content

Commit 869b9a3

Browse files
committedFeb 18, 2024·
fmt
1 parent ac08078 commit 869b9a3

File tree

4 files changed

+7
-15
lines changed

4 files changed

+7
-15
lines changed
 

‎cpp/build.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ function prepare_test_files() {
207207
cd ${BASE_DIR}/../examples/cpp/aot_inductor/bert/
208208
python aot_compile_export.py
209209
mv bert-seq.so ${HANDLER_DIR}/bert-seq.so
210-
mv Transformer_model/tokenizer_config.json ${HANDLER_DIR}/tokenizer_config.json
210+
mv Transformer_model/tokenizer.json ${HANDLER_DIR}/tokenizer.json
211211
export TOKENIZERS_PARALLELISM=""
212212
fi
213213
fi

‎examples/cpp/aot_inductor/bert/README.md

+2-8
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ handler:
3434
### Generate Model Artifact Folder
3535
3636
```bash
37-
torch-model-archiver --model-name bertcppaot --version 1.0 --handler ../../../../cpp/_build/test/resources/examples/aot_inductor/bert/libbert_handler:BertCppHandler --runtime LSP --extra-files index_to_name.json,../../../../cpp/_build/test/resources/examples/aot_inductor/bert_handler/bert-seq.so,../../../../cpp/_build/test/resources/examples/aot_inductor/bert_handler/tokenizer.json --config-file model-config.yaml --archive-format no-archive
37+
torch-model-archiver --model-name bertcppaot --version 1.0 --handler ../../../../cpp/_build/test/resources/examples/aot_inductor/bert_handler/libbert_handler:BertCppHandler --runtime LSP --extra-files index_to_name.json,../../../../cpp/_build/test/resources/examples/aot_inductor/bert_handler/bert-seq.so,../../../../cpp/_build/test/resources/examples/aot_inductor/bert_handler/tokenizer.json --config-file model-config.yaml --archive-format no-archive
3838
```
3939

4040
Create model store directory and move the folder `bertcppaot`
@@ -56,11 +56,5 @@ Infer the model using the following command
5656

5757
```
5858
curl http://localhost:8080/predictions/bertcppaot -T ../../../../cpp/test/resources/examples/aot_inductor/bert_handler/sample_text.txt
59-
{
60-
"lens_cap": 0.0022578993812203407,
61-
"lynx": 0.0032067005522549152,
62-
"Egyptian_cat": 0.046274684369564056,
63-
"tiger_cat": 0.13740436732769012,
64-
"tabby": 0.2724998891353607
65-
}
59+
Not Accepted
6660
```

‎examples/cpp/aot_inductor/bert/aot_compile_export.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
)
1212

1313
set_seed(1)
14+
MAX_BATCH_SIZE = 15
1415

1516

1617
def transformers_model_dowloader(
@@ -100,15 +101,14 @@ def transformers_model_dowloader(
100101
else:
101102
filename = os.path.join(dirname, "model-config.yaml")
102103
with open(filename, "r") as f:
103-
settings = yaml.load(f)
104+
settings = yaml.safe_load(f)
104105

105106
mode = settings["handler"]["mode"]
106107
model_name = settings["handler"]["model_name"]
107108
num_labels = int(settings["handler"]["num_labels"])
108-
do_lower_case = settings["handler"]["do_lower_case"]
109+
do_lower_case = bool(settings["handler"]["do_lower_case"])
109110
max_length = int(settings["handler"]["max_length"])
110-
batch_size = int(settings.get("batch_size", "1"))
111-
111+
batch_size = int(settings["batchSize"])
112112
transformers_model_dowloader(
113113
mode,
114114
model_name,

‎examples/cpp/aot_inductor/bert/src/bert_handler.cc

-2
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,6 @@ c10::IValue BertCppHandler::Inference(
177177
}
178178

179179
auto batch_output_tensor_vector = runner->run(inputs.toTensorVector());
180-
auto batch_output_tensor_vector = runner->run(vec);
181-
182180
return c10::IValue(batch_output_tensor_vector[0]);
183181
} catch (std::runtime_error& e) {
184182
TS_LOG(ERROR, e.what());

0 commit comments

Comments
 (0)
Please sign in to comment.