internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: pytorch/pytorch

Issue:
Disabling ibverbs fails
I think pytorch#5264 may not go far enough. In environments like the Cray XC40/XC50, Intel OmniPath clusters, some Cisco usNIC clusters, there is an IB fabric in places to carry file I/O traffic, but not MPI/IP/other IPC traffic. This means we want to be able to fully disable the use of IB verbs in these environments. We tried:

```bash
export WITH_GLOO_IBVERBS=0
export USE_IBVERBS=0
WITH_GLOO_IBVERBS=0 python setup.py build --verbose
```
and still wound up with:

`-DWITH_GLOO_IBVERBS=1` and `-DUSE_IBVERBS=1`

throughout the build. 

I can work around by editing the function `should_build_ib()` to use an `check_env_flag` to check for `WITH_GLOO_IBVERBS` or `USE_IBVERBS` in the environment in  `pytorch/tools/setup_helpers/dist_check.py`, but think I haven't been through enough in my local edits to handle the default case (finding IB when the user doesn't specify one way or another) and am not sure if I've tracked down all possible side-effects.


Environment Information
--------------------------
When submitting a bug report, please include the following information (where relevant):
- OS: Linux (Cray Linux Environment 6, but also checked in Clear Linux 21060)
- PyTorch version: Master 377d8969699a8120dd04bde9e04b4269747b88c2
- How you installed PyTorch (conda, pip, source): source
- Python version: 2.7.14
- CUDA/cuDNN version: N/A
- GPU models and configuration: N/A
- GCC version (if compiling from source): N/A I'm building with the Intel 2018 compilers which does necessitate a couple of minor patches to array initialization, but that's neither here nor there.


Discussion:

Resolving patch:
diff --git a/tools/setup_helpers/dist_check.py b/tools/setup_helpers/dist_check.py
--- a/tools/setup_helpers/dist_check.py
+++ b/tools/setup_helpers/dist_check.py
@@ -103,4 +103,9 @@ def should_build_ib():
     return ib_util_found and ib_lib_found and ib_lib_found
 
 if WITH_DISTRIBUTED:
-    WITH_GLOO_IBVERBS = should_build_ib() or check_env_flag("WITH_GLOO_IBVERBS")
+    # If the env variable is specified, use the value,
+    # otherwise only build with IB when IB support is detected on the system
+    if "WITH_GLOO_IBVERBS" in os.environ:
+        WITH_GLOO_IBVERBS = check_env_flag("WITH_GLOO_IBVERBS")
+    else:
+        WITH_GLOO_IBVERBS = should_build_ib()


Test patch:
Repository: pytorch/pytorch

Issue:
Changes to function_wrapper.py broke the CI for the ATen standalone repo
@ezyang @zou3519 

See:

https://travis-ci.org/zdevito/ATen/builds


Discussion:
Sorry about that! I'm taking a look.

Resolving patch:
diff --git a/aten/src/ATen/function_wrapper.py b/aten/src/ATen/function_wrapper.py
--- a/aten/src/ATen/function_wrapper.py
+++ b/aten/src/ATen/function_wrapper.py
@@ -2,18 +2,18 @@
 # "what has to be done to add a Operation ..." first!
 
 import re
-from collections import OrderedDict
 from code_template import CodeTemplate
 
 try:
-    import typing
+    import typing  # noqa: F401
 except ImportError:
     raise RuntimeError(
         'Missing build dependency: Unable to import the `typing` module. '
         'Please install it via `conda install typing` or `pip install typing`')
 
-from typing import Any, Dict, List, Generic, Optional, Set, Tuple, \
-    Union, TypeVar, NamedTuple
+# flake8 doesn't take into account usages in type annotations.
+from typing import Union, Set  # noqa: F401
+from typing import Any, Dict, List, Optional, Tuple, NamedTuple
 
 try:
     from mypy_extensions import TypedDict
@@ -292,6 +292,7 @@ def __getitem__(self, x):
             return r
         return self.parent[x]
 
+
 Environment = TypedDict('Environment', {
     'ScalarName': str,
     'THTensor': str,


Test patch:
Repository: pytorch/pytorch

Issue:
index_copy inconsistent behavior on CPU and GPU
`index_copy` has inconsistent behaviors for the shape of the tensor which is used to copy on CPU and GPU. In following examples, `index_copy` raises an error on CPU due to the invalid shape of `y`, but it works well on GPU for same tensors `x`, `y`, `z`.
```
In [1]: import torch

In [2]: from torch.autograd import Variable

In [3]: x = torch.ones(3,1)

In [4]: y = torch.Tensor([4])

In [5]: z = torch.LongTensor([2])

In [6]: x.index_copy_(0, z, y)
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-6-a1189d076165> in <module>()
----> 1 x.index_copy_(0, z, y)

RuntimeError: cannot select on a vector at /users1/xwgeng/pytorch/torch/lib/TH/generic/THTensor.c:403

In [7]: x = x.cuda()

In [8]: y = y.cuda()

In [9]: z = z.cuda()

In [10]: x.index_copy_(0, z, y)
Out[10]: 

 1
 1
 4
[torch.cuda.FloatTensor of size 3x1 (GPU 0)]
```
The pytorch version is `0.1.12+d7db75c`


Discussion:

Resolving patch:
diff --git a/tools/autograd/gen_python_functions.py b/tools/autograd/gen_python_functions.py
--- a/tools/autograd/gen_python_functions.py
+++ b/tools/autograd/gen_python_functions.py
@@ -17,7 +17,7 @@
     'alias', 'contiguous', 'clamp.*', 'is_cuda', 'is_sparse', 'size', 'stride',
     '.*_backward', '.*_backward_out', '.*_forward', '.*_forward_out',
     'sparse_raw_resize_', '_unsafe_view', 'tensor', 'sparse_coo_tensor',
-    '_arange.*', '_range.*', '_linspace.*', '_logspace.*'
+    '_arange.*', '_range.*', '_linspace.*', '_logspace.*', '_indexCopy_',
 ]
 
 PY_VARIABLE_METHODS_CPP = CodeTemplate.from_file(template_path + '/python_variable_methods.cpp')


Test patch:
Repository: pytorch/pytorch

Issue:
Tiny bug in the documentation of the LSTM formula
Hi,

Looking at the formulas of LSTM in [documentation](http://pytorch.org/docs/master/nn.html#torch.nn.LSTM), in the third equation (g_t), the suffix of the second W should be changed from W_{hc} to W_{hg}. The correct formula:

g_t=tanh(W_{ig}x_t+b_{ig}+W{h**g**}h_{(t−1)}+b_{hg})

Cheers,
Navid


Discussion:

Resolving patch:
diff --git a/torch/nn/modules/rnn.py b/torch/nn/modules/rnn.py
--- a/torch/nn/modules/rnn.py
+++ b/torch/nn/modules/rnn.py
@@ -319,7 +319,7 @@ class LSTM(RNNBase):
             \begin{array}{ll}
             i_t = \sigma(W_{ii} x_t + b_{ii} + W_{hi} h_{(t-1)} + b_{hi}) \\
             f_t = \sigma(W_{if} x_t + b_{if} + W_{hf} h_{(t-1)} + b_{hf}) \\
-            g_t = \tanh(W_{ig} x_t + b_{ig} + W_{hc} h_{(t-1)} + b_{hg}) \\
+            g_t = \tanh(W_{ig} x_t + b_{ig} + W_{hg} h_{(t-1)} + b_{hg}) \\
             o_t = \sigma(W_{io} x_t + b_{io} + W_{ho} h_{(t-1)} + b_{ho}) \\
             c_t = f_t c_{(t-1)} + i_t g_t \\
             h_t = o_t \tanh(c_t)


Test patch:
Repository: pytorch/pytorch

Issue:
Small bug in LPPool2d documentation
The math rendering doesn't end where it should, making the text after it difficult to read:

http://pytorch.org/docs/master/nn.html#torch.nn.LPPool2d
<img width="719" alt="screen shot 2018-03-12 at 5 07 03 pm" src="https://user-images.githubusercontent.com/6576216/37309613-d339a60c-2617-11e8-80a9-96e7a7bc1e93.png">



Discussion:
Thanks for the report! Would you be interested in submitting a PR that fixes it?
Sure, I can give it a try!

Resolving patch:
diff --git a/torch/nn/modules/pooling.py b/torch/nn/modules/pooling.py
--- a/torch/nn/modules/pooling.py
+++ b/torch/nn/modules/pooling.py
@@ -777,8 +777,8 @@ class LPPool2d(Module):
     .. math::
         f(X) = \sqrt[p]{\sum_{x \in X} x^{p}}
 
-        - At p = infinity, one gets Max Pooling
-        - At p = 1, one gets Average Pooling
+    - At p = infinity, one gets Max Pooling
+    - At p = 1, one gets Sum Pooling (which is proportional to Average Pooling)
 
     The parameters :attr:`kernel_size`, :attr:`stride` can either be:
 
@@ -841,8 +841,8 @@ class LPPool1d(Module):
     .. math::
         f(X) = \sqrt[p]{\sum_{x \in X} x^{p}}
 
-        - At p = infinity, one gets Max Pooling
-        - At p = 1, one gets Average Pooling
+    - At p = infinity, one gets Max Pooling
+    - At p = 1, one gets Sum Pooling (which is proportional to Average Pooling)
 
     Args:
         kernel_size: a single int, the size of the window


Test patch:
Repository: pytorch/pytorch

Issue:
Type() and type_as() are missing documentation
As can be seen in http://pytorch.org/docs/master/tensors.html

Best :)


Discussion:
Note that we had docs for these functions in PyTorch 0.3. Most likely, I accidentally deleted them in the tensor & variable merge.

Resolving patch:
diff --git a/torch/_tensor_docs.py b/torch/_tensor_docs.py
--- a/torch/_tensor_docs.py
+++ b/torch/_tensor_docs.py
@@ -1775,6 +1775,40 @@ def callable(a, b) -> number
 In-place version of :meth:`~Tensor.trunc`
 """)
 
+add_docstr_all('type',
+               r"""
+type(dtype=None, non_blocking=False, **kwargs) -> str or Tensor
+Returns the type if `dtype` is not provided, else casts this object to
+the specified type.
+
+If this is already of the correct type, no copy is performed and the
+original object is returned.
+
+Args:
+    dtype (type or string): The desired type
+    non_blocking (bool): If ``True``, and the source is in pinned memory
+        and destination is on the GPU or vice versa, the copy is performed
+        asynchronously with respect to the host. Otherwise, the argument
+        has no effect.
+    **kwargs: For compatibility, may contain the key ``async`` in place of
+        the ``non_blocking`` argument. The ``async`` arg is deprecated.
+""")
+
+add_docstr_all('type_as',
+               r"""
+type_as(tensor) -> Tensor
+
+Returns this tensor cast to the type of the given tensor.
+
+This is a no-op if the tensor is already of the correct type. This is
+equivalent to::
+
+    self.type(tensor.type())
+
+Params:
+    tensor (Tensor): the tensor which has the desired type
+""")
+
 add_docstr_all('unfold',
                r"""
 unfold(dim, size, step) -> Tensor
diff --git a/torch/_utils.py b/torch/_utils.py
--- a/torch/_utils.py
+++ b/torch/_utils.py
@@ -18,7 +18,7 @@ def _type(self, dtype=None, non_blocking=False, **kwargs):
             asynchronously with respect to the host. Otherwise, the argument
             has no effect.
         **kwargs: For compatibility, may contain the key ``async`` in place of
-            the ``non_blocking`` argument.
+            the ``non_blocking`` argument. The ``async`` arg is deprecated.
     """
     non_blocking = _get_async_or_non_blocking('type', non_blocking, kwargs)
     if dtype is None:


Test patch:
Repository: pytorch/pytorch

Issue:
Save `self.numel()` for backwards computation
Right now, the following derivatives.yaml declaration:
```
- name: mean(Tensor self)
  self: grad.expand(self.sizes()) / self.numel()
```
produces the following backwards:
```
variable_list MeanBackward1::apply(const variable_list& grads) {
  IndexRangeGenerator gen;
  auto self_ix = gen.range(1);
  variable_list grad_inputs(gen.size());
  auto& grad = grads[0];
  auto self = self_.unpack();
  if (should_compute_output({ self_ix })) {
    auto grad_result = grad.expand(self_sizes) / self.numel();
    copy_range(grad_inputs, self_ix, grad_result);
  }
  return grad_inputs;
}
```
It looks like `self.sizes()` is being saved for the backward pass, but `self.numel()` isn't, requiring saving `self` for backwards.


Discussion:

Resolving patch:
diff --git a/tools/autograd/load_derivatives.py b/tools/autograd/load_derivatives.py
--- a/tools/autograd/load_derivatives.py
+++ b/tools/autograd/load_derivatives.py
@@ -289,6 +289,11 @@ def saved_variables(formula, args):
             'suffix': lambda m: '_argsize_{}'.format(*m.groups()),
             'type': 'int64_t',
         }),
+        # replace self.numel() with self_numel
+        (r'{}.numel\(\)', {
+            'suffix': '_numel',
+            'type': 'int64_t',
+        }),
         # replace to_arg_sizes(self, 2) with self_argsizes_2
         (r'to_arg_sizes\({}, (\w+)\)', {
             'suffix': lambda m: '_sizes_{}'.format(*m.groups()),


Test patch:
Repository: pytorch/pytorch

Issue:
load_nvprof error
I got the following error when I load_nvprof.

> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File "/opt/pytorch/torch/autograd/profiler.py", line 286, in load_nvprof
>     return EventList(parse_nvprof_trace(path))
>   File "/opt/pytorch/torch/autograd/profiler.py", line 539, in parse_nvprof_trace
>     functions.sort(key=lambda evt: evt.start)
>   File "/opt/pytorch/torch/autograd/profiler.py", line 539, in <lambda>
>     functions.sort(key=lambda evt: evt.start)
> AttributeError: 'FunctionEvent' object has no attribute 'start'

pytorch version:
0.4.0a0+b69b885

The function works properly on 0.3.1.


Discussion:

Resolving patch:
diff --git a/torch/autograd/profiler.py b/torch/autograd/profiler.py
--- a/torch/autograd/profiler.py
+++ b/torch/autograd/profiler.py
@@ -536,7 +536,7 @@ def parse_nvprof_trace(path):
                           row['kernel_start'],
                           row['kernel_end'])
 
-    functions.sort(key=lambda evt: evt.start)
+    functions.sort(key=lambda evt: evt.cpu_interval.start)
     return functions
 
 


Test patch:
Repository: pytorch/pytorch

Issue:
Source build issue: Missing catch.hpp
Trying to build master (a3bd7b2), I'm seeing

```
.../pytorch/aten/src/ATen/test/basic.cpp:2:21: fatal error: catch.hpp: No such file or directory`
```

I tried `git submodule update` in `.../pytorch` to no avail. 


Discussion:
NM, also needed a `git submodule init`. 
Need a check to see if this is folder is checked out in `setup.py`, like the other submodules. Should be a simple patch.

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -255,6 +255,7 @@ def check_file(f):
         check_file(os.path.join(lib_path, "pybind11", "CMakeLists.txt"))
         check_file(os.path.join('aten', 'src', 'ATen', 'cpu', 'cpuinfo', 'CMakeLists.txt'))
         check_file(os.path.join('aten', 'src', 'ATen', 'cpu', 'tbb', 'tbb_remote', 'Makefile'))
+        check_file(os.path.join('aten', 'src', 'ATen', 'utils', 'catch', 'CMakeLists.txt'))
 
         check_pydep('yaml', 'pyyaml')
         check_pydep('typing', 'typing')


Test patch:
Repository: pytorch/pytorch

Issue:
Windows build logs are 7M a pop
That's pretty big! In contrast, an OS X build log is only 1.3M. Is there a reason they have to be this big?

CC @peterjc123 @yf225 


Discussion:
My guess is that it's because of warnings. I remember having to get through thousands of them when looking for the error that failed the build.
Yes, the major part of them are warnings. And some of them is not fixable. We can hide them using some flags on the compilers.
And this build configuration actually contains both the CPU and GPU build, which may also be a possible reason.

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -462,11 +462,14 @@ def run(self):
 extra_link_args = []
 
 if IS_WINDOWS:
-    extra_compile_args = ['/Z7', '/EHa', '/DNOMINMAX'
+    extra_compile_args = ['/Z7', '/EHa', '/DNOMINMAX', '/wd4267', '/wd4251', '/wd4522',
+                          '/wd4522', '/wd4838', '/wd4305', '/wd4244', '/wd4190',
+                          '/wd4101', '/wd4996', '/wd4275'
                           # /Z7 turns on symbolic debugging information in .obj files
                           # /EHa is about native C++ catch support for asynchronous
                           # structured exception handling (SEH)
                           # /DNOMINMAX removes builtin min/max functions
+                          # /wdXXXX disables warning no. XXXX
                           ]
     if sys.version_info[0] == 2:
         # /bigobj increases number of sections in .obj file, which is needed to link


Test patch:
Repository: pytorch/pytorch

Issue:
Add expand nodes to point-wise operators generated by @script
@script doesn't insert expand nodes, but our fuser assumes that point-wise operators cannot broadcast, which is unsafe. We need to fix this in a way makes the fuser safe, while still having it produce good fusions for @script nodes. This can be a modification to shape analysis that is aware of the (relatively small) set of point-wise operators that do broadcasting.

```
# before analysis
y = rand(1,4)
z = rand(4,4)
x = exp(add(y, z)) # broadcasting add

# using the result of shape analysis, we insert expand nodes and replace
# broadcasting add with a non-broadcasting variant:

# after
y = rand(1,4)
z = rand(4,4)
x = exp(add_nobroadcast(expand_to(y, z), z)) # non-broadcasting add, nobroadcast could be an attribute if that turns out to work.

# fuser is modified to only work on non-broadcasting adds.

```



Discussion:
@apaszke 

Resolving patch:
diff --git a/torch/jit/__init__.py b/torch/jit/__init__.py
--- a/torch/jit/__init__.py
+++ b/torch/jit/__init__.py
@@ -524,10 +524,14 @@ def __getattr__(self, attr):
         return self.module._get_method(attr)
 
 
-def script(fn):
-    rcb = createResolutionCallback()
+def _script_graph(fn, frame_id=2):
+    rcb = createResolutionCallback(frame_id)
     ast = get_jit_ast(fn)
-    graph = _jit_script_compile(ast, rcb)
+    return _jit_script_compile(ast, rcb)
+
+
+def script(fn):
+    graph = _script_graph(fn, frame_id=3)
     return torch._C.GraphExecutor(graph, True)
 
 


Test patch:
diff --git a/test/expect/TestJit.test_shape_analysis_broadcast.expect b/test/expect/TestJit.test_shape_analysis_broadcast.expect
new file mode 100644
--- /dev/null
+++ b/test/expect/TestJit.test_shape_analysis_broadcast.expect
@@ -0,0 +1,7 @@
+graph(%a : Double(3, 1, 5)
+      %b : Double(4, 1, 8, 5)) {
+  %3 : Double(4!, 3!, 8!, 5) = aten::expand[size=[4, 3, 8, 5]](%a)
+  %4 : Double(4!, 3!, 8, 5) = aten::expand[size=[4, 3, 8, 5]](%b)
+  %2 : Double(4, 3, 8, 5) = aten::add[alpha={1}](%3, %4)
+  return (%2);
+}
diff --git a/test/test_jit.py b/test/test_jit.py
--- a/test/test_jit.py
+++ b/test/test_jit.py
@@ -1412,6 +1412,17 @@ def test_integral_shape_inference(a):
 
         self.assertEqual(cu.test_integral_shape_inference(*inputs), outputs)
 
+    def test_shape_analysis_broadcast(self):
+        def broadcast(a, b):
+            return a + b
+
+        x = torch.randn(3, 1, 5, requires_grad=True)
+        y = torch.randn(4, 1, 8, 5, requires_grad=True)
+
+        graph = torch.jit._script_graph(broadcast)
+        torch._C._jit_pass_shape_analysis(graph, (x, y), False)
+        self.assertExpected(str(graph))
+
     def test_fuser_multiple_blocks(self):
         cu = torch.jit.CompilationUnit('''
         def test_fuser_multiple_blocks(this, that, theother, meme):
Repository: pytorch/pytorch

Issue:
enabling older computing capabilities like 5.0
I am using ubuntu 16.04 and I am trying to compile pytorch and I want to enable 5.0 cuda computing capability where to set it - in what file or maybe in environment variable? 


Discussion:
The environment variable is `TORCH_CUDA_ARCH_LIST`. You can build with `TORCH_CUDA_ARCH_LIST=5.0 python setup.py build develop`.

This should probably be added to the README (or setup.py, where the other common env variables are documented).

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -52,6 +52,10 @@
 #     specify the version of PyTorch, rather than the hard-coded version
 #     in this file; used when we're building binaries for distribution
 #
+#   TORCH_CUDA_ARCH_LIST
+#     specify which CUDA architectures to build for.
+#     ie `TORCH_CUDA_ARCH_LIST="6.0;7.0"`
+#
 # Environment variables we respect (these environment variables are
 # conventional and are often understood/set by other software.)
 #


Test patch:
Repository: pytorch/pytorch

Issue:
Multiprocessing: sharing a zero-sized tensor fails
- PyTorch version: 0.4.0a0+c7611f7

Repro:

```python
import torch
import torch.multiprocessing as mp

q = mp.Queue()
t = torch.tensor([])
q.put(t)
```

Result:

```
  File "/data/users/sgross/python3/lib/python3.5/multiprocessing/queues.py", line 241, in _feed
    obj = ForkingPickler.dumps(obj)
  File "/data/users/sgross/python3/lib/python3.5/multiprocessing/reduction.py", line 50, in dumps
    cls(buf, protocol).dump(obj)
  File "/data/users/sgross/pytorch/torch/multiprocessing/reductions.py", line 117, in reduce_storage
    df = multiprocessing.reduction.DupFd(fd)
  File "/data/users/sgross/python3/lib/python3.5/multiprocessing/reduction.py", line 190, in DupFd
    return resource_sharer.DupFd(fd)
  File "/data/users/sgross/python3/lib/python3.5/multiprocessing/resource_sharer.py", line 48, in __init__
    new_fd = os.dup(fd)
OSError: [Errno 9] Bad file descriptor
```


Discussion:
Emm. I fail to reproduce this bug in Python 3.5.0 and Mac OS 10.13.3. What's your system environment?
The bug is probably specific to the `file_descriptor` sharing mode. Mac OS uses `filename` by default.

Resolving patch:
diff --git a/torch/multiprocessing/reductions.py b/torch/multiprocessing/reductions.py
--- a/torch/multiprocessing/reductions.py
+++ b/torch/multiprocessing/reductions.py
@@ -98,6 +98,10 @@ def rebuild_storage_cuda(cls, device, handle, size, offset, view_size):
     return storage
 
 
+def rebuild_storage_empty(cls):
+    return cls()
+
+
 def reduce_storage(storage):
     from . import get_sharing_strategy
     if storage.is_cuda:
@@ -109,6 +113,10 @@ def reduce_storage(storage):
         cache_key = metadata[1]
         rebuild = rebuild_storage_filename
         storage._shared_incref()
+    elif storage.size() == 0:
+        # This is special cased because Empty tensors
+        # (with size 0) cannot be mmapped.
+        return (rebuild_storage_empty, (type(storage),))
     else:
         fd, size = storage._share_fd_()
         if sys.version_info[0] == 2:


Test patch:
diff --git a/test/test_multiprocessing.py b/test/test_multiprocessing.py
--- a/test/test_multiprocessing.py
+++ b/test/test_multiprocessing.py
@@ -371,6 +371,22 @@ def test_event(self):
             self.assertEqual(list(tensor), [4, 4, 4, 4])
         p.join()
 
+    def _test_empty_tensor_sharing(self, dtype):
+        q = mp.Queue()
+        empty = torch.tensor([], dtype=dtype)
+        q.put(empty)
+        out = q.get(timeout=1)
+        self.assertEqual(out, empty)
+
+    def test_empty_tensor_sharing(self):
+        self._test_empty_tensor_sharing(torch.float32)
+        self._test_empty_tensor_sharing(torch.int64)
+
+    @unittest.skipIf(not torch.cuda.is_available(), 'CUDA not available')
+    def test_empty_tensor_sharing_cuda(self):
+        self._test_empty_tensor_sharing(torch.cuda.float32)
+        self._test_empty_tensor_sharing(torch.cuda.int64)
+
     def _test_autograd_sharing(self, var):
         ready = mp.Event()
         master_modified = mp.Event()
Repository: pytorch/pytorch

Issue:
Make Windows build stop clobbering tools/shared/cwrap_common.py
Because this file is implemented as a symlink, in Windows we copy the source over it as part of the build process. This dirties the working copy, and is generally annoying. It would be good to work out a way to make this not happen.

CC @peterjc123 


Discussion:
How could this be done? Copy this file in the `setup.py` script and add it to `.gitignore`?

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -293,6 +293,15 @@ def check_file(f):
             libs += ['THD']
         build_libs(libs)
 
+        # Use copies instead of symbolic files.
+        # Windows has very poor support for them.
+        sym_files = ['tools/shared/cwrap_common.py']
+        orig_files = ['aten/src/ATen/common_with_cwrap.py']
+        for sym_file, orig_file in zip(sym_files, orig_files):
+            if os.path.exists(sym_file):
+                os.remove(sym_file)
+            shutil.copyfile(orig_file, sym_file)
+
         # Copy headers necessary to compile C++ extensions.
         #
         # This is not perfect solution as build does not depend on any of
diff --git a/tools/shared/cwrap_common.py b/tools/shared/cwrap_common.py
deleted file mode 120000
--- a/tools/shared/cwrap_common.py
+++ /dev/null
@@ -1 +0,0 @@
-../../aten/src/ATen/common_with_cwrap.py
\ No newline at end of file


Test patch: