@@ -81,12 +81,21 @@ subroutine test_torch_tensor_zeros()
81
81
! Check that the tensor values are all zero
82
82
expected(:,:) = 0.0
83
83
test_pass = assert_allclose(out_data, expected, test_name="test_torch_tensor_zeros")
84
- @assertTrue(test_pass)
85
- @assertEqual(shape(out_data), shape(expected))
84
+ if (.not. test_pass) then
85
+ call clean_up()
86
+ print *, "Error :: incorrect output from torch_tensor_zeros subroutine"
87
+ stop 999
88
+ end if
86
89
87
- ! Cleanup
88
- nullify(out_data)
89
- call torch_tensor_delete(tensor)
90
+ call clean_up()
91
+
92
+ contains
93
+
94
+ ! Subroutine for freeing memory and nullifying pointers used in the unit test
95
+ subroutine clean_up()
96
+ nullify(out_data)
97
+ call torch_tensor_delete(tensor)
98
+ end subroutine clean_up
90
99
91
100
end subroutine test_torch_tensor_zeros
92
101
@@ -132,12 +141,21 @@ subroutine test_torch_tensor_ones()
132
141
! Check that the tensor values are all one
133
142
expected(:,:) = 1.0
134
143
test_pass = assert_allclose(out_data, expected, test_name="test_torch_tensor_ones")
135
- @assertTrue(test_pass)
136
- @assertEqual(shape(out_data), shape(expected))
144
+ if (.not. test_pass) then
145
+ call clean_up()
146
+ print *, "Error :: incorrect output from torch_tensor_ones subroutine"
147
+ stop 999
148
+ end if
137
149
138
- ! Cleanup
139
- nullify(out_data)
140
- call torch_tensor_delete(tensor)
150
+ call clean_up()
151
+
152
+ contains
153
+
154
+ ! Subroutine for freeing memory and nullifying pointers used in the unit test
155
+ subroutine clean_up()
156
+ nullify(out_data)
157
+ call torch_tensor_delete(tensor)
158
+ end subroutine clean_up
141
159
142
160
end subroutine test_torch_tensor_ones
143
161
@@ -184,12 +202,21 @@ subroutine test_torch_from_array_1d()
184
202
! Compare the data in the tensor to the input data
185
203
expected(:) = in_data
186
204
test_pass = assert_allclose(out_data, expected, test_name="test_torch_tensor_from_array")
187
- @assertTrue(test_pass)
188
- @assertEqual(shape(out_data), shape(expected))
205
+ if (.not. test_pass) then
206
+ call clean_up()
207
+ print *, "Error :: incorrect output from torch_tensor_from_array subroutine"
208
+ stop 999
209
+ end if
189
210
190
- ! Cleanup
191
- nullify(out_data)
192
- call torch_tensor_delete(tensor)
211
+ call clean_up()
212
+
213
+ contains
214
+
215
+ ! Subroutine for freeing memory and nullifying pointers used in the unit test
216
+ subroutine clean_up()
217
+ nullify(out_data)
218
+ call torch_tensor_delete(tensor)
219
+ end subroutine clean_up
193
220
194
221
end subroutine test_torch_from_array_1d
195
222
@@ -236,12 +263,21 @@ subroutine test_torch_from_array_2d()
236
263
! Compare the data in the tensor to the input data
237
264
expected(:,:) = in_data
238
265
test_pass = assert_allclose(out_data, expected, test_name="test_torch_tensor_from_array")
239
- @assertTrue(test_pass)
240
- @assertEqual(shape(out_data), shape(expected))
266
+ if (.not. test_pass) then
267
+ call clean_up()
268
+ print *, "Error :: incorrect output from torch_tensor_from_array subroutine"
269
+ stop 999
270
+ end if
241
271
242
- ! Cleanup
243
- nullify(out_data)
244
- call torch_tensor_delete(tensor)
272
+ call clean_up()
273
+
274
+ contains
275
+
276
+ ! Subroutine for freeing memory and nullifying pointers used in the unit test
277
+ subroutine clean_up()
278
+ nullify(out_data)
279
+ call torch_tensor_delete(tensor)
280
+ end subroutine clean_up
245
281
246
282
end subroutine test_torch_from_array_2d
247
283
@@ -286,12 +322,21 @@ subroutine test_torch_from_array_3d()
286
322
! Compare the data in the tensor to the input data
287
323
expected(:,:,:) = in_data
288
324
test_pass = assert_allclose(out_data, expected, test_name="test_torch_tensor_from_array")
289
- @assertTrue(test_pass)
290
- @assertEqual(shape(out_data), shape(expected))
325
+ if (.not. test_pass) then
326
+ call clean_up()
327
+ print *, "Error :: incorrect output from torch_tensor_from_array subroutine"
328
+ stop 999
329
+ end if
291
330
292
- ! Cleanup
293
- nullify(out_data)
294
- call torch_tensor_delete(tensor)
331
+ call clean_up()
332
+
333
+ contains
334
+
335
+ ! Subroutine for freeing memory and nullifying pointers used in the unit test
336
+ subroutine clean_up()
337
+ nullify(out_data)
338
+ call torch_tensor_delete(tensor)
339
+ end subroutine clean_up
295
340
296
341
end subroutine test_torch_from_array_3d
297
342
@@ -340,11 +385,20 @@ subroutine test_torch_from_blob()
340
385
! Compare the data in the tensor to the input data
341
386
expected(:,:) = in_data
342
387
test_pass = assert_allclose(out_data, expected, test_name="test_torch_tensor_from_blob")
343
- @assertTrue(test_pass)
344
- @assertEqual(shape(out_data), shape(expected))
388
+ if (.not. test_pass) then
389
+ call clean_up()
390
+ print *, "Error :: incorrect output from torch_tensor_from_array subroutine"
391
+ stop 999
392
+ end if
345
393
346
- ! Cleanup
347
- nullify(out_data)
348
- call torch_tensor_delete(tensor)
394
+ call clean_up()
395
+
396
+ contains
397
+
398
+ ! Subroutine for freeing memory and nullifying pointers used in the unit test
399
+ subroutine clean_up()
400
+ nullify(out_data)
401
+ call torch_tensor_delete(tensor)
402
+ end subroutine clean_up
349
403
350
404
end subroutine test_torch_from_blob
0 commit comments