PCIe를 통해 첫 번째 모델 실행
| 필드 | 값 |
|---|---|
| 범주 | PCIe 코프로세싱 |
| 난이도 | 초급 |
| 예상 소 요 시간 | 15 minutes |
| 레이블 | PCIe, inference, tensor, image, detection |
동일한 YOLOv8s 아카이브와 640x480 거리 장면을 사용하여 세 개의 독립적인 프로그램을 실행합니다. 각 프로그램은 하나의 모드를 시연하고, 큐 0을 동기적으로 사용하며, 하나의 모델을 닫습니다. 이렇게 하면 각 예제를 복사하여 사용할 수 있을 만큼 짧게 유지할 수 있습니다.
둘러보기
모델에 사용할 수 있는 텐서 실행
호스트는 이미지를 모델에서 보고한 [640, 640, 3] 입력에 맞게 조정하고, BGR을 RGB로 변환하고, 픽셀을 [0, 1]로 조정합니다. Model.run()은 해당 FP32 텐서를 보내고 카드 측 이미지 전처리를 수행하지 않으며 6개의 원시 YOLO 출력 경로를 모두 출력합니다.
pcie_host/tutorials/024_run_your_first_model_over_pcie/run_tensor_mode.cpp
pcie::ConnectionOptions connection;
connection.card_id = card_id;
pcie::Model model(kModelPath, {}, connection);
const auto info = model.info();
if (info.inputs.size() != 1) {
throw std::runtime_error("YOLOv8s must expose one input tensor");
}
const pcie::Tensor input = make_yolo_tensor(image, info.inputs[0]);
model.build(kBuildTimeoutMs);
const auto outputs = model.run(input, kRunTimeoutMs);
if (outputs.empty()) {
throw std::runtime_error("tensor mode returned no outputs");
}
std::cout << "Tensor mode raw outputs:\n";
for (const auto& output : outputs) {
std::cout << " " << output.route.name << " " << dtype_name(output.dtype) << " "
<< shape_string(output.shape) << '\n';
}
model.close();