Turn off the ability for Declarations.cwrap entries to be methods.
authorGregory Chanan <gchanan@fb.com>
Wed, 13 Feb 2019 18:27:23 +0000 (10:27 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Wed, 13 Feb 2019 20:25:05 +0000 (12:25 -0800)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/17053

Differential Revision: D14065887

Pulled By: gchanan

fbshipit-source-id: 5d06ac66d27d28d48c2aff2b0d911f34ea0cd6fd

aten/src/ATen/function_wrapper.py

index 960bf82..737bf8a 100644 (file)
@@ -834,13 +834,11 @@ def create_generic(top_env, declarations):
 
         option['const_mark'] = '' if option['inplace'] else ' const'
 
-        is_method = 'method' in option['variants']
+        assert 'method' not in option['variants'], 'TH functions cannot be methods'
         is_function = 'function' in option['variants']
         dispatch_tensor = find_dispatch_tensor(formals)
         is_namespace_function = is_function and dispatch_tensor is not None
 
-        check_methods_do_not_start_with_underscore(option['name'], is_method)
-
         broadcast_arg = get_broadcast_argument(option)
         # "s_" for "same size".
         option['method_prefix_derived'] = '' if broadcast_arg is None else 's_'
@@ -902,13 +900,6 @@ def create_generic(top_env, declarations):
                 TYPE_METHOD_DEFINITION_BROADCAST.substitute(env))
 
         method_of = ['Type']
-        if is_method:
-            top_env['tensor_method_declarations'].append(
-                TENSOR_METHOD_DECLARATION.substitute(env))
-            top_env['tensor_method_definitions'].append(
-                TENSOR_METHOD_DEFINITION.substitute(env))
-            method_of.append('Tensor')
-
         if is_namespace_function:
             option['inferred_type'] = 'detail::infer_type({})'.format(dispatch_tensor)
             top_env['function_declarations'].append(