Skip to content

Commit

Permalink
[tools/circle_plus_gen] Fix type bug (#13262)
Browse files Browse the repository at this point in the history
Before
  *  `m.name` is sometimes `bytes`(when reading it from file) and sometimes `string`(set it from json file).
  * This problem sometimes makes an error message
 	 * `AttributeError: 'str' object has no attribute 'decode'`

After
  * `m.name` always bytes type

ONE-DCO-1.0-Signed-off-by: seunghui youn <[email protected]>
  • Loading branch information
zetwhite authored Jun 24, 2024
1 parent 776eb25 commit 0394aaa
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tools/circle_plus_gen/lib/circle_plus.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def _not_none(elem, elem_name=""):

class CirclePlus():
''' Wrapper class of circle_schema_generated.ModelT'''
TINFO_META_TAG = "CIRCLE_TRAINING"
TINFO_META_TAG = b"CIRCLE_TRAINING"
CIRCLE_IDENTIFIER = b"CIR0"

def __init__(self):
Expand All @@ -37,7 +37,7 @@ def get_train_param(self) -> typing.Union[TrainParam, None]:
return None

for m in metadata:
if m.name.decode("utf-8") == self.TINFO_META_TAG:
if m.name == self.TINFO_META_TAG:
buff: cir_gen.BufferT = buffers[m.buffer]
tparam: TrainParam = TrainParam.from_buff(buff.data)
return tparam
Expand All @@ -51,7 +51,7 @@ def _add_metadata(self, meta_name, meta_buf):
# If there are train_param, Replace it
if self.get_train_param() is not None:
for m in self.model.metadata:
if m.name.decode("utf-8") == self.TINFO_META_TAG:
if m.name == self.TINFO_META_TAG:
self.model.buffers[m.buffer] = buffer_obj

# There are no train_param, So add a new buffer and metadata
Expand Down

0 comments on commit 0394aaa

Please sign in to comment.