def _check_fetch_vars_persistable(self, program, fetch_list):
    for var in fetch_list:
        if isinstance(var, Variable):
            persistable = var.persistable
        else:
            block_num = program.desc.num_blocks()
            persistable = None
            var_name = cpt.to_bytes(var)
            for i in six.moves.range(block_num):
                var_desc = program.desc.block(i).find_var(var_name)
                if var_desc:
                    persistable = var_desc.persistable()
                    break
            assert (persistable is not None), 'Variable {} is not found'.format(var)
        if (not persistable):
            logging.warn('\n     Detect that build_strategy.memory_optimize = True, but the some variables in the fetch\n     list is not persistable, you may get wrong fetched value, or an exeception may be thrown\n     about cannot find variable of the fetch list. \n\n     TO FIX this:\n         # Sample\n         conv1 = fluid.layers.conv2d(data, 4, 5, 1, act=None) \n         # if you need to fetch conv1, then:\n         conv1.persistable = True\n\n                 ')
def _check_fetch_vars_persistable(self, program, fetch_list):
    for var in fetch_list:
        if isinstance(var, Variable):
            persistable = var.persistable
        else:
            block_num = program.desc.num_blocks()
            persistable = None
            var_name = cpt.to_bytes(var)
            for i in six.moves.range(block_num):
                var_desc = program.desc.block(i).find_var(var_name)
                if var_desc:
                    persistable = var_desc.persistable()
                    break
            assert (persistable is not None), 'Variable {} is not found'.format(var)
        if (not persistable):
            logging.warn('\n     Detect that build_strategy.memory_optimize = True, but the some variables in the fetch\n     list is not persistable, you may get wrong fetched value, or an exeception may be thrown\n     about cannot find variable of the fetch list. \n\n     TO FIX this:\n         # Sample\n         conv1 = fluid.layers.conv2d(data, 4, 5, 1, act=None) \n         # if you need to fetch conv1, then:\n         conv1.persistable = True\n\n                 ')