Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AUTOGEN] Add comment classes #267

Merged
merged 3 commits into from
Nov 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src_cpp/opennnBridge/worker_definitions_ag.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

// This file was auto generated
#define NERLPLANNER_VERSION "1.0.0"
// Generated by Nerlplanner version: 1.0.0

enum LayerTypeEnum{LAYER_TYPE_DEFAULT=0,LAYER_TYPE_SCALING=1,LAYER_TYPE_CNN=2,LAYER_TYPE_PERCEPTRON=3,LAYER_TYPE_POOLING=4,LAYER_TYPE_PROBABILISTIC=5,LAYER_TYPE_LSTM=6,LAYER_TYPE_RECCURRENT=7,LAYER_TYPE_UNSCALING=8,LAYER_TYPE_BOUNDING=9};
enum ProbabilisticActivationEnum{PROBABILISTIC_ACTIVATION_BINARY=1,PROBABILISTIC_ACTIVATION_LOGISTIC=2,PROBABILISTIC_ACTIVATION_COMPETITIVE=3,PROBABILISTIC_ACTIVATION_SOFTMAX=4};
Expand Down
2 changes: 1 addition & 1 deletion src_erl/NerlnetApp/src/worker_definitions_ag.hrl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
% This is an auto generated .hrl file
-define(NERLPLANNER_VERSION,"1.0.0").
% Generated by Nerlplanner version: 1.0.0

-define(KEY_MODEL_TYPE,modelType).
-define(KEY_LAYER_SIZES_LIST,layersSizes).
Expand Down
2 changes: 1 addition & 1 deletion src_py/nerlPlanner/CppHeadersExporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def gen_header_worker_parameters_definitions(header_path : str, debug : bool = F
gen_header_exporter_logger(pragma_once.generate_code())
auto_generated_header = AutoGeneratedHeader()
gen_header_exporter_logger(auto_generated_header.generate_code())
nerlplanner_version = Definition('NERLPLANNER_VERSION', f'"{NERLPLANNER_VERSION}"')
nerlplanner_version = Comment(f'Generated by Nerlplanner version: {NERLPLANNER_VERSION}')

layer_type_enums = EnumType('LayerTypeEnum', LayerTypeMap, True, 'LAYER_TYPE')
gen_header_exporter_logger(layer_type_enums.generate_code())
Expand Down
7 changes: 7 additions & 0 deletions src_py/nerlPlanner/CppHeadersExporterDefs.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
from collections import OrderedDict

class Comment():
def __init__(self, comment : str) -> None:
self.comment = comment

def generate_code(self):
return f'// {self.comment}\n'

class AutoGeneratedHeader:
def __init__(self) -> None:
pass
Expand Down
13 changes: 12 additions & 1 deletion src_py/nerlPlanner/ErlHeadersExporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def gen_worker_fields_hrl(header_path : str, debug : bool = False):
auto_generated_header = AutoGeneratedHeader()
gen_erlang_exporter_logger(auto_generated_header.generate_code())

nerlplanner_version = Definition('NERLPLANNER_VERSION', f'"{NERLPLANNER_VERSION}"')
nerlplanner_version = Comment(f'Generated by Nerlplanner version: {NERLPLANNER_VERSION}')
gen_erlang_exporter_logger(nerlplanner_version.generate_code())

fields_list_vals = [KEY_MODEL_TYPE, KEY_LAYER_SIZES_LIST,
Expand All @@ -43,7 +43,17 @@ def gen_worker_fields_hrl(header_path : str, debug : bool = False):
f.write(EMPTY_LINE)
[f.write(x.generate_code()) for x in fields_list_defs]

def gen_dc_fields_hrl(header_path : str, debug : bool = False):
global DEBUG
DEBUG = debug

auto_generated_header = AutoGeneratedHeader()
gen_erlang_exporter_logger(auto_generated_header.generate_code())

nerlplanner_version = Comment(f'Generated by Nerlplanner version: {NERLPLANNER_VERSION}')
gen_erlang_exporter_logger(nerlplanner_version.generate_code())

#TODO


def main():
Expand All @@ -52,6 +62,7 @@ def main():
parser.add_argument('-d', '--debug', help='debug mode', action='store_true')
args = parser.parse_args()
gen_worker_fields_hrl(args.output, args.debug)
gen_dc_fields_hrl(args.output, args.debug)

if __name__=="__main__":
main()
Expand Down
7 changes: 7 additions & 0 deletions src_py/nerlPlanner/ErlHeadersExporterDefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

# Generates automated Erlang code!

class Comment():
def __init__(self, comment : str) -> None:
self.comment = comment

def generate_code(self):
return f'% {self.comment}\n'

class AutoGeneratedHeader:
def __init__(self) -> None:
pass
Expand Down
14 changes: 1 addition & 13 deletions src_py/nerlPlanner/JsonDistributedConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,14 @@
from JsonElements import *
from collections import OrderedDict
from JsonElementWorker import *
from JsonDistributedConfigDefs import *

import json


# from collections import OrderedDict
#values=json.loads(jsontext,object_pairs_hook=OrderedDict)

KEY_NERLNET_SETTINGS = "NerlNetSettings"
KEY_FREQUENCY = "frequency"
KEY_BATCH_SIZE = "batchSize"
KEY_DEVICES = "devices"
KEY_CLIENTS = "clients"
KEY_WORKERS = "workers"
KEY_MODEL_SHA = "model-sha"
KEY_SOURCES = "sources"
KEY_ROUTERS = "routers"

NAME_FIELD = "name"
WORKER_MODEL_SHA_FIELD = "model-sha"

class JsonDistributedConfig():
def __init__(self):
self.main_dict = OrderedDict()
Expand Down
13 changes: 13 additions & 0 deletions src_py/nerlPlanner/JsonDistributedConfigDefs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

KEY_NERLNET_SETTINGS = "NerlNetSettings"
KEY_FREQUENCY = "frequency"
KEY_BATCH_SIZE = "batchSize"
KEY_DEVICES = "devices"
KEY_CLIENTS = "clients"
KEY_WORKERS = "workers"
KEY_MODEL_SHA = "model-sha"
KEY_SOURCES = "sources"
KEY_ROUTERS = "routers"

NAME_FIELD = "name"
WORKER_MODEL_SHA_FIELD = "model-sha"