Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finetune cfg tool #4050

Merged
merged 3 commits into from
Dec 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion oneflow/core/common/error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ Error Error::CompileOptionWrong() {

void ThrowError(const std::shared_ptr<cfg::ErrorProto>& error) {
*MutThreadLocalError() = error;
CHECK(error->has_error_type());
CHECK_NE(error->error_type_case(), cfg::ErrorProto::ERROR_TYPE_NOT_SET);
switch (error->error_type_case()) {
#define MAKE_ENTRY(cls) \
case cfg::ErrorProto::OF_PP_CAT(k, OF_PP_CAT(cls, Error)): \
Expand Down
5 changes: 3 additions & 2 deletions tools/cfg/template/template.cfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -295,14 +295,15 @@ class Const{{ util.class_name(cls) }} : public ::oneflow::cfg::Message {
{% endif %}{# field label type #}
{% endfor %}{# field #}
{% for oneof in util.message_type_oneofs(cls) %}
public:
{{ util.oneof_enum_name(oneof) }} {{ util.oneof_name(oneof) }}_case() const;

protected:
bool has_{{ util.oneof_name(oneof) }}() const;
{% endfor %}{# oneofs #}

public:
::std::shared_ptr<Const{{ util.class_name(cls) }}> __SharedConst__() const;
int64_t __Id__() const;
public:
bool operator==(const Const{{ util.class_name(cls) }}& other) const;

bool operator<(const Const{{ util.class_name(cls) }}& other) const;
Expand Down
2 changes: 0 additions & 2 deletions tools/cfg/template/template.cfg.pybind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ ONEFLOW_CFG_PYBIND11_MODULE("{{ util.module_get_python_module_path(module) }}",
{% endfor %}{# field #}
{% for oneof in util.message_type_oneofs(cls) %}
registry.def("{{ util.oneof_name(oneof) }}_case", &Const{{ util.class_name(cls) }}::{{ util.oneof_name(oneof) }}_case);
registry.def("has_{{ util.oneof_name(oneof) }}", &Const{{ util.class_name(cls) }}::has_{{ util.oneof_name(oneof) }});
registry.def_property_readonly_static("{{ util.oneof_name(oneof).upper() }}_NOT_SET",
[](const pybind11::object&){ return {{ util.module_package_cfg_namespace(module) }}::{{ util.class_name(cls) }}::{{ util.oneof_name(oneof).upper() }}_NOT_SET; })
{% for field in util.oneof_type_fields(oneof) %}
Expand Down Expand Up @@ -273,7 +272,6 @@ ONEFLOW_CFG_PYBIND11_MODULE("{{ util.module_get_python_module_path(module) }}",
{% endfor %}{# oneof_fields #}
;
registry.def("{{ util.oneof_name(oneof) }}_case", &{{ util.module_package_cfg_namespace(module) }}::{{ util.class_name(cls) }}::{{ util.oneof_name(oneof) }}_case);
registry.def("has_{{ util.oneof_name(oneof) }}", &{{ util.module_package_cfg_namespace(module) }}::{{ util.class_name(cls) }}::has_{{ util.oneof_name(oneof) }});
{% endfor %}{# oneofs #}
}
{% endif %}{# cls is not entry #}
Expand Down