def load_deprecated_signatures(declarations_by_signature):
with open(deprecated_path, 'r') as f:
deprecated_defs = yaml.load(f, Loader=Loader)
declarations = []
def get_signature(name, params, call_args):
# create a mapping of parameter name to parameter type
types = dict([param.split(' ')[::-1] for param in params])
# if the name in the call is not in the parameter list, assume it's
# a literal Scalar
rearranged_types = [types.get(arg, 'Scalar') for arg in call_args]
return '{}({})'.format(name, ', '.join(rearranged_types))
for deprecated in deprecated_defs:
prototype = deprecated['name']
call_args = split_name_params(deprecated['aten'])[1]
name, params = split_name_params(prototype)
signature = get_signature(name, params, call_args)
for declaration in declarations_by_signature[signature]:
declaration = copy.deepcopy(declaration)
declaration['deprecated'] = True
declaration['call_args'] = call_args
if declaration['inplace']:
declaration['prototype'] = prototype.replace(name, name + '_')
else:
declaration['prototype'] = prototype
args_by_name = {arg['name']: arg for arg in declaration['arguments']}
declaration['arguments'] = []
for arg in params:
_, arg_name = arg.split(' ')
declaration['arguments'].append(args_by_name[arg_name])
declarations.append(declaration)
return declarations
评论列表
文章目录