Browse Source

unique attribute identifier

tags/20220216
nihuini 4 years ago
parent
commit
c5efaf02b7
No known key found for this signature in database GPG Key ID: 98FD8F4EBC3E5DB8
1 changed files with 3 additions and 3 deletions
  1. +3
    -3
      tools/pnnx/src/ir.cpp

+ 3
- 3
tools/pnnx/src/ir.cpp View File

@@ -1341,11 +1341,11 @@ int Graph::python(const std::string& pypath, const std::string& pnnxbinpath)

if (is_running_mean_var)
{
fprintf(pyfp, " self.%s = self.load_pnnx_bin_as_tensor(archive, '%s.%s', (", key.c_str(), sanitize_identifier(op->name).c_str(), key.c_str());
fprintf(pyfp, " self.%s_%s = self.load_pnnx_bin_as_tensor(archive, '%s.%s', (", sanitize_identifier(op->name).c_str(), key.c_str(), sanitize_identifier(op->name).c_str(), key.c_str());
}
else
{
fprintf(pyfp, " self.%s = self.load_pnnx_bin_as_parameter(archive, '%s.%s', (", key.c_str(), sanitize_identifier(op->name).c_str(), key.c_str());
fprintf(pyfp, " self.%s_%s = self.load_pnnx_bin_as_parameter(archive, '%s.%s', (", sanitize_identifier(op->name).c_str(), key.c_str(), sanitize_identifier(op->name).c_str(), key.c_str());
}

for (size_t i = 0; i < attr.shape.size(); i++)
@@ -1420,7 +1420,7 @@ int Graph::python(const std::string& pypath, const std::string& pnnxbinpath)
else if (op->type == "pnnx.Attribute")
{
const std::string& key = op->attrs.begin()->first;
fprintf(pyfp, "v_%s = self.%s\n", sanitize_identifier(op->outputs[0]->name).c_str(), key.c_str());
fprintf(pyfp, "v_%s = self.%s_%s\n", sanitize_identifier(op->outputs[0]->name).c_str(), sanitize_identifier(op->name).c_str(), key.c_str());
}
else if (op->type == "Tensor.slice")
{


Loading…
Cancel
Save