summaryrefslogtreecommitdiff
path: root/test/common_nn.py
AgeCommit message (Collapse)AuthorFilesLines
2019-03-30Turn on F401: Unused import warning. (#18598)Edward Yang1-1/+1
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/18598 ghimport-source-id: c74597e5e7437e94a43c163cee0639b20d0d0c6a Stack from [ghstack](https://github.com/ezyang/ghstack): * **#18598 Turn on F401: Unused import warning.** This was requested by someone at Facebook; this lint is turned on for Facebook by default. "Sure, why not." I had to noqa a number of imports in __init__. Hypothetically we're supposed to use __all__ in this case, but I was too lazy to fix it. Left for future work. Be careful! flake8-2 and flake8-3 behave differently with respect to import resolution for # type: comments. flake8-3 will report an import unused; flake8-2 will not. For now, I just noqa'd all these sites. All the changes were done by hand. Signed-off-by: Edward Z. Yang <ezyang@fb.com> Differential Revision: D14687478 fbshipit-source-id: 30d532381e914091aadfa0d2a5a89404819663e3
2019-03-27enable more unit tests (#18537)jithunnair-amd1-18/+0
Summary: Enable unit tests working with ROCm 2.3. In particular, these are unit tests where we skipped for double data types previously and some tests for multi-GPU setups. Pull Request resolved: https://github.com/pytorch/pytorch/pull/18537 Differential Revision: D14651822 Pulled By: ezyang fbshipit-source-id: 7dd575504ebe235a91489866c91000e9754b1235
2019-03-18Circular Convolution Function via circular padding (#17240)Narine Kokhlikyan1-0/+173
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/17240 Added circular padding in addition to zero padding to Conv1D, Conv2D and Conv3D based on the solution suggested in: https://github.com/pytorch/pytorch/issues/3858 Reviewed By: ezyang Differential Revision: D14126416 fbshipit-source-id: a2f1587503ee0cfff98d5cb0d5b0a600ef8aaeb4
2019-02-21fix lint (#17366)Soumith Chintala1-11/+22
Summary: fix lint Pull Request resolved: https://github.com/pytorch/pytorch/pull/17366 Differential Revision: D14171702 Pulled By: soumith fbshipit-source-id: 5d8ecfac442e93b11bf4095f9977fd3302d033eb
2019-02-21remove nn.Upsample deprecation warnings from tests (#17352)Soumith Chintala1-99/+99
Differential Revision: D14168481 Pulled By: soumith fbshipit-source-id: 63c37c5f04d2529abd4f42558a3d5e81993eecec
2019-02-14Speed-up adaptive average pooling for the common case of size=1 output (#17011)ngimel1-0/+12
Summary: When adaptive pooling has to produce a single pixel feature map, it is faster to do so by calling .mean(). Backward calls a pretty inefficient cuda kernel with atomics, which becomes ridiculously slow for halfs. For half this PR provides approx 30x speed-up for adaptive average pooling, which results in 30% end-to-end speed-up on senet. Improvements are smaller for float, but still significant (approx 5x). Also this PR unifies handling of 3d (no batch dimension) and 4d tensors, using negative dimension indices. cc ezyang for review. Pull Request resolved: https://github.com/pytorch/pytorch/pull/17011 Reviewed By: ailzhang Differential Revision: D14078747 Pulled By: soumith fbshipit-source-id: 0eb9255da2351190a6bcaf68c30e2ae2402a2dd9
2019-02-12enable more unit tests in test_nn (#16994)Johannes M Dieterich1-33/+1
Summary: These tests work with ROCm 2.1. Pull Request resolved: https://github.com/pytorch/pytorch/pull/16994 Differential Revision: D14059802 Pulled By: bddppq fbshipit-source-id: 8e2cbb13196c2e0283d3e02b7f761374bc580751
2019-02-12fix bicubic upsampling and enable tests (#17020)Johannes M Dieterich1-7/+0
Summary: Fix macro name in ifdef guard, enable upsampling tests. Pull Request resolved: https://github.com/pytorch/pytorch/pull/17020 Differential Revision: D14059780 Pulled By: bddppq fbshipit-source-id: 82c57d17d5bccdccb548c65d2b7a1ff8ab05af30
2019-01-16Port the backend of FractionalMaxPool3d from TH to ATen (#15575)Chandler Zuo1-0/+25
Summary: 1. Port the FractionalMaxPool3d implementation from THNN/THCUNN to ATen. 2. Expose this function to Python module nn. Pull Request resolved: https://github.com/pytorch/pytorch/pull/15575 Differential Revision: D13612848 Pulled By: chandlerzuo fbshipit-source-id: 5f474b39005efa7788e984e8a805456dcdc43f6c
2019-01-15Port FractionalMaxPool2d from TH to ATen (#15531)Chandler Zuo1-14/+19
Summary: Tested: pytest test/test_nn.py -k Fractional Pull Request resolved: https://github.com/pytorch/pytorch/pull/15531 Differential Revision: D13612833 Pulled By: chandlerzuo fbshipit-source-id: b919d698d068b97ba7a4f8021367e7f6c8aae39c
2018-12-17Bicubic interpolation for nn.functional.interpolate (#9849)David Riazati1-0/+49
Summary: Addresses #918, interpolation results should be similar to tf * Adds bicubic interpolation operator to `nn.functional.interpolate` * Corresponding test in `test_nn.py` The operator is added in legacy `TH` to be aligned with the other upsampling operators; they can be refactored/moved to ATen all at once when #10482 is resolved Pull Request resolved: https://github.com/pytorch/pytorch/pull/9849 Differential Revision: D9007525 Pulled By: driazati fbshipit-source-id: 93ef49a34ce4e5ffd4bda94cd9a6ddc939f0a4cc
2018-12-04Enable testing on Loss modules (#14778)David Riazati1-1/+1
Summary: This PR adds `None` buffers as parameters (similarly to #14715). It also cleans up a bunch of the `test_jit.py` tests that should be covered by `common_nn.py` and brings in `criterion_tests` to test loss functions. Pull Request resolved: https://github.com/pytorch/pytorch/pull/14778 Differential Revision: D13330849 Pulled By: driazati fbshipit-source-id: 924cc4cf94e0dcd11e811a55222fd2ebc42a9e76
2018-12-04Add new reduction mode in kl_div (#14457)Ailing Zhang1-0/+2
Summary: Fixes #6622 . We used to average over all elements for kl divergence, which is not aligned with its math definition. This PR corrects the default reduction behavior of KL divergence that it now naverages over batch dimension. - In KL, default behavior `reduction=mean` averages over batch dimension. While for most other loss functions, `reduction=mean` averages over all elements. - We used to support scalar tensor as well. For BC purpose, we still support it, no reduction is performed on scalar tensor. - Added a new reduction mode called `batchmean` which has the correct behavior for KL. Add a warning to make `batchmean` as default for KL instead of `mean` in next major release. - [deprecated]I chose to not add a new reduction option, since "mean over batch dimension" is kinda special, and it only makes sense in few cases like KL. We don't want to explain why there's a option "batchmean" but it's not applicable for all other functions. I'm open to discussion on this one, as I cannot think of a perfect solution for this. Pull Request resolved: https://github.com/pytorch/pytorch/pull/14457 Differential Revision: D13236016 Pulled By: ailzhang fbshipit-source-id: 905cc7b3bfc35a11d7cf098b1ebc382170a087a7
2018-12-04interpolate (#14123)Elias Ellison1-11/+11
Summary: Add support for interpolate and upsampling in weak_script mode. Because the function parameters are overloaded, i had to add it as a builtin op. For interpolate: size can be ?int | int[]?, and scale_factor can be ?float | float[]?. Every combination of the two parameters needs to be supported. The same logic applies for upsample_nearest, upsample_bilinear, and upsample. There are a few fixes that I came to along the way. Pull Request resolved: https://github.com/pytorch/pytorch/pull/14123 Differential Revision: D13278923 Pulled By: eellison fbshipit-source-id: e59729034369be4ce4b747291a3d1c74e135b869
2018-11-30Move module tests to common_nn (#14578)David Riazati1-1/+1953
Summary: This moves `new_module_tests` from `test_nn.py` to `common_nn.py` so that they can be used in `test_jit.py` without running any of `test_nn.py` Pull Request resolved: https://github.com/pytorch/pytorch/pull/14578 Differential Revision: D13268286 Pulled By: driazati fbshipit-source-id: 6e8654a4c29ab754d656ac83820c14d1c1843e03
2018-11-28Use nn module tests in test_jit (#14238)David Riazati1-2/+2
Summary: This PR adds weak modules for all activation modules and uses `test_nn` module tests to test weak modules that have been annotated with `weak_module` and therefore are in `torch._jit_internal._weak_types` Also depends on #14379 Pull Request resolved: https://github.com/pytorch/pytorch/pull/14238 Differential Revision: D13252887 Pulled By: driazati fbshipit-source-id: e9638cf74089884a32b8f0f38396cf432c02c988
2018-11-28Revert D13192230: [pytorch][PR] [jit] Use nn module tests in test_jitDavid Riazati1-2/+2
Differential Revision: D13192230 Original commit changeset: 36488960b6c9 fbshipit-source-id: 63b68bd909b9ef0548f52c986c84f549aecb8909
2018-11-27Use nn module tests in test_jit (#14238)David Riazati1-2/+2
Summary: This PR adds weak modules for all activation modules and uses `test_nn` module tests to test weak modules that have been annotated with `weak_module` and therefore are in `torch._jit_internal._weak_types` Also depends on #14379 Pull Request resolved: https://github.com/pytorch/pytorch/pull/14238 Differential Revision: D13192230 Pulled By: driazati fbshipit-source-id: 36488960b6c91448b38c0fa65422539a93af8c5e
2018-11-14Ensure nn Losses check scalar vs non-scalar values.Gregory Chanan1-5/+1
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/13860 Reviewed By: ezyang Differential Revision: D13029364 Pulled By: gchanan fbshipit-source-id: 20f1330fa181e52aea1f879dc655a9a6f62b5f53
2018-11-01Rename elementwise_mean to mean (#13419)Tongzhou Wang1-25/+25
Summary: Closes #12459 Pull Request resolved: https://github.com/pytorch/pytorch/pull/13419 Differential Revision: D12883299 Pulled By: SsnL fbshipit-source-id: 8b4512ff73b66fdc674412904dbb3bf497ba70a7
2018-10-24Enable test_nn embedding tests and use correct warp size in Embedding.cu ↵iotamudelta1-4/+0
(#13046) Summary: * Enable test_nn embedding tests and use correct warp size in Embedding.cu * Fix embedding_backward_feature_kernel kernel for HIP For attention: bddppq ezyang Pull Request resolved: https://github.com/pytorch/pytorch/pull/13046 Differential Revision: D10560721 Pulled By: bddppq fbshipit-source-id: e6c3cbeb980a34ff52a92dba8bde745a2e03f2fd
2018-10-17Rename test/common.py to test/common_utils.py (#12794)James Sun1-1/+1
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/12794 common.py is used in base_module for almost all tests in test/. The name of this file is so common that can easily conflict with other dependencies if they happen to have another common.py in the base module. Rename the file to avoid conflict. Reviewed By: orionr Differential Revision: D10438204 fbshipit-source-id: 6a996c14980722330be0a9fd3a54c20af4b3d380
2018-10-08Fix a bunch of warnings in TestNNTongzhou Wang1-2/+2
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/12453 Differential Revision: D10244130 Pulled By: SsnL fbshipit-source-id: e425c76bfb721fe118a32ddd1fa6eca3a3cd86f0
2018-10-03mark unit tests as working, skip failing unit test (#12313)Johannes M Dieterich1-19/+0
Summary: * enabled fp16 tests for test_torch * enable fp16 tests for test_nn * enabled multilabelmargin loss for fp16 * removed skip for test_pdist_empty_col * Enable test_nn tests that pass with compiler fixes etc. * Enable test_legacy_nn tests that pass with compiler fixes etc. ezyang bddppq Pull Request resolved: https://github.com/pytorch/pytorch/pull/12313 Differential Revision: D10189922 Pulled By: bddppq fbshipit-source-id: a5592817c04b14e355cb062d42ebea406f0c92b6
2018-09-02improve docker packages, fix bugs, enable tests, enable FFT (#10893)iotamudelta1-4/+27
Summary: * improve docker packages (install OpenBLAS to have at-compile-time LAPACK functionality w/ optimizations for both Intel and AMD CPUs) * integrate rocFFT (i.e., enable Fourier functionality) * fix bugs in ROCm caused by wrong warp size * enable more test sets, skip the tests that don't work on ROCm yet * don't disable asserts any longer in hipification * small improvements Pull Request resolved: https://github.com/pytorch/pytorch/pull/10893 Differential Revision: D9615053 Pulled By: ezyang fbshipit-source-id: 864b4d27bf089421f7dfd8065e5017f9ea2f7b3b
2018-08-01Add CELU activation to pytorch (#8551)Xiang Gao1-0/+1
Summary: Also fuse input scale multiplication into ELU Paper: https://arxiv.org/pdf/1704.07483.pdf Pull Request resolved: https://github.com/pytorch/pytorch/pull/8551 Differential Revision: D9088477 Pulled By: SsnL fbshipit-source-id: 877771bee251b27154058f2b67d747c9812c696b
2018-07-31Add CTC loss (#9628)Thomas Viehmann1-6/+48
Summary: The CPU and CUDA variants are a direct transposition of Graves et al.'s description of the algorithm with the modification that is is in log space. The there also is a binding for the (much faster) CuDNN implementation. This could eventually fix #3420 I still need to add tests (TestNN seems much more elaborate than the other testing) and fix the bugs than invariably turn up during the testing. Also, I want to add some more code comments. I could use feedback on all sorts of things, including: - Type handling (cuda vs. cpu for the int tensors, dtype for the int tensors) - Input convention. I use log probs because that is what the gradients are for. - Launch parameters for the kernels - Errors and obmissions and anything else I'm not even aware of. Thank you for looking! In terms of performance it looks like it is superficially comparable to WarpCTC (and thus, but I have not systematically investigated this). I have read CuDNN is much faster than implementations because it does *not* use log-space, but also the gathering step is much much faster (but I avoided trying tricky things, it seems to contribute to warpctc's fragility). I might think some more which existing torch function (scatter or index..) I could learn from for that step. Average timings for the kernels from nvprof for some size: ``` CuDNN: 60.464us compute_alphas_and_betas 16.755us compute_grads_deterministic Cuda: 121.06us ctc_loss_backward_collect_gpu_kernel (= grads) 109.88us ctc_loss_gpu_kernel (= alphas) 98.517us ctc_loss_backward_betas_gpu_kernel (= betas) WarpCTC: 299.74us compute_betas_and_grad_kernel 66.977us compute_alpha_kernel ``` Of course, I still have the (silly) outer blocks loop rather than computing consecutive `s` in each thread which I might change, and there are a few other things where one could look for better implementations. Finally, it might not be unreasonable to start with these implementations, as the performance of the loss has to be seen in the context of the entire training computation, so this would likely dilute the relative speedup considerably. My performance measuring testing script: ``` import timeit import sys import torch num_labels = 10 target_length = 30 input_length = 50 eps = 1e-5 BLANK = 0#num_labels batch_size = 16 torch.manual_seed(5) activations = torch.randn(input_length, batch_size, num_labels + 1) log_probs = torch.log_softmax(activations, 2) probs = torch.exp(log_probs) targets = torch.randint(1, num_labels+1, (batch_size * target_length,), dtype=torch.long) targets_2d = targets.view(batch_size, target_length) target_lengths = torch.tensor(batch_size*[target_length]) input_lengths = torch.tensor(batch_size*[input_length]) activations = log_probs.detach() def time_cuda_ctc_loss(grout, *args): torch.cuda.synchronize() culo, culog_alpha = torch._ctc_loss(*args) g, = torch.autograd.grad(culo, args[0], grout) torch.cuda.synchronize() def time_cudnn_ctc_loss(groupt, *args): torch.cuda.synchronize() culo, cugra= torch._cudnn_ctc_loss(*args) g, = torch.autograd.grad(culo, args[0], grout) torch.cuda.synchronize() def time_warp_ctc_loss(grout, *args): torch.cuda.synchronize() culo = warpctc.ctc_loss(*args, blank_label=BLANK, size_average=False, length_average=False, reduce=False) g, = torch.autograd.grad(culo, args[0], grout) torch.cuda.synchronize() if sys.argv[1] == 'cuda': lpcu = log_probs.float().cuda().detach().requires_grad_() args = [lpcu, targets_2d.cuda(), input_lengths.cuda(), target_lengths.cuda(), BLANK] grout = lpcu.new_ones((batch_size,)) torch.cuda.synchronize() print(timeit.repeat("time_cuda_ctc_loss(grout, *args)", number=1000, globals=globals())) elif sys.argv[1] == 'cudnn': lpcu = log_probs.float().cuda().detach().requires_grad_() args = [lpcu, targets.int(), input_lengths.int(), target_lengths.int(), BLANK, True] grout = lpcu.new_ones((batch_size,)) torch.cuda.synchronize() print(timeit.repeat("time_cudnn_ctc_loss(grout, *args)", number=1000, globals=globals())) elif sys.argv[1] == 'warpctc': import warpctc activations = activations.cuda().detach().requires_grad_() args = [activations, input_lengths.int(), targets.int(), target_lengths.int()] grout = activations.new_ones((batch_size,), device='cpu') torch.cuda.synchronize() print(timeit.repeat("time_warp_ctc_loss(grout, *args)", number=1000, globals=globals())) ``` I'll also link to a notebook that I used for writing up the algorithm in simple form and then test the against implementations against it. Pull Request resolved: https://github.com/pytorch/pytorch/pull/9628 Differential Revision: D8952453 Pulled By: ezyang fbshipit-source-id: 18e073f40c2d01a7c96c1cdd41f6c70a06e35860
2018-07-11Accumulate MSELoss reduce=True into accreal instead of real (#9287)Richard Zou1-0/+4
Summary: THNN was accumulating the result of reduction loss functions into real instead of accreal. This was causing precision issues with MSELoss. This patch only fixes MSELoss. Some of the other losses exhibit bad precision as well (because they accumulate into real instead of accreal) and require more investigation. I will open an issue for those (#9286) Fixes #8710 cc li-roy SsnL Pull Request resolved: https://github.com/pytorch/pytorch/pull/9287 Reviewed By: SsnL Differential Revision: D8775708 Pulled By: zou3519 fbshipit-source-id: d1a1f159deee0cb90fd8e81e63b246115eea8e9e
2018-07-05Test nn.Module on non-contiguous inputs (#9114)Tongzhou Wang1-7/+15
Summary: 1. Let `ModuleTest` raise when they fail on non-contiguous inputs. Fix legacy modules. 2. Fix BN (both THNN and cuDNN) not working on non-contiguous inputs. 3. Fix CUDA EmbeddingBag not working on non-contiguous inputs. To prevent calling `.contiguous()` on in both `forward` and `backward`, a. prefix all current `embedding_bag*` functions with `_`, indicating that they require input to be contiguous (there is a check in each function). b. create `embedding_bag`, which makes input arguments `.contiguous()`, and calls `_embedding_bag` 3. Make many ATen `embedding*` functions to work on non-contiguous inputs so we don't need to call `input = input.contiguous()` in Python `nn.functional.embedding`. 4. Fix dense-sparse addition when the sparse input is not coalesced and indices or values tensor is not contiguous. This came up in the test cases of Embedding modules with `sparse=True`. Added tests. 5. Update `TensorUtils.cpp` to use `AT_*` macros. Request: review from cpuhrsch on the `Embedding*` changes. review from ezyang on ATen sparse & BN changes. Closes https://github.com/pytorch/pytorch/pull/9114 Differential Revision: D8717299 Pulled By: SsnL fbshipit-source-id: 0acc6f1c9522b5b605361e75112c16bbe1e98527
2018-07-02update nn loss tests to use new reduction arg (#9118)Roy Li1-79/+80
Summary: The tests were using the old args, which caused them to emit a lot of deprecation warnings. closes #9103. Reviewed By: ezyang Differential Revision: D8720581 Pulled By: li-roy fbshipit-source-id: 3b79527f6fe862fb48b99a6394e8d7b89fc7a8c8
2018-07-01combine size_average and reduce args in loss functions (#8018)Roy Li1-1/+5
Summary: closes #7929 Closes https://github.com/pytorch/pytorch/pull/8018 Differential Revision: D8682540 Pulled By: li-roy fbshipit-source-id: 649170dd1a7f373151c1d4e949838bd1c5651936
2018-05-31Add memory leak check in CUDA tests (#7270)Tongzhou Wang1-5/+2
* Add memory leak check in CUDA tests * Tracking multi-GPU too * fix run_test.py not running __name__ == '__main__' content; add test for make_cuda_memory_checked_test * add a comment * skip if cuda * 1. Change the wrapper to a method in common.py:TestCase 2. Refactor common constants/method that initialize CUDA context into common_cuda.py 3. Update some test files to use TEST_CUDA and TEST_MULTIGPU * Fix MaxUnpool3d forward memory leak * Fix MultiLabelMarginCriterion forward memory leak * Fix MultiMarginLoss backward memory leak * default doCUDAMemoryCheck to False * make the wrapper skip-able * use TEST_MULTIGPU * add align_corners=True/False tests for Upsample; fix TEST_CUDNN * finalize interface * VolumetricMaxUnpooling_updateOutput * fix test_nccl * rename THC caching allocator methods to be clearer * make the wrapped function a method * address comments; revert changes to aten/src/THC/THCCachingAllocator.cpp * fix renamed var
2018-05-23[PyTorch] [gradcheck] change backward() to grad() (#7710)Tongzhou Wang1-5/+4
* Change backward calls to grad to avoid memory leak from #7343; Replace unnecesary create_graph=True with retain_graph=True * fix gradgradcheck use of make_non_contiguous * allow non-contguous target * remove unnecessray .grad.zero_() * remove contiguous_detach * fix PReLU double backward always returning ggW as a scalar * let noncontig gO require grad * move requires_grad to return
2018-04-17Codemod to update our codebase to 0.4 standard (#6641)Tongzhou Wang1-43/+20
* Codemod to update our codebase to 0.4 standard * Update some of the test scri[ts * remove Variable in test_clip_grad_value * fix _symbolic_override_wrapper_maker
2018-03-21Implement MarginRankingLoss as native function and add reduce=True arg to it ↵li-roy1-1/+15
(#5346) * add reduce=True arg to MarginRankingLoss * make default margin arg match for legacy * remove accidentally added test * fix test * fix native_functions.yaml alphabetical order
2018-03-17Fix kldiv backward on CUDA (#5814)Richard Zou1-2/+3
* Test that gradOutput is being used for criterion losses * Fix incorrect kldiv backward on CUDA * Address comments * Fix legacy
2018-03-17 implement TripletMarginLoss as a native function (#5680)li-roy1-0/+17
* implement TripletMarginLoss as a native function * implement TripletMarginLoss as native function * fix compile error * address comments * address comments * Add keepdim arg to pairwise distance
2018-03-09small fixes to CosineEmbeddingLoss tests (#5681)li-roy1-0/+2
* small fixes to CosineEmbeddingLoss tests * fix test
2018-03-08implement CosineEmbeddingLoss as a native function and add reduce arg (#5646)li-roy1-2/+21
* implement CosineEmbeddingLoss as a native function and add reduce=True arg to it * fix flake8 * address comments * add reference function to tests * fix flake8
2018-03-08Revert "implement CosineEmbeddingLoss as a native function and add reduce ↵Edward Z. Yang1-21/+2
arg" (#5640) * Revert "implement CosineEmbeddingLoss as a native function and add reduce arg (#5447)" This reverts commit c16478fe3fb8842119438b8fd79d98c8f50ca688.
2018-03-08implement CosineEmbeddingLoss as a native function and add reduce arg (#5447)li-roy1-2/+21
forward (new) [1.1905965859768912, 1.160144692985341, 1.1558120870031416] backward (new) [1.9150976981036365, 1.9792822760064155, 1.8779143309220672] double backward (new) [3.6898688060464337, 3.5784677929477766, 3.569505032035522] forward (old) [3.2359962839400396, 3.275224728975445, 3.3409753759624436] backward (old) [5.668679727939889, 5.722980880062096, 5.585088661056943] double backward (old) N/A * implement CosineEmbeddingLoss as a native function and add reduce=True arg to it * fix flake8 * address comments * add reference function to tests * fix flake8
2018-03-07remove legacy workaround for hinge embedding loss reference fn (#5596)li-roy1-5/+0
2018-03-01Deprecate variable factory, use torch.tensor instead (#5476)gchanan1-3/+1
* Remove usages of torch.autograd.variable; use torch.tensor instead. * Deprecate torch.autograd.variable. * Remove unused sample_scalar.
2018-02-28More Variable/Tensor clean-ups (#5464)Sam Gross1-22/+1
2018-02-27add reduce=True arg to MultiMarginLoss (#5150)li-roy1-0/+82
* add reduce=True arg to MultiMarginLoss * Change tests to support legacy * fix flake8 * address comments * formatting change * remove free of unallocated tensor * fix after variable/tensor merge
2018-02-23Merge Variable and Tensor classes (#5225)Sam Gross1-32/+23
This replaces the torch.Tensor constructors with factories that produce Variables. Similarly, functions on the torch module (e.g. torch.randn) now return Variables. To keep the PR to a reasonable size, I've left most of the unused tensor code. Subsequent PRs will remove the dead code, clean-up calls to torch.autograd.Variable, and rename Variable to Tensor everywhere. There are some breaking changes because Variable and Tensors had slightly different semantics. There's a list of those changes here: https://github.com/pytorch/pytorch/wiki/Breaking-Changes-from-Variable-and-Tensor-merge
2018-02-15add reduce=True arg to MultiLabelSoftMarginLoss (#5097)li-roy1-8/+1
* add reduce=True arg to MultiLabelSoftMarginLoss * Move some tests to new_criterion_tests * fix flake8 * fix multilabelsoftmarginloss weights test
2018-02-13Move scalar tests from common_nn to legacy_nn. (#5223)gchanan1-169/+0
2018-02-13 add reduce=True arg to SoftMarginLoss (#5071)li-roy1-0/+13
* add reduce=True arg to SoftMarginLoss * add reference function for SoftMarginLoss * Rebase onto master * Address comments * Fix flake8 * Fix rebase error
2018-02-09add reduce=True arg to HingeEmbeddingLoss (#5130)li-roy1-0/+22
* add reduce=True arg to HingeEmbeddingLoss * pass arg to super constructor in HingeEmbeddingLoss * make HingeEmbeddingLoss reference fn work on legacy