def translate_ethosu_copy(tir_call_extern: tvm.tir.Call) -> vapi.NpuDmaOperation:
    """This function will translate a TIR call_extern
    as produced by NPU Relay to TIR compilation.

    Parameters
    ----------
    tir_call_extern : tvm.tir.Call

    Returns
    -------
    ethosu.vela.api.NpuDmaOperation
        The vela object containing the params of ethosu_copy
    """
    # We skip the first element as it is the call_extern function name
    serial_object = spec.create_serial_object(spec.SerialCopy, tir_call_extern.args[1:])
    return _create_npu_dma_op(serial_object)
def translate_ethosu_pooling(tir_call_extern: tvm.tir.Call) -> vapi.NpuPoolingOperation:
    """This function will translate a TIR call_extern
    as produced by NPU Relay to TIR compilation.

    Parameters
    ----------
    tir_call_extern : tvm.tir.Call
        This should be a TIR call_extern that has agreed upon ordering
        for TIR Compiler. See SerialPooling in
        tvm/relay/backend/contrib/ethosu/tir/spec.py for the ordering.

    Returns
    -------
    ethosu.vela.api.NpuPoolingOperation
        The vela object containing the params of ethosu_pooling
    """
    serial_object = spec.create_serial_object(spec.SerialPooling, tir_call_extern.args[1:])
    return _create_npu_op_pooling(serial_object)
Esempio n. 3
0
def translate_ethosu_unary_elementwise(
    tir_extern_call: tvm.tir.Call, ) -> vapi.NpuElementWiseOperation:
    """This function will translate a tir extern_call
    as produced by Relay to TIR compilation.
    Parameters
    ----------
    tir_extern_call : tvm.tir.Call
        This should be a tir external call that has a agreed upon ordering
        for the NPU TIR Compiler. See SerialUnaryElementwise in
        tvm/relay/backend/contrib/ethosu/tir/spec.py for the ordering.

    Returns
    -------
    ethosu.vela.api.NpuElementWiseOperation
        The vela object containing the params of ethosu_unary_elementwise
    """
    serial_object = spec.create_serial_object(spec.SerialUnaryElementwise,
                                              tir_extern_call.args[1:])
    return _create_npu_op_unary_elementwise(serial_object)
Esempio n. 4
0
def translate_ethosu_conv2d(tir_extern_call):
    """This function will translate a tir extern_call
    as produced by Relay to TIR compilation.
    Parameters
    ----------
    tir_extern_call : tvm.tir.Call
        This should be an tir external call that has a agreed upon ordering
        for TIR Compiler. See Serial2DConvolution in
        tvm/relay/backend/contrib/ethosu/tir/spec.py for the ordering.

    Returns
    -------
    ethosu.vela.api.NpuConv2DOperation
        The vela object containing the params of ethosu_conv2d
    weights_zero_point : int
        The zero point of the weights
    """
    # We skip the first element as it is the extern_call function name
    serial_object = spec.create_serial_object(spec.Serial2DConvolution, tir_extern_call.args[1:])
    return _create_npu_op_conv2d(serial_object)
Esempio n. 5
0
def translate_ethosu_depthwise_conv2d(tir_extern_call):
    """This function will translate a tir extern_call
    as produced by Relay to TIR compilation.

    Parameters
    ----------
    tir_extern_call : tvm.tir.Call
        This should be a tir external call that has an agreed upon ordering
        for NPU TIR Compiler. See Serial2DDepthwise in
        tvm/relay/backend/contrib/ethosu/tir/spec.py for the ordering.

    Returns
    -------
    ethosu.vela.api.NpuDepthWiseOperation
        The vela object containing the params of ethosu_depthwise_conv2d
    weights_zero_point : int
        The zero point of the weights
    """
    serial_object = spec.create_serial_object(spec.Serial2DDepthwise,
                                              tir_extern_call.args[1:])
    return _create_npu_op_depthwise_conv2d(serial_object)