diff --git a/mace/python/tools/mace_engine_factory_codegen.py b/mace/python/tools/mace_engine_factory_codegen.py index ce91006506cecc14d2838a880f5c5398e8676886..5518deb34afb1a5201fe037220535b7b0577b6cb 100644 --- a/mace/python/tools/mace_engine_factory_codegen.py +++ b/mace/python/tools/mace_engine_factory_codegen.py @@ -27,9 +27,10 @@ def gen_mace_engine_factory(model_tags, template_dir, loader=FileSystemLoader(template_dir), trim_blocks=True) # generate mace_run BUILD file template_name = 'mace_engine_factory.h.jinja2' + model_tags = list(model_tags) source = j2_env.get_template(template_name).render( model_tags=model_tags, embed_model_data=embed_model_data, ) - with open(output_dir + '/mace_engine_factory.h', "wb") as f: + with open(output_dir + '/mace_engine_factory.h', "w") as f: f.write(source) diff --git a/mace/python/tools/model_saver.py b/mace/python/tools/model_saver.py index 56709ef69c4b65b7c45f93fa4587472fad245115..117bb8ef60a1481ae55613e90146fa57faced977 100644 --- a/mace/python/tools/model_saver.py +++ b/mace/python/tools/model_saver.py @@ -216,7 +216,7 @@ def save_model_to_code(net_def, model_tag, runtime, tensor=tensor, tag=model_tag, ) - with open(output_dir + 'tensor' + str(counter) + '.cc', "wb") as f: + with open(output_dir + 'tensor' + str(counter) + '.cc', "w") as f: f.write(source) counter += 1 @@ -228,7 +228,7 @@ def save_model_to_code(net_def, model_tag, runtime, tag=model_tag, model_data_size=len(model_data), model_data=model_data) - with open(output_dir + 'tensor_data' + '.cc', "wb") as f: + with open(output_dir + 'tensor_data' + '.cc', "w") as f: f.write(source) # generate op source files @@ -243,7 +243,7 @@ def save_model_to_code(net_def, model_tag, runtime, tag=model_tag, runtime=runtime, ) - with open(output_dir + 'op' + str(counter) + '.cc', "wb") as f: + with open(output_dir + 'op' + str(counter) + '.cc', "w") as f: f.write(source) counter += 1 @@ -262,13 +262,13 @@ def save_model_to_code(net_def, model_tag, runtime, winograd_conv=winograd_conv, checksum=checksum, build_time=build_time) - with open(output_dir + 'model.cc', "wb") as f: + with open(output_dir + 'model.cc', "w") as f: f.write(source) # generate model header file template_name = 'model_header.jinja2' source = j2_env.get_template(template_name).render(tag=model_tag, ) - with open(output_dir + model_tag + '.h', "wb") as f: + with open(output_dir + model_tag + '.h', "w") as f: f.write(source) diff --git a/mace/python/tools/operator.jinja2 b/mace/python/tools/operator.jinja2 index fc77b1e67aedbd34513442870b910c9332c8786d..e3492ddf7f112fef067c1b51ef7ba83b3065711d 100644 --- a/mace/python/tools/operator.jinja2 +++ b/mace/python/tools/operator.jinja2 @@ -80,7 +80,7 @@ void CreateOperator{{i}}(mace::OperatorDef *op) { arg->set_i({{ arg.i }}); {%- endif %} {%- if arg.HasField('s') %} - arg->set_s({{ arg.s|tojson }}); + arg->set_s({{ arg.s.decode('utf-8')|tojson }}); {%- endif %} arg->mutable_floats()->Reserve({{ arg.floats|length }}); @@ -161,4 +161,3 @@ void CreateOperator{{i}}(mace::OperatorDef *op) { } // namespace {{tag}} } // namespace mace -