@@ -6643,6 +6643,117 @@ public void TestInterpolateBilinear2D()
66436643 }
66446644 }
66456645
6646+ [ Fact ]
6647+ public void TestInterpolateBilinear2DNoAntialias ( )
6648+ {
6649+ foreach ( var device in TestUtils . AvailableDevices ( ) ) {
6650+ using Tensor input = torch . tensor ( rawArray : new float [ ] {
6651+ 1.0f , 0.0f , 0.0f , 1.0f , 0.0f , 0.0f , 1.0f , 0.0f , 0.0f ,
6652+ 1.0f , 0.0f , 0.0f , 1.0f , 0.0f , 0.0f , 1.0f , 0.0f , 0.0f ,
6653+ 1.0f , 0.0f , 0.0f , 1.0f , 0.0f , 0.0f , 1.0f , 0.0f , 0.0f ,
6654+ 0.0f , 1.0f , 0.0f , 0.0f , 1.0f , 0.0f , 0.0f , 1.0f , 0.0f ,
6655+ 0.0f , 1.0f , 0.0f , 0.0f , 1.0f , 0.0f , 0.0f , 1.0f , 0.0f ,
6656+ 0.0f , 1.0f , 0.0f , 0.0f , 1.0f , 0.0f , 0.0f , 1.0f , 0.0f ,
6657+ 0.0f , 0.0f , 1.0f , 0.0f , 0.0f , 1.0f , 0.0f , 0.0f , 1.0f ,
6658+ 0.0f , 0.0f , 1.0f , 0.0f , 0.0f , 1.0f , 0.0f , 0.0f , 1.0f ,
6659+ 0.0f , 0.0f , 1.0f , 0.0f , 0.0f , 1.0f , 0.0f , 0.0f , 1.0f
6660+ } , new long [ ] { 1 , 1 , 9 , 9 } , float32 , device : device ) ;
6661+ using var res = torch . nn . functional . interpolate ( input , new long [ ] { 6 , 6 } , mode : InterpolationMode . Bilinear , antialias : false ) ;
6662+ using Tensor expect = torch . tensor ( rawArray : new float [ ] {
6663+ 0.7500f , 0.0000f , 0.7500f , 0.0000f , 0.7500f , 0.0000f ,
6664+ 0.7500f , 0.0000f , 0.7500f , 0.0000f , 0.7500f , 0.0000f ,
6665+ 0.2500f , 0.2500f , 0.2500f , 0.2500f , 0.2500f , 0.2500f ,
6666+ 0.2500f , 0.2500f , 0.2500f , 0.2500f , 0.2500f , 0.2500f ,
6667+ 0.0000f , 0.7500f , 0.0000f , 0.7500f , 0.0000f , 0.7500f ,
6668+ 0.0000f , 0.7500f , 0.0000f , 0.7500f , 0.0000f , 0.7500f
6669+ } , new long [ ] { 1 , 1 , 6 , 6 } , float32 , device : device ) ;
6670+ Assert . True ( torch . allclose ( res , expect , rtol : 0.0 , atol : 1E-04 ) ) ;
6671+ }
6672+ }
6673+
6674+ [ Fact ]
6675+ public void TestInterpolateBilinear2DAntialias ( )
6676+ {
6677+ foreach ( var device in TestUtils . AvailableDevices ( ) ) {
6678+ using Tensor input = torch . tensor ( rawArray : new float [ ] {
6679+ 1.0f , 0.0f , 0.0f , 1.0f , 0.0f , 0.0f , 1.0f , 0.0f , 0.0f ,
6680+ 1.0f , 0.0f , 0.0f , 1.0f , 0.0f , 0.0f , 1.0f , 0.0f , 0.0f ,
6681+ 1.0f , 0.0f , 0.0f , 1.0f , 0.0f , 0.0f , 1.0f , 0.0f , 0.0f ,
6682+ 0.0f , 1.0f , 0.0f , 0.0f , 1.0f , 0.0f , 0.0f , 1.0f , 0.0f ,
6683+ 0.0f , 1.0f , 0.0f , 0.0f , 1.0f , 0.0f , 0.0f , 1.0f , 0.0f ,
6684+ 0.0f , 1.0f , 0.0f , 0.0f , 1.0f , 0.0f , 0.0f , 1.0f , 0.0f ,
6685+ 0.0f , 0.0f , 1.0f , 0.0f , 0.0f , 1.0f , 0.0f , 0.0f , 1.0f ,
6686+ 0.0f , 0.0f , 1.0f , 0.0f , 0.0f , 1.0f , 0.0f , 0.0f , 1.0f ,
6687+ 0.0f , 0.0f , 1.0f , 0.0f , 0.0f , 1.0f , 0.0f , 0.0f , 1.0f
6688+ } , new long [ ] { 1 , 1 , 9 , 9 } , float32 , device : device ) ;
6689+ using var res = torch . nn . functional . interpolate ( input , new long [ ] { 6 , 6 } , mode : InterpolationMode . Bilinear , antialias : true ) ;
6690+ using Tensor expect = torch . tensor ( rawArray : new float [ ] {
6691+ 0.6250f , 0.1111f , 0.5556f , 0.1111f , 0.5556f , 0.0000f ,
6692+ 0.5972f , 0.1358f , 0.5309f , 0.1358f , 0.5309f , 0.0417f ,
6693+ 0.4028f , 0.3086f , 0.3580f , 0.3086f , 0.3580f , 0.3333f ,
6694+ 0.3333f , 0.3580f , 0.3086f , 0.3580f , 0.3086f , 0.4028f ,
6695+ 0.0417f , 0.5309f , 0.1358f , 0.5309f , 0.1358f , 0.5972f ,
6696+ 0.0000f , 0.5556f , 0.1111f , 0.5556f , 0.1111f , 0.6250f
6697+ } , new long [ ] { 1 , 1 , 6 , 6 } , float32 , device : device ) ;
6698+ Assert . True ( torch . allclose ( res , expect , rtol : 0.0 , atol : 1E-04 ) ) ;
6699+ }
6700+ }
6701+
6702+ [ Fact ]
6703+ public void TestInterpolateBicubic2DNoAntialias ( )
6704+ {
6705+ foreach ( var device in TestUtils . AvailableDevices ( ) ) {
6706+ using Tensor input = torch . tensor ( rawArray : new float [ ] {
6707+ 1.0f , 0.0f , 0.0f , 1.0f , 0.0f , 0.0f , 1.0f , 0.0f , 0.0f ,
6708+ 1.0f , 0.0f , 0.0f , 1.0f , 0.0f , 0.0f , 1.0f , 0.0f , 0.0f ,
6709+ 1.0f , 0.0f , 0.0f , 1.0f , 0.0f , 0.0f , 1.0f , 0.0f , 0.0f ,
6710+ 0.0f , 1.0f , 0.0f , 0.0f , 1.0f , 0.0f , 0.0f , 1.0f , 0.0f ,
6711+ 0.0f , 1.0f , 0.0f , 0.0f , 1.0f , 0.0f , 0.0f , 1.0f , 0.0f ,
6712+ 0.0f , 1.0f , 0.0f , 0.0f , 1.0f , 0.0f , 0.0f , 1.0f , 0.0f ,
6713+ 0.0f , 0.0f , 1.0f , 0.0f , 0.0f , 1.0f , 0.0f , 0.0f , 1.0f ,
6714+ 0.0f , 0.0f , 1.0f , 0.0f , 0.0f , 1.0f , 0.0f , 0.0f , 1.0f ,
6715+ 0.0f , 0.0f , 1.0f , 0.0f , 0.0f , 1.0f , 0.0f , 0.0f , 1.0f
6716+ } , new long [ ] { 1 , 1 , 9 , 9 } , float32 , device : device ) ;
6717+ using var res = torch . nn . functional . interpolate ( input , new long [ ] { 6 , 6 } , mode : InterpolationMode . Bicubic , antialias : true ) ;
6718+ using Tensor expect = torch . tensor ( rawArray : new float [ ] {
6719+ 0.6493f , 0.0467f , 0.6196f , 0.0471f , 0.6226f , - 0.0440f ,
6720+ 0.6356f , 0.0619f , 0.6042f , 0.0624f , 0.6069f , - 0.0205f ,
6721+ 0.4083f , 0.3155f , 0.3487f , 0.3180f , 0.3464f , 0.3712f ,
6722+ 0.3712f , 0.3464f , 0.3180f , 0.3487f , 0.3155f , 0.4083f ,
6723+ - 0.0205f , 0.6069f , 0.0624f , 0.6042f , 0.0619f , 0.6356f ,
6724+ - 0.0440f , 0.6226f , 0.0471f , 0.6196f , 0.0467f , 0.6493f
6725+ } , new long [ ] { 1 , 1 , 6 , 6 } , float32 , device : device ) ;
6726+ Assert . True ( torch . allclose ( res , expect , rtol : 0.0 , atol : 1E-04 ) ) ;
6727+ }
6728+ }
6729+
6730+ [ Fact ]
6731+ public void TestInterpolateBicubic2DAntialias ( )
6732+ {
6733+ foreach ( var device in TestUtils . AvailableDevices ( ) ) {
6734+ using Tensor input = torch . tensor ( rawArray : new float [ ] {
6735+ 1.0f , 0.0f , 0.0f , 1.0f , 0.0f , 0.0f , 1.0f , 0.0f , 0.0f ,
6736+ 1.0f , 0.0f , 0.0f , 1.0f , 0.0f , 0.0f , 1.0f , 0.0f , 0.0f ,
6737+ 1.0f , 0.0f , 0.0f , 1.0f , 0.0f , 0.0f , 1.0f , 0.0f , 0.0f ,
6738+ 0.0f , 1.0f , 0.0f , 0.0f , 1.0f , 0.0f , 0.0f , 1.0f , 0.0f ,
6739+ 0.0f , 1.0f , 0.0f , 0.0f , 1.0f , 0.0f , 0.0f , 1.0f , 0.0f ,
6740+ 0.0f , 1.0f , 0.0f , 0.0f , 1.0f , 0.0f , 0.0f , 1.0f , 0.0f ,
6741+ 0.0f , 0.0f , 1.0f , 0.0f , 0.0f , 1.0f , 0.0f , 0.0f , 1.0f ,
6742+ 0.0f , 0.0f , 1.0f , 0.0f , 0.0f , 1.0f , 0.0f , 0.0f , 1.0f ,
6743+ 0.0f , 0.0f , 1.0f , 0.0f , 0.0f , 1.0f , 0.0f , 0.0f , 1.0f
6744+ } , new long [ ] { 1 , 1 , 9 , 9 } , float32 , device : device ) ;
6745+ using var res = torch . nn . functional . interpolate ( input , new long [ ] { 6 , 6 } , mode : InterpolationMode . Bicubic , antialias : false ) ;
6746+ using Tensor expect = torch . tensor ( rawArray : new float [ ] {
6747+ 0.7734f , - 0.1406f , 0.8789f , - 0.1406f , 0.8789f , - 0.0352f ,
6748+ 0.8274f , - 0.1831f , 0.9440f , - 0.1831f , 0.9440f , - 0.0665f ,
6749+ 0.2077f , 0.3042f , 0.1966f , 0.3042f , 0.1966f , 0.2930f ,
6750+ 0.2930f , 0.1966f , 0.3042f , 0.1966f , 0.3042f , 0.2077f ,
6751+ - 0.0665f , 0.9440f , - 0.1831f , 0.9440f , - 0.1831f , 0.8274f ,
6752+ - 0.0352f , 0.8789f , - 0.1406f , 0.8789f , - 0.1406f , 0.7734f
6753+ } , new long [ ] { 1 , 1 , 6 , 6 } , float32 , device : device ) ;
6754+ Assert . True ( torch . allclose ( res , expect , rtol : 0.0 , atol : 1E-04 ) ) ;
6755+ }
6756+ }
66466757
66476758 [ Fact ]
66486759 public void TestInterpolateArea ( )
0 commit comments