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
4 changes: 3 additions & 1 deletion extension/pybindings/pybindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,9 @@ struct PyModule final {
} else if (py::isinstance<py::int_>(python_input)) {
cpp_inputs.push_back(EValue(py::cast<int64_t>(python_input)));
} else {
ET_ASSERT_UNREACHABLE_MSG("Unsupported pytype: %s", type_str.c_str());
throw std::runtime_error(
"Unsupported python type " + type_str +
". Ensure that inputs are passed as a flat list of tensors.");
}
}

Expand Down
11 changes: 11 additions & 0 deletions extension/pybindings/test/make_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,16 @@ def test_verification_config(tester) -> None:

tester.assertEqual(str(expected), str(executorch_output))

def test_unsupported_input_type(tester):
exported_program, inputs = create_program(ModuleAdd())
executorch_module = load_fn(exported_program.buffer)

# Pass an unsupported input type to the module.
inputs = ([*inputs],)

# This should raise a Python error, not hit a fatal assert in the C++ code.
tester.assertRaises(RuntimeError, executorch_module, inputs)

######### RUN TEST CASES #########
test_e2e(tester)
test_multiple_entry(tester)
Expand All @@ -479,5 +489,6 @@ def test_verification_config(tester) -> None:
test_method_meta(tester)
test_bad_name(tester)
test_verification_config(tester)
test_unsupported_input_type(tester)

return wrapper
Loading