mirror of
https://github.com/pytorch/pytorch.git
synced 2026-11-20 09:04:25 +08:00
[C++ API] Added missing nearest-exact mode and anti-alias flag (#69318)
Summary: Description: Following https://github.com/pytorch/pytorch/pull/65142#issuecomment-981995692 adding missing nearest-exact mode and anti-alias flag to C++ frontend. - https://github.com/pytorch/pytorch/pull/65142 - https://github.com/pytorch/pytorch/pull/64501 - added tests in pytorch/test/cpp/api/functional.cpp Pull Request resolved: https://github.com/pytorch/pytorch/pull/69318 Reviewed By: davidberard98 Differential Revision: D33278995 Pulled By: jbschlosser fbshipit-source-id: fa87c0c78df6b398e4f9688cc02111eed187afa7
This commit is contained in:
committed by
Facebook GitHub Bot
parent
da63f3f92b
commit
ce9a2f8ba9
@@ -2138,6 +2138,33 @@ TEST_F(FunctionalTest, Interpolate) {
|
||||
"align_corners option can only be set with the "
|
||||
"interpolating modes: linear | bilinear | bicubic | trilinear");
|
||||
}
|
||||
{
|
||||
auto tensor = torch::rand({2, 3, 32, 32});
|
||||
std::vector<int64_t> osize = {8, 10};
|
||||
auto expected = at::native::_upsample_nearest_exact2d(tensor, osize, torch::nullopt);
|
||||
|
||||
auto options = F::InterpolateFuncOptions()
|
||||
.size(osize)
|
||||
.mode(torch::kNearestExact)
|
||||
.align_corners(false);
|
||||
auto output = F::interpolate(tensor, options);
|
||||
|
||||
ASSERT_TRUE(output.allclose(expected));
|
||||
}
|
||||
{
|
||||
auto tensor = torch::rand({2, 3, 32, 32});
|
||||
std::vector<int64_t> osize = {8, 10};
|
||||
auto expected = at::native::_upsample_bilinear2d_aa(tensor, osize, false, torch::nullopt);
|
||||
|
||||
auto options = F::InterpolateFuncOptions()
|
||||
.size(osize)
|
||||
.mode(torch::kBilinear)
|
||||
.align_corners(false)
|
||||
.antialias(true);
|
||||
auto output = F::interpolate(tensor, options);
|
||||
ASSERT_TRUE(output.allclose(expected));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(FunctionalTest, Pad) {
|
||||
|
||||
Reference in New Issue
Block a user