8000 Update on "Make TS recognize input arg name" · pytorch/pytorch@15ded21 · GitHub
[go: up one dir, main page]

Skip to content

Commit 15ded21

Browse files
Update on "Make TS recognize input arg name"
This PR allows TS schema_matching to match input arg with self for aten operators. This is because, operators in their functional form have input as paremeter instead of self. fixes: #71994 Differential Revision: [D34427556](https://our.internmc.facebook.com/intern/diff/D34427556) [ghstack-poisoned]
2 parents 217b262 + cb90156 commit 15ded21

21 files changed

+745
-48
lines changed

aten/src/ATen/native/cuda/SummaryOps.cu

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ Tensor _bincount_cuda_template(
311311
weights.options().layout_opt(),
312312
weights.options().device_opt(),
313313
weights.options().pinned_memory_opt());
314-
auto ret = cuda::CUDA_tensor_histogram<weights_t, input_t, true>(
314+
cuda::CUDA_tensor_histogram<weights_t, input_t, true>(
315315
output, self, weights, nbins, minvalue, maxvalue);
316316
} else {
317317
output = native::zeros(
@@ -320,7 +320,7 @@ Tensor _bincount_cuda_template(
320320
c10::nullopt /* layout */,
321321
DeviceType::CUDA,
322322
c10::nullopt /* pin_memory */);
323-
auto ret = cuda::CUDA_tensor_histogram<int64_t, input_t, false>(
323+
cuda::CUDA_tensor_histogram<int64_t, input_t, false>(
324324
output, self, weights, nbins, minvalue, maxvalue);
325325
}
326326
return output;
@@ -374,7 +374,7 @@ Tensor _histc_cuda_template(
374374
#endif
375375
TORCH_CHECK(minvalue < maxvalue, "max must be larger than min");
376376
377-
auto ret = cuda::CUDA_tensor_histogram<input_t, input_t, false>(
377+
cuda::CUDA_tensor_histogram<input_t, input_t, false>(
378378
output, self, Tensor(), nbins, minvalue, maxvalue);
379379
return output;
380380
}

aten/src/ATen/native/cuda/UpSampleBilinear2d.cu

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,6 @@ C10_LAUNCH_BOUNDS_1(256) // 256 performs better then 1024
456456
__global__ void upsample_gen2d_aa_out_frame(
457457
const accscalar_t height_scale,
458458
const accscalar_t width_scale,
459-
const bool align_corners,
460459
const PackedTensorAccessor64<scalar_t, 4> idata,
461460
PackedTensorAccessor64<scalar_t, 4> odata,
462461
const InterpFilter & interp_filter) {
@@ -550,7 +549,6 @@ C10_LAUNCH_BOUNDS_1(256) // 256 performs better then 1024
550549
__global__ void upsample_gen2d_aa_backward_out_frame(
551550
const accscalar_t height_scale,
552551
const accscalar_t width_scale,
553-
const bool align_corners,
554552
PackedTensorAccessor64<scalar_t, 4> idata,
555553
const PackedTensorAccessor64<scalar_t, 4> odata,
556554
const InterpFilter & interp_filter) {
@@ -672,8 +670,6 @@ static void upsample_gen2d_aa_out_cuda_template(
672670
int output_height = output_size[0];
673671
int output_width = output_size[1];
674672

675-
int nbatch = input.size(0);
676-
int channels = input.size(1);
677673
int input_height = input.size(2);
678674
int input_width = input.size(3);
679675

@@ -735,7 +731,7 @@ static void upsample_gen2d_aa_out_cuda_template(
735731
<<<grid,
736732
block,
737733
shmem_size,
738-
stream>>>(height_scale, width_scale, align_corners, idata, odata, interp_filter);
734+
stream>>>(height_scale, width_scale, idata, odata, interp_filter);
739735
C10_CUDA_KERNEL_LAUNCH_CHECK();
740736
});
741737

@@ -766,8 +762,6 @@ static void upsample_gen2d_aa_backward_out_cuda_template(
766762
int output_height = output_size[0];
767763
int output_width = output_size[1];
768764

769-
int nbatch = input_size[0];
770-
int channels = input_size[1];
771765
int input_height = input_size[2];
772766
int input_width = input_size[3];
773767

@@ -819,7 +813,7 @@ static void upsample_gen2d_aa_backward_out_cuda_template(
819813
<<<grid,
820814
block,
821815
shmem_size,
822-
stream>>>(height_scale, width_scale, align_corners, idata, odata, interp_filter);
816+
stream>>>(height_scale, width_scale, idata, odata, interp_filter);
823817
C10_CUDA_KERNEL_LAUNCH_CHECK();
824818
});
825819
}

aten/src/ATen/native/native_functions.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1366,7 +1366,7 @@
13661366
device_guard: False
13671367
dispatch:
13681368
MkldnnCPU: copy_mkldnn_
1369-
SparseCPU, SparseCUDA, SparseHIP: copy_sparse_wrapper_
1369+
SparseCPU, SparseCUDA: copy_sparse_wrapper_
13701370
CompositeExplicitAutograd: copy_
13711371
SparseCsrCPU, SparseCsrCUDA: copy_sparse_csr_
13721372

caffe2/operators/elementwise_ops.cu

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ void device_reduce<at::Half>(
119119
int N,
120120
Tensor* buffer,
121121
CUDAContext* context) {
122+
(void)N; // Suppress unused variable warning
123+
(void)buffer; // Suppress unused variable warning
124+
(void)context; // Suppress unused variable warning
122125
#if TORCH_HIP_VERSION >= 210
123126
auto buffer_size = 1;
124127

test/cpp/api/functional.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2174,7 +2174,7 @@ TEST_F(FunctionalTest, Interpolate) {
21742174
}
21752175
}
21762176

2177-
TEST_F(FunctionalTest, Pad) {
2177+
TEST_F(FunctionalTest, Pad1) {
21782178
{
21792179
auto input = torch::arange(6, torch::kDouble).reshape({1, 2, 3});
21802180
auto output = F::pad(input, F::PadFuncOptions({1, 2}).mode(torch::kCircular));
@@ -2183,6 +2183,8 @@ TEST_F(FunctionalTest, Pad) {
21832183
ASSERT_EQ(output.sizes(), std::vector<int64_t>({1, 2, 6}));
21842184
ASSERT_TRUE(output.allclose(expected, 1e-04));
21852185
}
2186+
}
2187+
TEST_F(FunctionalTest, Pad2) {
21862188
{
21872189
auto input = torch::arange(9, torch::kDouble).reshape({1, 1, 3, 3});
21882190
auto output = F::pad(input, F::PadFuncOptions({3, 3, 3, 1}).mode(torch::kCircular));
@@ -2197,6 +2199,8 @@ TEST_F(FunctionalTest, Pad) {
21972199
ASSERT_EQ(output.sizes(), std::vector<int64_t>({1, 1, 7, 9}));
21982200
ASSERT_TRUE(output.allclose(expected, 1e-04));
21992201
}
2202+
}
2203+
TEST_F(FunctionalTest, Pad3) {
22002204
{
22012205
auto input = torch::arange(12, torch::kDouble).reshape({1, 1, 2, 2, 3});
22022206
auto output = F::pad(input, F::PadFuncOptions({3, 3, 2, 1, 2, 2}).mode(torch::kCircular));
@@ -2239,6 +2243,8 @@ TEST_F(FunctionalTest, Pad) {
22392243
ASSERT_EQ(output.sizes(), std::vector<int64_t>({1, 1, 6, 5, 9}));
22402244
ASSERT_TRUE(output.allclose(expected, 1e-04));
22412245
}
2246+
}
2247+
TEST_F(FunctionalTest, Pad4) {
22422248
{
22432249
auto input = torch::arange(16, torch::kDouble).reshape({2, 2, 2, 2});
22442250
auto output = F::pad(input, F::PadFuncOptions({1, 1, 1, 1}).mode(torch::kReflect));
@@ -2265,6 +2271,8 @@ TEST_F(FunctionalTest, Pad) {
22652271
ASSERT_EQ(output.sizes(), std::vector<int64_t>({2, 2, 4, 4}));
22662272
ASSERT_TRUE(output.allclose(expected, 1e-04));
22672273
}
2274+
}
2275+
TEST_F(FunctionalTest, Pad5) {
22682276
{
22692277
auto input = torch::arange(12, torch::kDouble).reshape({1, 1, 2, 2, 3});
22702278
auto output = F::pad(input, F::PadFuncOptions({1, 2, 2, 1, 1, 2}).mode(torch::kReplicate));
@@ -2301,6 +2309,8 @@ TEST_F(FunctionalTest, Pad) {
23012309
ASSERT_EQ(output.sizes(), std::vector<int64_t>({1, 1, 5, 5, 6}));
23022310
ASSERT_TRUE(output.allclose(expected, 1e-04));
23032311
}
2312+
}
2313+
TEST_F(FunctionalTest, Pad6) {
23042314
{
23052315
auto input = torch::arange(18, torch::kDouble).reshape({1, 1, 3, 2, 3});
23062316
auto output = F::pad(input, F::PadFuncOptions({0, 2, 1, 0, 1, 2}).mode(torch::kReflect));
@@ -2331,12 +2341,16 @@ TEST_F(FunctionalTest, Pad) {
23312341
ASSERT_EQ(output.sizes(), std::vector<int64_t>({1, 1, 6, 3, 5}));
23322342
ASSERT_TRUE(output.allclose(expected, 1e-04));
23332343
}
2344+
}
2345+
TEST_F(FunctionalTest, Pad7) {
23342346
{
23352347
auto input = torch::ones({1, 1, 1, 1}, torch::kDouble);
23362348
auto output = F::pad(input, F::PadFuncOptions({1, 1}).mode(torch::kConstant).value(0));
23372349
ASSERT_EQ(output.sizes(), std::vector<int64_t>({1, 1, 1, 3}));
23382350
auto expected = torch::tensor({{{{0., 1., 0.}}}}, torch::kDouble);
23392351
}
2352+
}
2353+
TEST_F(FunctionalTest, Pad8) {
23402354
{
23412355
auto input = torch::ones({1, 1, 1, 1}, torch::kDouble);
23422356
auto output = F::pad(input, F::PadFuncOptions({1, 1}));

test/onnx/test_pytorch_onnx_onnxruntime.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6308,6 +6308,16 @@ def forward(self, x):
63086308
x = torch.randn(4, 2, 3, requires_grad=True)
63096309
self.run_test(InplaceAddModel(), x)
63106310

6311+
def test_addcmul(self):
6312+
class AddcmulModel(torch.nn.Module):
6313+
def forward(self, x, t1, t2):
6314+
return torch.addcmul(x, t1, t2), torch.addcmul(x, t1, t2, value=2.2)
6315+
6316+
x = torch.randn(1, 3)
6317+
t1 = torch.randn(3, 1)
6318+
t2 = torch.randn(1, 3)
6319+
self.run_test(AddcmulModel(), (x, t1, t2))
6320+
63116321
def test_rsqrt(self):
63126322
class RsqrtModel(torch.nn.Module):
63136323
def forward(self, x):

test/run_test.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -821,6 +821,11 @@ def parse_args():
821821
" within a specified test module. For unspecified test modules with the bring-to-front "
822822
"option, all test cases will be run, as one may expect.",
823823
)
824+
parser.add_argument(
825+
"--dry-run",
826+
action="store_true",
827+
help="Only list the test that will run.",
828+
)
824829
return parser.parse_args()
825830

826831

@@ -1022,7 +1027,10 @@ def main():
10221027
selected_tests = get_selected_tests(options)
10231028

10241029
if options.verbose:
1025-
print_to_stderr("Selected tests: {}".format(", ".join(selected_tests)))
1030+
print_to_stderr("Selected tests:\n {}".format("\n ".join(selected_tests)))
1031+
1032+
if options.dry_run:
1033+
return
10261034

10271035
if options.coverage and not PYTORCH_COLLECT_COVERAGE:
10281036
shell(["coverage", "erase"])

0 commit comments

Comments
 (0)
0