Unverified Commit 11bc6104 authored by Shucai Xiao's avatar Shucai Xiao Committed by GitHub
Browse files

Segment fault c api (#490)



* fixed a bug in the cpp api for the case of zero input parameter

* clang format

* fixed clang format warning
Co-authored-by: default avatarPaul Fultz II <pfultz2@yahoo.com>
Co-authored-by: default avatarmvermeulen <5479696+mvermeulen@users.noreply.github.com>
parent bf6a3507
......@@ -344,7 +344,10 @@ struct program_parameter_shapes : MIGRAPHX_HANDLE_BASE(program_parameter_shapes)
std::vector<const char*> names() const
{
std::vector<const char*> result(this->size());
if(!result.empty())
{
call(&migraphx_program_parameter_shapes_names, result.data(), this->get_handle_ptr());
}
return result;
}
};
......
......@@ -22,4 +22,24 @@ TEST_CASE(load_and_run)
CHECK(bool{shapes_before.front() == outputs.front().get_shape()});
}
TEST_CASE(zero_parameter)
{
auto p = migraphx::parse_onnx("constant_fill_test.onnx");
auto shapes_before = p.get_output_shapes();
p.compile(migraphx::target("cpu"));
auto shapes_after = p.get_output_shapes();
CHECK(shapes_before.size() == 1);
CHECK(shapes_before.size() == shapes_after.size());
CHECK(bool{shapes_before.front() == shapes_after.front()});
migraphx::program_parameters pp;
auto param_shapes = p.get_parameter_shapes();
for(auto&& name : param_shapes.names())
{
pp.add(name, migraphx::argument::generate(param_shapes[name]));
}
auto outputs = p.eval(pp);
CHECK(shapes_before.size() == outputs.size());
CHECK(bool{shapes_before.front() == outputs.front().get_shape()});
}
int main(int argc, const char* argv[]) { test::run(argc, argv); }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment