Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ def no_op_placeholder_for_execute_engine(
serialized_require_output_allocator: str,
serialized_resource_allocation_strategy: str,
serialized_requires_native_multidevice: str,
serialized_aliased_io: str,
) -> List[torch.Tensor]:
raise RuntimeError(
"The saved model is cross compiled for windows in Linux, should only be loadded in Windows via torch_tensorrt.load_cross_compiled_exported_program() api."
Expand All @@ -342,6 +343,7 @@ def fake_no_op_placeholder_for_execute_engine(
serialized_require_output_allocator: str,
serialized_resource_allocation_strategy: str,
serialized_requires_native_multidevice: str,
serialized_aliased_io: str,
) -> List[torch.Tensor]:
"""Fake kernel for no_op_placeholder_for_execute_engine.

Expand Down
29 changes: 29 additions & 0 deletions tests/py/dynamo/executorch/test_backend.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import ast
from pathlib import Path
from types import SimpleNamespace

import pytest
Expand All @@ -7,6 +9,7 @@
import torch # noqa: E402
from torch.export.graph_signature import InputKind # noqa: E402
from torch_tensorrt.dynamo.runtime._TorchTensorRTModule import ( # noqa: E402
ALIASED_IO_IDX,
DEVICE_IDX,
ENGINE_IDX,
INPUT_BINDING_NAMES_IDX,
Expand Down Expand Up @@ -109,6 +112,32 @@ def _engine_tensor(payload: bytes) -> torch.Tensor:
return torch.frombuffer(bytearray(payload), dtype=torch.uint8)


@pytest.mark.unit
def test_no_op_placeholder_schema_matches_serialized_engine_layout():
meta_ops_path = (
Path(__file__).parents[4]
/ "py/torch_tensorrt/dynamo/runtime/meta_ops/register_meta_ops.py"
)
module = ast.parse(meta_ops_path.read_text())
signatures = {
node.name: [arg.arg for arg in node.args.args]
for node in module.body
if isinstance(node, ast.FunctionDef)
and node.name
in {
"no_op_placeholder_for_execute_engine",
"fake_no_op_placeholder_for_execute_engine",
}
}

expected_arg_count = SERIALIZATION_LEN + 1
for args in signatures.values():
assert len(args) == expected_arg_count
assert args[ALIASED_IO_IDX + 1] == "serialized_aliased_io"
assert len(signatures) == 2
assert len({tuple(args) for args in signatures.values()}) == 1


@pytest.mark.unit
def test_get_engine_info_rejects_multiple_engine_nodes():
engine_info = [""] * SERIALIZATION_LEN
Expand Down
Loading