Skip to content
Draft
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
4 changes: 2 additions & 2 deletions backends/vulkan/serialization/vulkan_graph_serialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
VkGraph,
)
from executorch.exir._serialize._dataclass import _DataclassEncoder, _json_to_dataclass
from executorch.exir._serialize._flatbuffer import _flatc_compile, _flatc_decompile
from executorch.exir._serialize._flatbuffer import _flatc_decompile, _run_flatc


# Python's json module spells the non-finite floats "Infinity" / "-Infinity" /
Expand Down Expand Up @@ -110,7 +110,7 @@ def convert_to_flatbuffer(vk_graph: VkGraph) -> bytes:
json_path = os.path.join(d, "schema.json")
with open(json_path, "wb") as json_file:
json_file.write(vk_graph_json.encode("ascii"))
_flatc_compile(d, schema_path, json_path)
_run_flatc(["--binary", "--force-defaults", "-o", d, schema_path, json_path])
output_path = os.path.join(d, "schema.bin")
with open(output_path, "rb") as output_file:
return output_file.read()
Expand Down
8 changes: 8 additions & 0 deletions backends/vulkan/test/test_serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,14 @@ def test_serialize_deserialize_non_finite_scalars(self) -> None:
]
)

def test_serialize_deserialize_signed_zero(self) -> None:
values = [
VkValue(Double(-0.0)),
VkValue(Double(0.0)),
VkValue(DoubleList([-0.0, 0.0])),
]
self.assertEqual(repr(self._round_trip(values).values), repr(values))

def test_serialize_deserialize_non_finite_floats_in_list(self) -> None:
# json only emits a float as a chunk of its own inside an object; in a
# list the chunk carries the delimiter with it, so a rewrite that works
Expand Down
Loading