cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
datapro
Visitor
Visitor
284 Views
Registered: ‎03-31-2021

create runner

When I run following code 
I don't know why there was a program error.
So how to use create_runner?
My board is U200 and I'm using Vitis AI docker pytorch image
Thanks
 
 

 

###my code###
from ctypes import *
from typing import List
import cv2
import numpy as np
import xir
import vart
import os
import math
import threading
import time
import sys

def get_child_subgraph_dpu(graph: "Graph"):
    assert graph is not None, \
        "Input Graph object should not be None."
    root_subgraph = graph.get_root_subgraph()
    assert root_subgraph is not None, \
        "Failed to get root subgraph of input Graph object."
    if root_subgraph.is_leaf:
        return []
    child_subgraphs = root_subgraph.toposort_child_subgraph()
    assert child_subgraphs is not None and len(child_subgraphs) > 0
    return [cs
            for cs in child_subgraphs
            if cs.has_attr("device") and cs.get_attr("device").upper() == "DPU"]def main():
    # 이미지 경로 설정
    img_path = "./dataset/val/baboon.bmp"    # 스레드 수 설정
    threadnum = 1    i = 0
    g = xir.Graph.deserialize("test.xmodel")
    subgraphs = get_child_subgraph_dpu(g)
    # print(dir(vart.Runner.create_runner))
    # run = Runner("./")
    print(type(subgraphs[0]))
    r = vart.Runner.create_runner(subgraph=subgraphs[0], mode=str("run"))if __name__ == '__main__':
    main()

 

 

error

 

 

(vitis-ai-pytorch) Vitis-AI /workspace/hansol/FSRCNN > python3 abc.py
<class 'xir.Subgraph'>
Traceback (most recent call last):
  File "abc.py", line 102, in <module>
    main()
  File "abc.py", line 84, in main
    r = vart.Runner.create_runner(subgraph=subgraphs[0], mode=str("run"))
TypeError: create_runner(): incompatible function arguments. The following argument types are supported:
    1. (subgraph: xir::Subgraph, mode: str = '') -> vart.RunnerInvoked with: kwargs: subgraph=<xir.Subgraph named 'subgraph_ResNet__ResNet_AdaptiveAvgPool2d_avgpool__483_i0'>, mode='run'

 

0 Kudos
3 Replies
zhipengl
Xilinx Employee
Xilinx Employee
251 Views
Registered: ‎03-21-2021

Hi,
Thank you for your feedback.
Could you please share the “test.xmodel” so that we can further analyze the problem.

datapro
Visitor
Visitor
243 Views
Registered: ‎03-31-2021

thanks this is my test model

0 Kudos
datapro
Visitor
Visitor
144 Views
Registered: ‎03-31-2021

Could you share with me if there's any progress? I reply again because there has been no feedback since I attached the model.

0 Kudos