From 681af9efafb34b4124212be9473232b6a256e04a Mon Sep 17 00:00:00 2001 From: cse0001 Date: Tue, 12 Nov 2024 12:02:05 -0800 Subject: [PATCH 1/5] Fix wasm-pack not found error --- frontend/scripts/install.sh | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/frontend/scripts/install.sh b/frontend/scripts/install.sh index c78d7e7dc..1ffe7a831 100755 --- a/frontend/scripts/install.sh +++ b/frontend/scripts/install.sh @@ -17,9 +17,24 @@ fi # wasm-pack # wasm-pack will be installed by npm package # https://rustwasm.github.io/wasm-pack/installer/ -# if ! hash wasm-pack 2>/dev/null; then -# curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh -# fi +if ! hash wasm-pack 2>/dev/null; then + curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh +fi + +# copy wasm-pack +destination="$HOME/.config/wasm-pack-nodejs/bin" +source=$(which wasm-pack) +if [ -z "$source" ]; then + echo "wasm-pack is not installed or not found in PATH" +else + echo "$source" + if [ -d "$destination" ]; then + cp "$source" "$destination" + else + mkdir -p "$destination" + cp "$source" "$destination" + fi +fi # yarn From a46773fd880e368d88939504d84f61017e94fbc9 Mon Sep 17 00:00:00 2001 From: cse0001 Date: Thu, 5 Dec 2024 10:31:15 -0800 Subject: [PATCH 2/5] add parameters --modelfile --- visualdl/reader/graph_reader.py | 8 ++++++-- visualdl/server/api.py | 14 +++++++++----- visualdl/server/app.py | 2 +- visualdl/server/args.py | 9 +++++++++ 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/visualdl/reader/graph_reader.py b/visualdl/reader/graph_reader.py index 4e8035bd5..3c3af3ded 100644 --- a/visualdl/reader/graph_reader.py +++ b/visualdl/reader/graph_reader.py @@ -41,7 +41,7 @@ class GraphReader(object): """Graph reader to read vdl graph files, support for frontend api in lib.py. """ - def __init__(self, logdir=''): + def __init__(self, logdir='', model_name=''): """Instance of GraphReader Args: @@ -52,6 +52,7 @@ def __init__(self, logdir=''): else: self.dir = logdir + self.model_name = model_name self.walks = {} self.displayname2runs = {} self.runs2displayname = {} @@ -102,7 +103,10 @@ def graphs(self, update=False): ] tags_temp.sort(reverse=True) if len(tags_temp) > 0: - walks_temp.update({run: tags_temp[0]}) + if self.model_name: + walks_temp.update({run: self.model_name}) + else: + walks_temp.update({run: tags_temp[0]}) self.walks = walks_temp return self.walks diff --git a/visualdl/server/api.py b/visualdl/server/api.py index eea55455d..7c644025d 100644 --- a/visualdl/server/api.py +++ b/visualdl/server/api.py @@ -77,9 +77,13 @@ def try_call(function, *args, **kwargs): class Api(object): - def __init__(self, logdir, model, cache_timeout): + def __init__(self, logdir, model, modelfile, cache_timeout): + self.model_name = '' + if not logdir and modelfile: + logdir = os.path.dirname(modelfile) + self.model_name = os.path.basename(modelfile) self._reader = LogReader(logdir) - self._graph_reader = GraphReader(logdir) + self._graph_reader = GraphReader(logdir, self.model_name) self._graph_reader.set_displayname(self._reader) if model: if 'vdlgraph' in model: @@ -415,7 +419,7 @@ def get_component_tabs(*apis, vdl_args, request_args): all_tabs = set() if vdl_args.component_tabs: return list(vdl_args.component_tabs) - if vdl_args.logdir: + if vdl_args.logdir or vdl_args.modelfile: for api in apis: all_tabs.update(api('component_tabs', request_args)) all_tabs.add('static_graph') @@ -427,8 +431,8 @@ def get_component_tabs(*apis, vdl_args, request_args): return list(all_tabs) -def create_api_call(logdir, model, cache_timeout): - api = Api(logdir, model, cache_timeout) +def create_api_call(logdir, model, modelfile, cache_timeout): + api = Api(logdir, model, modelfile, cache_timeout) routes = { 'components': (api.components, []), 'runs': (api.runs, []), diff --git a/visualdl/server/app.py b/visualdl/server/app.py index 2f7b0f3b9..a1d368121 100644 --- a/visualdl/server/app.py +++ b/visualdl/server/app.py @@ -86,7 +86,7 @@ def get_locale(): ) # we add this to prevent SIGINT not work in multiprocess queue waiting babel = Babel(app, locale_selector=get_locale) # noqa:F841 # Babel api from flask_babel v3.0.0 - api_call = create_api_call(args.logdir, args.model, args.cache_timeout) + api_call = create_api_call(args.logdir, args.model, args.modelfile, args.cache_timeout) profiler_api_call = create_profiler_api_call(args.logdir) inference_api_call = create_model_convert_api_call() fastdeploy_api_call = create_fastdeploy_api_call() diff --git a/visualdl/server/args.py b/visualdl/server/args.py index 71f97afb1..fdbefea2e 100644 --- a/visualdl/server/args.py +++ b/visualdl/server/args.py @@ -40,6 +40,7 @@ def __init__(self, args): self.api_only = args.get('api_only', False) self.open_browser = args.get('open_browser', False) self.model = args.get('model', '') + self.modelfile = args.get('modelfile', '') self.product = args.get('product', default_product) self.telemetry = args.get('telemetry', True) self.theme = args.get('theme', None) @@ -123,6 +124,7 @@ def __init__(self, **kwargs): self.api_only = args.api_only self.open_browser = args.open_browser self.model = args.model + self.modelfile = args.modelfile self.product = args.product self.telemetry = args.telemetry self.theme = args.theme @@ -141,6 +143,13 @@ def parse_args(): epilog="For more information: https://github.com/PaddlePaddle/VisualDL" ) + parser.add_argument( + "--modelfile", + type=str, + action="store", + default="", + help="json model file path") + parser.add_argument( "--logdir", action="store", nargs="+", help="log file directory") From c61567a05ce67fc4800807b8caacb63355f04b59 Mon Sep 17 00:00:00 2001 From: cse0001 Date: Tue, 10 Dec 2024 21:44:15 -0800 Subject: [PATCH 3/5] Fix operator attribute visualization bug --- visualdl/component/graph/graph_component.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/visualdl/component/graph/graph_component.py b/visualdl/component/graph/graph_component.py index 775da25c5..7360b647d 100644 --- a/visualdl/component/graph/graph_component.py +++ b/visualdl/component/graph/graph_component.py @@ -474,13 +474,13 @@ def get_sub_ops(op, op_name, all_ops, all_vars): all_ops[sub_op_name]['output_vars'][now_var] = [now_var] try: - attrs = op.results()[0].get_defining_op().attrs() + attrs = sub_op.results()[0].get_defining_op().attrs() if 'place' in attrs: attrs['place'] = str(attrs['place']) - attrs['dtype'] = safe_get_dtype(op) + attrs['dtype'] = safe_get_dtype(sub_op) except Exception: - # attrs = {} - pass + attrs = {} + #pass all_ops[sub_op_name]['attrs'] = attrs all_ops[sub_op_name]['attr_types'] = attrs @@ -601,7 +601,8 @@ def analyse_pir(program): attrs['place'] = str(attrs['place']) attrs['dtype'] = safe_get_dtype(op) except Exception: - pass + #pass + attrs = {} all_vars[var_name]['shape'] = safe_get_shape(op) all_vars[var_name]['type'] = safe_get_type(op) @@ -641,6 +642,15 @@ def analyse_pir(program): all_vars[now_var]['from_node'] = op_name all_ops[op_name]['output_vars'][now_var] = [now_var] + try: + attrs = op.results()[0].get_defining_op().attrs() + if 'place' in attrs: + attrs['place'] = str(attrs['place']) + attrs['dtype'] = safe_get_dtype(op) + except Exception: + #pass + attrs = {} + all_ops[op_name]['attrs'] = attrs all_ops[op_name]['attr_types'] = attrs all_ops[op_name]['children_node'] = [] From 9e5c2e25fe047af36356677481ffd1cc32fe0144 Mon Sep 17 00:00:00 2001 From: cse0001 Date: Tue, 7 Jan 2025 05:46:51 -0800 Subject: [PATCH 4/5] Fix var bugs --- visualdl/component/graph/graph_component.py | 44 +++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/visualdl/component/graph/graph_component.py b/visualdl/component/graph/graph_component.py index 7360b647d..d3b7efe85 100644 --- a/visualdl/component/graph/graph_component.py +++ b/visualdl/component/graph/graph_component.py @@ -464,7 +464,29 @@ def get_sub_ops(op, op_name, all_ops, all_vars): all_ops[sub_op_name]['is_leaf_node'] = True now_var = utils.gen_var_name(sub_op.results()) for source in sub_op.operands_source(): + if str(source.type()) == '<>': + continue input_name = utils.gen_var_name(source) + if input_name not in all_vars.keys(): + all_vars[input_name] = {} + all_vars[input_name]['name'] = input_name + try: + attrs = source.results()[0].get_defining_op().attrs() + if 'place' in attrs: + attrs['place'] = str(attrs['place']) + attrs['dtype'] = safe_get_dtype(source) + except Exception: + attrs = {} + + all_vars[input_name]['shape'] = safe_get_shape(source) + all_vars[input_name]['type'] = safe_get_type(source) + all_vars[input_name]['dtype'] = safe_get_dtype(source) + all_vars[input_name]['value'] = [] + all_vars[input_name]['persistable'] = safe_get_persistable(source) + all_vars[input_name]['attrs'] = attrs + all_vars[input_name]['from_node'] = '' + all_vars[input_name]['to_nodes'] = [] + if sub_op.name() == "pd_op.increment_": all_vars[now_var]['to_nodes'].append(all_vars[input_name]['from_node']) all_ops[all_vars[input_name]['from_node']]['input_vars'][now_var] = [now_var] @@ -633,7 +655,29 @@ def analyse_pir(program): all_ops[op_name]['is_leaf_node'] = True now_var = utils.gen_var_name(op.results()) for source in op.operands_source(): + if str(source.type()) == '<>': + continue input_name = utils.gen_var_name(source) + if input_name not in all_vars.keys(): + all_vars[input_name] = {} + all_vars[input_name]['name'] = input_name + try: + attrs = source.results()[0].get_defining_op().attrs() + if 'place' in attrs: + attrs['place'] = str(attrs['place']) + attrs['dtype'] = safe_get_dtype(source) + except Exception: + attrs = {} + + all_vars[input_name]['shape'] = safe_get_shape(source) + all_vars[input_name]['type'] = safe_get_type(source) + all_vars[input_name]['dtype'] = safe_get_dtype(source) + all_vars[input_name]['value'] = [] + all_vars[input_name]['persistable'] = safe_get_persistable(source) + all_vars[input_name]['attrs'] = attrs + all_vars[input_name]['from_node'] = '' + all_vars[input_name]['to_nodes'] = [] + if op.name() == "pd_op.increment_": all_vars[now_var]['to_nodes'].append(all_vars[input_name]['from_node']) all_ops[all_vars[input_name]['from_node']]['input_vars'][now_var] = [now_var] From 23372ab5575a19d0615bad9c27b90786e84f7ebd Mon Sep 17 00:00:00 2001 From: cse0001 Date: Thu, 16 Jan 2025 09:35:32 -0800 Subject: [PATCH 5/5] check source type --- visualdl/component/graph/graph_component.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/visualdl/component/graph/graph_component.py b/visualdl/component/graph/graph_component.py index d3b7efe85..f20394720 100644 --- a/visualdl/component/graph/graph_component.py +++ b/visualdl/component/graph/graph_component.py @@ -464,7 +464,8 @@ def get_sub_ops(op, op_name, all_ops, all_vars): all_ops[sub_op_name]['is_leaf_node'] = True now_var = utils.gen_var_name(sub_op.results()) for source in sub_op.operands_source(): - if str(source.type()) == '<>': + if not source.type(): + # if source.type() == Value().type(): continue input_name = utils.gen_var_name(source) if input_name not in all_vars.keys(): @@ -655,7 +656,8 @@ def analyse_pir(program): all_ops[op_name]['is_leaf_node'] = True now_var = utils.gen_var_name(op.results()) for source in op.operands_source(): - if str(source.type()) == '<>': + if not source.type(): + # if source.type() == Value().type(): continue input_name = utils.gen_var_name(source) if input_name not in all_vars.keys():