Skip to content

Commit

Permalink
Change the doc to mention only gpu or ref as targets (#1153)
Browse files Browse the repository at this point in the history
Documentation update for valid targets
  • Loading branch information
umangyadav authored and causten committed Mar 31, 2022
1 parent cd0a4aa commit ead6317
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion doc/src/reference/py.rst
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ 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

Expand Down
14 changes: 12 additions & 2 deletions src/register_target.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <migraphx/register_target.hpp>
#include <unordered_map>
#include <migraphx/register_target.hpp>

namespace migraphx {
inline namespace MIGRAPHX_INLINE_NS {
Expand All @@ -11,7 +11,17 @@ std::unordered_map<std::string, target>& target_map()
}

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> result;
Expand Down
5 changes: 5 additions & 0 deletions test/targets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ TEST_CASE(make_target)
}
}

TEST_CASE(make_invalid_target)
{
EXPECT(test::throws([&] { migraphx::make_target("mi100"); }));
}

TEST_CASE(targets)
{
auto ts = migraphx::get_targets();
Expand Down

0 comments on commit ead6317

Please sign in to comment.