@@ -74,6 +74,8 @@ def get_nodeattr(self, name):
7474 if dtype == "s" :
7575 # decode string attributes
7676 ret = ret .decode ("utf-8" )
77+ elif dtype == "strings" :
78+ ret = [x .decode ("utf-8" ) for x in ret ]
7779 elif dtype == "t" :
7880 # use numpy helper to convert TensorProto -> np array
7981 ret = np_helper .to_array (ret )
@@ -123,13 +125,15 @@ def set_nodeattr(self, name, value):
123125 # encode string attributes
124126 value = value .encode ("utf-8" )
125127 attr .__setattr__ (dtype , value )
128+ elif dtype == "strings" :
129+ attr .strings [:] = [x .encode ("utf-8" ) for x in value ]
126130 elif dtype == "floats" : # list of floats
127131 attr .floats [:] = value
128132 elif dtype == "ints" : # list of integers
129133 attr .ints [:] = value
130134 elif dtype == "t" : # single tensor
131135 attr .t .CopyFrom (value )
132- elif dtype in ["strings" , " tensors" , "graphs" , "sparse_tensors" ]:
136+ elif dtype in ["tensors" , "graphs" , "sparse_tensors" ]:
133137 # untested / unsupported attribute types
134138 # add testcases & appropriate getters before enabling
135139 raise Exception ("Attribute type %s not yet supported" % dtype )
0 commit comments