Example #1
0
def run_node(onnx_node, data_inputs, **kwargs):
    # type: (onnx.NodeProto, List[np.ndarray], Dict[Text, Any]) -> List[np.ndarray]
    """
    Convert ONNX node to ngraph node and perform computation on input data.

    :param onnx_node: ONNX NodeProto describing a computation node
    :param data_inputs: list of numpy ndarrays with input data
    :return: list of numpy ndarrays with computed output
    """
    NgraphBackend.backend_name = pytest.config.getoption('backend', default='CPU')
    if NgraphBackend.supports_ngraph_device(NgraphBackend.backend_name):
        return NgraphBackend.run_node(onnx_node, data_inputs, **kwargs)
    else:
        raise RuntimeError('The requested nGraph backend <' + NgraphBackend.backend_name +
                           '> is not supported!')
Example #2
0
def run_model(onnx_model, data_inputs):
    # type: (onnx.ModelProto, List[np.ndarray]) -> List[np.ndarray]
    """
    Convert ONNX model to an ngraph model and perform computation on input data.

    :param onnx_model: ONNX ModelProto describing an ONNX model
    :param data_inputs: list of numpy ndarrays with input data
    :return: list of numpy ndarrays with computed output
    """
    NgraphBackend.backend_name = BACKEND_NAME
    if NgraphBackend.supports_ngraph_device(NgraphBackend.backend_name):
        ng_model_function = import_onnx_model(onnx_model)
        runtime = get_runtime()
        computation = runtime.computation(ng_model_function)
        return computation(*data_inputs)
    else:
        raise RuntimeError('The requested nGraph backend <'
                           + NgraphBackend.backend_name + '> is not supported!')
Example #3
0
def run_model(onnx_model, data_inputs):
    # type: (onnx.ModelProto, List[np.ndarray]) -> List[np.ndarray]
    """
    Convert ONNX model to an ngraph model and perform computation on input data.

    :param onnx_model: ONNX ModelProto describing an ONNX model
    :param data_inputs: list of numpy ndarrays with input data
    :return: list of numpy ndarrays with computed output
    """
    NgraphBackend.backend_name = pytest.config.getoption('backend', default='CPU')
    if NgraphBackend.supports_ngraph_device(NgraphBackend.backend_name):
        ng_model = import_onnx_model(onnx_model)
        runtime = get_runtime()
        computations = [runtime.computation(model['output'], *model['inputs']) for
                        model in ng_model]
        return [computation(*data_inputs) for computation in computations]
    else:
        raise RuntimeError('The requested nGraph backend <' + NgraphBackend.backend_name +
                           '> is not supported!')
def test_supports_ngraph_device_gpu():
    assert NgraphBackend.supports_ngraph_device('GPU')
def test_supports_ngraph_device_nnp():
    assert NgraphBackend.supports_ngraph_device('NNP')
def test_supports_ngraph_device_interpreter():
    assert NgraphBackend.supports_ngraph_device('INTERPRETER')
def test_supports_ngraph_device_nnp(backend_name):
    assert NgraphBackend.supports_ngraph_device(backend_name)