Factory fucntion to create an instance of runner by graph and attributes.
Usage:
auto graph = xir::Graph::deserialize(xmodel_file);
auto attrs = xir::Attrs::create();
auto runner = vitis::ai::GraphRunner::create_graph_runner(graph.get(), attrs.get());
auto input_tensor_buffers = runner->get_inputs();
Graph runner Example
Sample code:
// The way to create graph runner and the APIs usage of runner are shown below.
auto graph = xir::Graph::deserialize(xmodel_file);
auto attrs = xir::Attrs::create();
auto runner = vitis::ai::GraphRunner::create_graph_runner(graph.get(), attrs.get());
// get input and output tensor buffers
auto input_tensor_buffers = runner->get_inputs();
auto output_tensor_buffers = runner->get_outputs();
// sync input tensor buffers
for (auto& input : input_tensor_buffers) { input->sync_for_write(0, input->get_tensor()->get_data_size() / input->get_tensor()->get_shape()[0]);
}
// run graph runner
auto v = runner->execute_async(input_tensor_buffers, output_tensor_buffers);
auto status = runner->wait((int)v.first, 1000000000);
// sync output tensor buffers
for (auto& output : output_tensor_buffers) { output->sync_for_read(0, output->get_tensor()->get_data_size() / output->get_tensor()->get_shape()[0]);
}
Prototype
std::unique_ptr< vart::RunnerExt > create_graph_runner(const xir::Graph *graph, xir::Attrs *attrs);
Parameters
The following table lists the create_graph_runner
function arguments.
Type | Member | Description |
---|---|---|
const xir::Graph * | graph | XIR Graph |
xir::Attrs * | attrs | XIR attrs object, this object is shared among all runners on the same graph. |