from ast import Or
from collections import OrderedDict


SIMULATOR_MODULE_CONVERT_FUNCTION = OrderedDict() 


def register_simulator_convert_function(module_type):
    def insert(func):
        SIMULATOR_MODULE_CONVERT_FUNCTION[module_type] = func
        return func
    return insert

BACKEND_SIMULATOR_FUNCTION = OrderedDict()

def register_simulator_function(backend_type):
    def insert(func):
        if backend_type in BACKEND_SIMULATOR_FUNCTION:
            BACKEND_SIMULATOR_FUNCTION[backend_type].append(func)
        else:
            BACKEND_SIMULATOR_FUNCTION[backend_type] = [func]
        return func
    return insert

MNN_MODULE_CONVERT_CLASSES = OrderedDict() 

def register_mnn_convert_classes(module_type):
    def insert(cls):
        MNN_MODULE_CONVERT_CLASSES[module_type] = cls
        return cls
    return insert

BACKEND_DEPLOY_MNN_FUNCTION = OrderedDict()

def register_deploy_mnn_function(backend_type):
    def insert(func):
        if backend_type in BACKEND_DEPLOY_MNN_FUNCTION:
            BACKEND_DEPLOY_MNN_FUNCTION[backend_type].append(func)
        else:
            BACKEND_DEPLOY_MNN_FUNCTION[backend_type] = [func]
        return func
    return insert

BACKEND_DEPLOY_ONNX_FUNCTION = OrderedDict()

def register_deploy_onnx_function(backend_type):
    def insert(func):
        if backend_type in BACKEND_DEPLOY_ONNX_FUNCTION:
            BACKEND_DEPLOY_ONNX_FUNCTION[backend_type].append(func)
        else:
            BACKEND_DEPLOY_ONNX_FUNCTION[backend_type] = [func]
        return func
    return insert