Skip to content

Commit

Permalink
fix typo and move impl
Browse files Browse the repository at this point in the history
  • Loading branch information
yhmtsai committed May 17, 2024
1 parent 43e0a79 commit 3b4ca2e
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 29 deletions.
15 changes: 0 additions & 15 deletions core/config/config_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,6 @@ namespace gko {
namespace config {


type_descriptor update_type(const pnode& config, const type_descriptor& td)
{
auto value_typestr = td.get_value_typestr();
auto index_typestr = td.get_index_typestr();

if (auto& obj = config.get("value_type")) {
value_typestr = obj.get_string();
}
if (auto& obj = config.get("index_type")) {
index_typestr = obj.get_string();
}
return type_descriptor{value_typestr, index_typestr};
}


template <>
deferred_factory_parameter<const LinOpFactory> get_factory<const LinOpFactory>(
const pnode& config, const registry& context, const type_descriptor& td)
Expand Down
2 changes: 1 addition & 1 deletion core/config/config_helper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace config {


/**
* LinOpFactoryType enum is to avoid forward declartion, linopfactory header,
* LinOpFactoryType enum is to avoid forward declaration, linopfactory header,
* two template versions of parse
*/
enum class LinOpFactoryType : int { Cg = 0 };
Expand Down
15 changes: 15 additions & 0 deletions core/config/type_descriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,21 @@ namespace gko {
namespace config {


type_descriptor update_type(const pnode& config, const type_descriptor& td)
{
auto value_typestr = td.get_value_typestr();
auto index_typestr = td.get_index_typestr();

if (auto& obj = config.get("value_type")) {
value_typestr = obj.get_string();
}
if (auto& obj = config.get("index_type")) {
index_typestr = obj.get_string();
}
return type_descriptor{value_typestr, index_typestr};
}


template <typename ValueType, typename IndexType>
type_descriptor make_type_descriptor()
{
Expand Down
4 changes: 2 additions & 2 deletions core/test/config/type_descriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ using namespace gko::config;
TEST(TypeDescriptor, TemplateCreate)
{
{
SCOPED_TRACE("defaule template");
SCOPED_TRACE("default template");
auto td = make_type_descriptor<>();

ASSERT_EQ(td.get_value_typestr(), "float64");
Expand Down Expand Up @@ -51,7 +51,7 @@ TEST(TypeDescriptor, TemplateCreate)
TEST(TypeDescriptor, Constructor)
{
{
SCOPED_TRACE("defaule constructor");
SCOPED_TRACE("default constructor");
type_descriptor td;

ASSERT_EQ(td.get_value_typestr(), "float64");
Expand Down
6 changes: 3 additions & 3 deletions include/ginkgo/core/config/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class pnode;
* enum value. `"baseline": "absolute"` will select the absolute baseline in
* ResidualNorm critrion
* 4. `"type"` is the new key to select the class without template type. We also
* prepand the namespace except for gko. For example, we use "solver::Cg" for
* prepend the namespace except for gko. For example, we use "solver::Cg" for
* Cg solver. Note. the template type is given by the another entry or from
* the type_descriptor.
* 5. the data type uses fixed-width representation
Expand Down Expand Up @@ -89,8 +89,8 @@ class pnode;
* type_descriptor. For example:
* ```c++
* auto gmres_factory =
* build_from_config(config, context,
* make_type_descriptor<float32, int32>());
* parse(config, context,
* make_type_descriptor<float32, int32>());
* ```
* will lead to a GMRES solver that uses `float` as its value type.
* Additionally, the config can be used to set these types through the fields:
Expand Down
16 changes: 8 additions & 8 deletions include/ginkgo/core/config/registry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,27 +168,27 @@ class registry final {
* registry constructor
*
* @param additional_map the additional map to dispatch the class base.
* Users can extend this map to fit their own LinOpFactory.
* Users can extend map to fit their own
* LinOpFactory.
*/
registry(const configuration_map& additional_map = {});

/**
* registry constructor
*
* @param additional_map the additional map to dispatch the class base.
* Users can extend this map to fit their own LinOpFactory.
* @param stored_map the map stores the shared pointer of users' objects.
* It can hold any type whose base type is
* LinOp/LinOpFactory/CriterionFactory. For example,
* It can hold any type whose base type is
* LinOp/LinOpFactory/CriterionFactory.
* For example,
* ```
* {{
* {"csr", csr_shared_ptr},
* {"cg", cg_shared_ptr}
* }}
* ```
* @param build_map the build map to dispatch the class base. Ginkgo
* provides `generate_config_map()` in config.hpp to provide the ginkgo
* build map. Users can extend this map to fit their own LinOpFactory.
* @param additional_map the additional map to dispatch the class base.
* Users can extend map to fit their own
* LinOpFactory.
*/
registry(
const std::unordered_map<std::string, detail::allowed_ptr>& stored_map,
Expand Down

0 comments on commit 3b4ca2e

Please sign in to comment.