Skip to content

Commit ead6317

Browse files
umangyadavcausten
authored andcommitted
Change the doc to mention only gpu or ref as targets (#1153)
Documentation update for valid targets
1 parent cd0a4aa commit ead6317

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

doc/src/reference/py.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ target
121121
122122
Constructs the target.
123123

124-
:param str name: The name of the target to construct. This can either be 'cpu' or 'gpu'.
124+
:param str name: The name of the target to construct. This can either be 'gpu' or 'ref'.
125125

126126
:rtype: target
127127

src/register_target.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#include <migraphx/register_target.hpp>
21
#include <unordered_map>
2+
#include <migraphx/register_target.hpp>
33

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

1313
void register_target(const target& t) { target_map()[t.name()] = t; }
14-
target make_target(const std::string& name) { return target_map().at(name); }
14+
15+
target make_target(const std::string& name)
16+
{
17+
const auto it = target_map().find(name);
18+
if(it == target_map().end())
19+
{
20+
MIGRAPHX_THROW("Requested target '" + name + "' is not enabled or not supported");
21+
}
22+
return it->second;
23+
}
24+
1525
std::vector<std::string> get_targets()
1626
{
1727
std::vector<std::string> result;

test/targets.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ TEST_CASE(make_target)
1212
}
1313
}
1414

15+
TEST_CASE(make_invalid_target)
16+
{
17+
EXPECT(test::throws([&] { migraphx::make_target("mi100"); }));
18+
}
19+
1520
TEST_CASE(targets)
1621
{
1722
auto ts = migraphx::get_targets();

0 commit comments

Comments
 (0)