(self, blocks)
return ret
blocks: [{}, {}, ...]
blocks: [{}, {}, ...]
blocks : [ {} {} ... ]
def add_blocks(self, blocks):
        """ blocks: [{}, {}, ...]
        """
        assert isinstance(blocks, list) and all(
            isinstance(x, dict) for x in blocks
        ), blocks

        modules = OrderedDict()
        for block in blocks:
            stage_idx = block["stage_idx"]
            block_idx = block["block_idx"]
            block_op_type = block["block_op_type"]
            tcns = block["block"]
            n = tcns[2]
            assert n == 1
            nnblock = self.add_ir_block(tcns, [block_op_type])
            nn_name = "xif{}_{}".format(stage_idx, block_idx)
            assert nn_name not in modules
            modules[nn_name] = nnblock
        ret = nn.Sequential(modules)
        return ret
def add_blocks ( self , blocks ) : assert isinstance ( blocks , list ) and all ( isinstance ( x , dict ) for x in blocks ) , blocks modules = OrderedDict ( ) for block in blocks : stage_idx = block [ "stage_idx" ] block_idx = block [ "block_idx" ] block_op_type = block [ "block_op_type" ] tcns = block [ "block" ] n = tcns [ 2 ] assert n == 1 nnblock = self . add_ir_block ( tcns , [ block_op_type ] ) nn_name = "xif{}_{}" . format ( stage_idx , block_idx ) assert nn_name not in modules modules [ nn_name ] = nnblock ret = nn . Sequential ( modules ) return ret