File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed
packages/paddlejs-converter Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change 4242# 在转换过程中新生成的、需要添加到vars中的variable
4343appendedVarList = []
4444
45+ class ObjDict (dict ):
46+ """
47+ Makes a dictionary behave like an object,with attribute-style access.
48+ """
49+ def __getattr__ (self ,name ):
50+ try :
51+ return self [name ]
52+ except :
53+ raise AttributeError (name )
54+ def __setattr__ (self ,name ,value ):
55+ self [name ]= value
56+
4557def validateShape (shape , name ):
4658 """检验shape长度,超过4则截断"""
4759 if len (shape ) > 4 :
@@ -323,7 +335,7 @@ def appendConnectOp(fetch_targets):
323335
324336 # 从fetch_targets中提取输出算子信息
325337 for target in fetch_targets :
326- name = target [ ' name' ]
338+ name = target . name
327339 curVar = fluid .global_scope ().find_var (name )
328340 curTensor = np .array (curVar .get_tensor ())
329341 shape = list (curTensor .shape )
@@ -409,7 +421,8 @@ def convertToPaddleJSModel():
409421 for input , value in op ['inputs' ].items ():
410422 if len (value ) <= 0 :
411423 continue
412- cur = {'name' : value [0 ]}
424+ cur = ObjDict ()
425+ cur .name = value [0 ]
413426 inputNames .append (cur )
414427 targets = appendConnectOp (inputNames )
415428 # op['inputs'] = targets
You can’t perform that action at this time.
0 commit comments