@ -570,25 +570,14 @@ class TestTrilinearInterp_attr_tensor_Case3(TestTrilinearInterpOp_attr_tensor):
class TestTrilinearInterpAPI ( OpTest ) :
class TestTrilinearInterpAPI ( OpTest ) :
def test_case ( self ) :
def test_case ( self ) :
x = fluid . layers . data ( name = " x " , shape = [ 3 , 6 , 9 , 4 ] , dtype = " float32 " )
x = fluid . data ( name = " x " , shape = [ 2 , 3 , 6 , 9 , 4 ] , dtype = " float32 " )
y = fluid . layers . data ( name = " y " , shape = [ 6 , 9 , 4 , 3 ] , dtype = " float32 " )
y = fluid . data ( name = " y " , shape = [ 2 , 6 , 9 , 4 , 3 ] , dtype = " float32 " )
dim = fluid . layers . data ( name = " dim " , shape = [ 1 ] , dtype = " int32 " )
dim = fluid . data ( name = " dim " , shape = [ 1 ] , dtype = " int32 " )
shape_tensor = fluid . layers . data (
shape_tensor = fluid . data ( name = " shape_tensor " , shape = [ 3 ] , dtype = " int32 " )
name = " shape_tensor " ,
actual_size = fluid . data ( name = " actual_size " , shape = [ 3 ] , dtype = " int32 " )
shape = [ 3 ] ,
scale_tensor = fluid . data (
dtype = " int32 " ,
name = " scale_tensor " , shape = [ 1 ] , dtype = " float32 " )
append_batch_size = False )
actual_size = fluid . layers . data (
name = " actual_size " ,
shape = [ 3 ] ,
dtype = " int32 " ,
append_batch_size = False )
scale_tensor = fluid . layers . data (
name = " scale_tensor " ,
shape = [ 1 ] ,
dtype = " float32 " ,
append_batch_size = False )
out1 = fluid . layers . resize_trilinear (
out1 = fluid . layers . resize_trilinear (
y , out_shape = [ 12 , 18 , 8 ] , data_format = ' NDHWC ' )
y , out_shape = [ 12 , 18 , 8 ] , data_format = ' NDHWC ' )
@ -598,14 +587,18 @@ class TestTrilinearInterpAPI(OpTest):
x , out_shape = [ 4 , 4 , 8 ] , actual_shape = actual_size )
x , out_shape = [ 4 , 4 , 8 ] , actual_shape = actual_size )
out5 = fluid . layers . resize_trilinear ( x , scale = scale_tensor )
out5 = fluid . layers . resize_trilinear ( x , scale = scale_tensor )
x_data = np . random . random ( ( 1 , 3 , 6 , 9 , 4 ) ) . astype ( " float32 " )
x_data = np . random . random ( ( 2 , 3 , 6 , 9 , 4 ) ) . astype ( " float32 " )
dim_data = np . array ( [ 18 ] ) . astype ( " int32 " )
dim_data = np . array ( [ 18 ] ) . astype ( " int32 " )
shape_data = np . array ( [ 12 , 18 , 8 ] ) . astype ( " int32 " )
shape_data = np . array ( [ 12 , 18 , 8 ] ) . astype ( " int32 " )
actual_size_data = np . array ( [ 12 , 18 , 8 ] ) . astype ( " int32 " )
actual_size_data = np . array ( [ 12 , 18 , 8 ] ) . astype ( " int32 " )
scale_data = np . array ( [ 2.0 ] ) . astype ( " float32 " )
scale_data = np . array ( [ 2.0 ] ) . astype ( " float32 " )
if core . is_compiled_with_cuda ( ) :
place = core . CUDAPlace ( 0 )
else :
place = core . CPUPlace ( )
place = core . CPUPlace ( )
exe = fluid . Executor ( place )
exe = fluid . Executor ( place )
exe . run ( fluid . default_startup_program ( ) )
results = exe . run ( fluid . default_main_program ( ) ,
results = exe . run ( fluid . default_main_program ( ) ,
feed = {
feed = {
" x " : x_data ,
" x " : x_data ,
@ -628,8 +621,7 @@ class TestTrilinearInterpAPI(OpTest):
class TestTrilinearInterpOpException ( OpTest ) :
class TestTrilinearInterpOpException ( OpTest ) :
def test_exception ( self ) :
def test_exception ( self ) :
input = fluid . layers . data (
input = fluid . data ( name = " input " , shape = [ 2 , 3 , 6 , 9 , 4 ] , dtype = " float32 " )
name = " input " , shape = [ 3 , 6 , 9 , 4 ] , dtype = " float32 " )
def attr_data_format ( ) :
def attr_data_format ( ) :
# for 5-D input, data_format only can be NCDHW or NDHWC
# for 5-D input, data_format only can be NCDHW or NDHWC