Browse Source

parse attrs

tags/20180129
nihui 8 years ago
parent
commit
80d14dd252
1 changed files with 16 additions and 0 deletions
  1. +16
    -0
      tools/mxnet/mxnet2ncnn.cpp

+ 16
- 0
tools/mxnet/mxnet2ncnn.cpp View File

@@ -377,6 +377,15 @@ static bool read_mxnet_json(const char* jsonpath, std::vector<MXNetNode>& nodes)
continue;
}

// "attrs": {"__init__": "[\"zero\", {}]"},
nscan = sscanf(line, " \"attrs\": {\"%255[^\"]\": \"%255[^\"]\"}", key, value);
if (nscan == 2)
{
n.attrs[key] = value;
// fprintf(stderr, "# %s = %s\n", key, value);
continue;
}

// "param": {"p": "0.5"},
nscan = sscanf(line, " \"param\": {\"%255[^\"]\": \"%255[^\"]\"}", key, value);
if (nscan == 2)
@@ -393,6 +402,13 @@ static bool read_mxnet_json(const char* jsonpath, std::vector<MXNetNode>& nodes)
continue;
}

// "attrs": {
if (memcmp(line, " \"attrs\": {", 15) == 0)
{
in_attr_block = true;
continue;
}

// "param": {
if (memcmp(line, " \"param\": {", 16) == 0)
{


Loading…
Cancel
Save