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

catch python buffer unsupported types #3701

Merged
merged 5 commits into from
Dec 12, 2024
Merged
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 src/py/migraphx_py.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,13 @@
{
migraphx::shape::type_t t;
std::size_t n = 0;
// Unsupported pybuffer types lead to undefined behaviour when comparing with migraphx type enum

Check warning on line 266 in src/py/migraphx_py.cpp

View workflow job for this annotation

GitHub Actions / misspell

[misspell] src/py/migraphx_py.cpp#L266

"behaviour" is a misspelling of "behavior"
Raw output
./src/py/migraphx_py.cpp:266:52: "behaviour" is a misspelling of "behavior"
if(info.format == "z")
{
MIGRAPHX_THROW(
"MIGRAPHX PYTHON: Unsupported data type. For fp8 and bf16 literals try using "
"migraphx.generate_argument with migraphx.add_literal");
}
visit_types([&](auto as) {
if(info.format == py::format_descriptor<decltype(as())>::format() or
(info.format == "l" and py::format_descriptor<decltype(as())>::format() == "q") or
Expand Down Expand Up @@ -388,6 +395,12 @@
py::arg("op"),
py::arg("args"),
py::arg("mod_args") = std::vector<migraphx::module*>{})
.def(
"add_literal",
[](migraphx::module& mm, migraphx::argument a) {
return mm.add_literal(a.get_shape(), a.data());
},
py::arg("data"))
.def(
"add_literal",
[](migraphx::module& mm, py::buffer data) {
Expand Down
Loading