Code Monkey home page Code Monkey logo

Comments (1)

ZuoyunZheng avatar ZuoyunZheng commented on August 22, 2024

Ad-hoc fix was:

  1. reorder the function calls in prepare_graph():
        self.get_consts()
        # check inputs and outputs
        self.fetch_inputs_outputs()
        #self.reorder_nodes()
        self.update_nodes_by_name()
        self.add_cache_nodes()
        self.fetch_inputs_outputs()
        # add PadContext for 'input' if the model has left or right context
        # fuse statistics extraction and pooling, lstm cell
        self.fuse_nodes()
        self.add_cache_nodes()
        self.fetch_inputs_outputs()
        self.fetch_model_inputs_outputs()
        self.reorder_nodes(False)

  1. changes in reorder_nodes():
        ...
        while len(nodes_need_check) > 0:
            for node in list(nodes_need_check):
                ...
                if set(depend_inputs) <= set(checked_names) \
                        or (node.type == KaldiOpType.IfDefined.name
                                and ifdefine and 'IfDefined' in node.inputs[-1]):
            ...
  1. changes in add_cache_nodes():
        cache_nodes = list()
        for node in self._nodes:
            input = node.inputs[-1]
            if node.type == KaldiOpType.IfDefined.name and \
                    not input.endswith('.IfDefined'):
                _LOG.info(f"Appending cache nodes {node.inputs[-1]}")
                if input in self._nodes_by_name:
                    input_node = self._nodes_by_name[input]
                    cache_node_name = input_node.name + '.Cache'
                    cache_inputs = [input_node.name]
                    cache_node = make_node(cache_node_name,
                                           KaldiOpType.Identity.name,
                                           cache_inputs,
                                           [cache_node_name])
                    cache_nodes.append(cache_node)
                    node.inputs = node.inputs[:-1]
                    node.inputs.append(cache_node_name + '.IfDefined')
                else:
                    cache_node_name = input + '.Cache'
                    cache_inputs = [input]
                    cache_node = make_node(cache_node_name,
                                           KaldiOpType.Identity.name,
                                           cache_inputs,
                                           [cache_node_name])
                    node.inputs = node.inputs[:-1]
                    node.inputs.append(cache_node_name + '.IfDefined')
                    cache_nodes.append(cache_node)
        if len(cache_nodes) > 0:
            self._nodes.extend(cache_nodes)
            self.fetch_inputs_outputs()
            self.reorder_nodes()

from kaldi-onnx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.