ATen icon indicating copy to clipboard operation
ATen copied to clipboard

Consider removing _forward ATen methods when there are no buffers

Open ezyang opened this issue 6 years ago • 1 comments

I spent some time scratching my head on why there was both prelu and prelu_forward when they looked exactly identical. The answer is, based on reading nn_parse.py, that prelu doesn't have any buffers, so the "base" signature (which has no buffers) ends up being the same as the raw forward signature.

Let us consider adding a little bit of logic to delete the _forward declaration when it is the same as the base, so there aren't two ways to spell the same thing. The only thing I am not sure about is if there is any code that is taking advantage of this uniformity, in which case it might be better to have both? Not sure.

ezyang avatar Nov 08 '17 06:11 ezyang

Well, gen_variable_type.py does seem to rely on forward existing:

    for declaration in declarations:
        name = declaration['name']
        if name == 'batch_norm' or 'conv' in name:
            continue

        fwd_name = name + '_forward'
        if fwd_name not in declarations_by_name:
            continue
        declaration['base_name'] = fwd_name

ezyang avatar Nov 08 '17 08:11 ezyang