Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix fill #303

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions onnx_tf/handlers/frontend/fill.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import numbers

import numpy as np

from onnx_tf.common import exception
Expand All @@ -12,6 +14,9 @@ class Fill(FrontendHandler):

@classmethod
def args_check(cls, node, **kwargs):
output_shape = node.attr["_output_shapes"][0]
for dim_size in output_shape:
assert isinstance(dim_size, numbers.Number)
if node.inputs[1] not in kwargs["consts"]:
exception.CONST_NOT_FOUND_EXCEPT(node.inputs[1], node.op_type)

Expand All @@ -20,3 +25,11 @@ def version_1(cls, node, **kwargs):
value = float(np.asscalar(kwargs["consts"][node.inputs[1]]))
return cls.make_node_from_tf_node(
node, [node.inputs[0]], input_as_shape=1, value=value)

@classmethod
def version_9(cls, node, **kwargs):
output_shape = node.attr["_output_shapes"][0]
value = float(np.asscalar(kwargs["consts"][node.inputs[1]]))
outputs = cls.get_outputs_names(node)
return cls.make_node_from_tf_node(
node, [], outputs, op_type="ConstantLike", shape=output_shape, value=value)
1 change: 1 addition & 0 deletions test/frontend/test_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ def do_test_expected(self):
("test_concat", tf.concat, "concat", [[get_rnd([1, 10]),get_rnd([10, 10]),get_rnd([20, 10])], 0], {}),
("test_bias_add_nchw", tf.nn.bias_add, "BiasAdd", [get_rnd([10, 32, 10, 10]),get_rnd([32])], {"data_format":"NCHW"}),
("test_bias_add_nhwc", tf.nn.bias_add, "BiasAdd", [get_rnd([10, 10, 10, 32]),get_rnd([32])], {"data_format":"NHWC"}),
("test_fill", tf.fill, "Fill", [[3, 10], 5], {}),
]

if not legacy_opset_pre_ver(6):
Expand Down