Skip to content

Commit 41ecffe

Browse files
committed
Test data for half pixel NN resize from ONNX
1 parent 847035e commit 41ecffe

File tree

4 files changed

+7
-1
lines changed

4 files changed

+7
-1
lines changed
Binary file not shown.
Binary file not shown.

testdata/dnn/onnx/generate_onnx_models.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2440,7 +2440,7 @@ def save_data_and_tf_function(tf_function, name, input):
24402440
np.save(os.path.join("data", "output_" + name + ".npy"), output)
24412441
cumsum_model = tf2onnx.convert.from_function(
24422442
function=tf_function,
2443-
input_signature=[tf.TensorSpec([], tf.float32)],
2443+
input_signature=[tf.TensorSpec(input.shape, tf.float32)],
24442444
opset=14)[0]
24452445
onnx.save(cumsum_model, os.path.join("models", name + ".onnx"))
24462446

@@ -2966,3 +2966,9 @@ def make_node_with_constant(op_type, constant_value, inputs=None, outputs=None,
29662966
np.save(input_files, input.data)
29672967
output_files = os.path.join("data", "output_" + name)
29682968
np.save(output_files, np.ascontiguousarray(output.data))
2969+
2970+
## tf_half_pixel_for_nn
2971+
@tf.function
2972+
def tf_resize_nearest(x):
2973+
return tf.compat.v1.image.resize_nearest_neighbor(x, size=(5, 6), align_corners=False, half_pixel_centers=True)
2974+
save_data_and_tf_function(tf_resize_nearest, "tf_half_pixel_for_nn", np.random.rand(1, 2, 3, 2))
954 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)