NNgen / nngen

NNgen: A Fully-Customizable Hardware Synthesis Compiler for Deep Neural Network

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

function [nngen/basic_type.py:__Operator collect_numerics] is too busy

RyusukeYamano opened this issue · comments

The function does not terminate in deep (& complex) networks because it re-explores the already explored ”args” when exploring the computational graph.

nngen/nngen/basic_types.py

Lines 476 to 484 in 2a30d83

def collect_numerics(self):
ret = []
ret.append(self)
for arg in self.args:
ret.extend(arg.collect_numerics())
ret = sorted(set(ret), key=ret.index)
return ret

This seems to work well.

    def collect_numerics(self, ret=set()):
        ret.add(self)
        for arg in self.args:
            if arg not in ret:
                ret = ret.union(arg.collect_numerics(), ret)

        return ret

Is this fine?

    def collect_numerics(self, ret=set()):
        ret.add(self)
        for arg in self.args:
            if arg not in ret:
                ret = arg.collect_numerics(ret)
        return ret

Fixed in 6d26c8c