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

[In progress] Free nodes as they're parsed in program.from_value() #3749

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft
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 src/include/migraphx/program.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ struct MIGRAPHX_EXPORT program
void mark(const parameter_map& params, marker m);

value to_value() const;
void from_value(const value& v);
void from_value(value v);

void debug_print() const;
void debug_print(instruction_ref ins) const;
Expand Down
2 changes: 1 addition & 1 deletion src/include/migraphx/value.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ struct MIGRAPHX_EXPORT value
};

value() = default;

value(value&& rhs) = default;
value(const value& rhs);
value& operator=(value rhs);
value(const std::string& pkey, const value& rhs);
Expand Down
14 changes: 8 additions & 6 deletions src/program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -720,12 +720,12 @@
}

static void mod_from_val(module_ref mod,
const value& v,
value& v,
std::unordered_map<std::string, instruction_ref>& instructions,
const std::unordered_map<std::string, module_ref>& map_mods)
{
const auto& module_val = v.at(mod->name());
for(const value& node : module_val.at("nodes"))
auto& module_val = v.at(mod->name());
for(value& node : module_val.at("nodes"))
{
instruction_ref output;
auto name = node.at("name").to<std::string>();
Expand Down Expand Up @@ -764,7 +764,7 @@
std::back_inserter(module_inputs),
[&](const value& i) { return map_mods.at(i.to<std::string>()); });

for(const auto& smod : module_inputs)
for(auto& smod : module_inputs)

Check warning on line 767 in src/program.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

style: Variable 'smod' can be declared as reference to const [constVariableReference]
{
mod_from_val(smod, v, instructions, map_mods);
}
Expand All @@ -785,10 +785,12 @@
}
output->set_normalized(normalized);
instructions[node.at("output").to<std::string>()] = output;
node = nullptr;
}
module_val = nullptr;
}

void program::from_value(const value& v)
void program::from_value(value v)
{
auto version = v.at("version").to<int>();
if(version != program_file_version)
Expand Down Expand Up @@ -816,7 +818,7 @@
this->impl->contexts.back().from_value(v.at("contexts")[i]);
}

auto module_vals = v.at("modules");
auto& module_vals = v.at("modules");
for(const auto& vv : module_vals)
{
const auto& name = vv.get_key();
Expand Down
Loading