From c0d41a608c326605dac5b37af5ce3e8261eb7752 Mon Sep 17 00:00:00 2001 From: xiebaiyuan Date: Tue, 18 Sep 2018 17:39:19 +0800 Subject: [PATCH] add vars --- python/tools/mdl2fluid/mdl2fluid.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/python/tools/mdl2fluid/mdl2fluid.py b/python/tools/mdl2fluid/mdl2fluid.py index d6a1f1cfd9..f9805f603d 100644 --- a/python/tools/mdl2fluid/mdl2fluid.py +++ b/python/tools/mdl2fluid/mdl2fluid.py @@ -30,6 +30,7 @@ class Converter: block_desc.idx = 0 block_desc.parent_idx = -1 self.package_ops(block_desc) + self.package_vars(block_desc) print 'blocks: ' print self.program_desc.blocks @@ -229,6 +230,20 @@ class Converter: # print mdl2fluid_op_layer_dict.get(l_type) desc_ops_add.type = types.mdl2fluid_op_layer_dict.get(l_type) + def package_vars(self, block_desc): + json_matrix_ = self.mdl_json['matrix'] + # print json_matrix_ + for j in json_matrix_: + vars_add = block_desc.vars.add() + vars_add.name = j + vars_add.type.type = 7 # 7 is lodtensor + # print j + tensor = vars_add.type.lod_tensor.tensor + tensor.data_type = 5 # 5 is FP32 + for dims in json_matrix_.get(j): + tensor.dims.append(dims) + pass + # print mdl_path # # model -- GitLab