Skip to content

Refactoring and fixes minor bugs in light API #62

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

Merged
merged 9 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
fix minour bugs in light API
  • Loading branch information
xadupre committed Jan 9, 2024
commit a4dde572a81df9589b349b3ae4bceb457fafe074
16 changes: 16 additions & 0 deletions _unittests/ut_light_api/test_light_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,22 @@ def ah(self):
expected = (a > 0).astype(int).astype(np.float32).reshape((-1, 1))
self.assertEqualArray(expected, got)

def test_input_shape(self):
kernel = (np.arange(9) + 1).reshape(3, 3).astype(np.float32)
model = (
start()
.vin("X", shape=[None, None])
.cst(kernel[np.newaxis, np.newaxis, ...])
.rename("W")
.bring("X", "W")
.Conv(pads=[1, 1, 1, 1])
.rename("Y")
.vout()
.to_onnx()
)
i = str(model.graph.input[0]).replace("\n", "").replace(" ", "")
self.assertNotIn("shape{}", i)


if __name__ == "__main__":
TestLightApi().test_domain()
Expand Down
3 changes: 3 additions & 0 deletions onnx_array_api/graph_api/graph_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,9 @@ def _build_initializers(self) -> List[TensorProto]:
t = onh.from_array(v, name=k)
res.append(t)
continue
if isinstance(v, TensorProto):
res.append(v)
continue
raise TypeError(
f"Unable to convert initializer {k!r} with type "
f"{type(v)} into a TensorProto."
Expand Down
24 changes: 11 additions & 13 deletions onnx_array_api/light_api/_op_vars.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,17 @@ def Conv(
pads: Optional[List[int]] = None,
strides: Optional[List[int]] = None,
) -> "Var":
dilations = dilations or []
kernel_shape = kernel_shape or []
pads = pads or []
strides = strides or []
return self.make_node(
"Conv",
*self.vars_,
auto_pad=auto_pad,
dilations=dilations,
group=group,
kernel_shape=kernel_shape,
pads=pads,
strides=strides,
kwargs = {}
if dilations is not None:
kwargs["dilations"] = dilations
if kernel_shape is not None:
kwargs["kernel_shape"] = kernel_shape
if pads is not None:
kwargs["pads"] = pads
if strides is not None:
kwargs["strides"] = strides
return self.make_node(
"Conv", *self.vars_, auto_pad=auto_pad, group=group, **kwargs
)

def ConvInteger(
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy