Commit ead6317d authored by Umang Yadav's avatar Umang Yadav Committed by Chris Austen
Browse files

Change the doc to mention only gpu or ref as targets (#1153)

Documentation update for valid targets
parent cd0a4aa5
...@@ -121,7 +121,7 @@ target ...@@ -121,7 +121,7 @@ target
Constructs the target. Constructs the target.
:param str name: The name of the target to construct. This can either be 'cpu' or 'gpu'. :param str name: The name of the target to construct. This can either be 'gpu' or 'ref'.
:rtype: target :rtype: target
......
#include <migraphx/register_target.hpp>
#include <unordered_map> #include <unordered_map>
#include <migraphx/register_target.hpp>
namespace migraphx { namespace migraphx {
inline namespace MIGRAPHX_INLINE_NS { inline namespace MIGRAPHX_INLINE_NS {
...@@ -11,7 +11,17 @@ std::unordered_map<std::string, target>& target_map() ...@@ -11,7 +11,17 @@ std::unordered_map<std::string, target>& target_map()
} }
void register_target(const target& t) { target_map()[t.name()] = t; } void register_target(const target& t) { target_map()[t.name()] = t; }
target make_target(const std::string& name) { return target_map().at(name); }
target make_target(const std::string& name)
{
const auto it = target_map().find(name);
if(it == target_map().end())
{
MIGRAPHX_THROW("Requested target '" + name + "' is not enabled or not supported");
}
return it->second;
}
std::vector<std::string> get_targets() std::vector<std::string> get_targets()
{ {
std::vector<std::string> result; std::vector<std::string> result;
......
...@@ -12,6 +12,11 @@ TEST_CASE(make_target) ...@@ -12,6 +12,11 @@ TEST_CASE(make_target)
} }
} }
TEST_CASE(make_invalid_target)
{
EXPECT(test::throws([&] { migraphx::make_target("mi100"); }));
}
TEST_CASE(targets) TEST_CASE(targets)
{ {
auto ts = migraphx::get_targets(); auto ts = migraphx::get_targets();
......
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