| @@ -12,3 +12,4 @@ | |||
| # See the License for the specific language governing permissions and | |||
| # limitations under the License. | |||
| # ============================================================================ | |||
| """This module defines the methods associated with the web app.""" | |||
| @@ -12,3 +12,4 @@ | |||
| # See the License for the specific language governing permissions and | |||
| # limitations under the License. | |||
| # ============================================================================ | |||
| """This module defines the public methods that are relevant to the business.""" | |||
| @@ -206,8 +206,8 @@ class Graph: | |||
| for name_tmp, node_tmp in group.items(): | |||
| node_tmp.polymeric_scope_name = polymeric_node_name | |||
| self._polymeric_nodes.update({name_tmp: node_tmp}) | |||
| polymeric_node.update_input(node_tmp.input) | |||
| polymeric_node.update_output(node_tmp.output) | |||
| polymeric_node.update_input(node_tmp.inputs) | |||
| polymeric_node.update_output(node_tmp.outputs) | |||
| self._normal_nodes.update({polymeric_node_name: polymeric_node}) | |||
| @@ -227,7 +227,7 @@ class Graph: | |||
| for node_name, group_node in group.items(): | |||
| node_list = [] | |||
| is_in_group = False | |||
| for dst_name in group_node.output: | |||
| for dst_name in group_node.outputs: | |||
| node_tmp = self._leaf_nodes[dst_name] | |||
| node_list.append(node_tmp) | |||
| @@ -245,7 +245,7 @@ class Graph: | |||
| if node_tmp in group.values(): | |||
| is_in_group = True | |||
| break | |||
| for dst_name_tmp in node_tmp.output: | |||
| for dst_name_tmp in node_tmp.outputs: | |||
| run_count += 1 | |||
| node_tmp = self._leaf_nodes[dst_name_tmp] | |||
| if visit_nodes.get(dst_name_tmp): | |||
| @@ -273,23 +273,23 @@ class Graph: | |||
| def _update_input_output(self): | |||
| """We need to update input and output attribute after build polymeric node.""" | |||
| for node in self._normal_nodes.values(): | |||
| for src_name, input_attr in node.input.items(): | |||
| for src_name, input_attr in node.inputs.items(): | |||
| if self._polymeric_nodes.get(src_name): | |||
| input_attr['scope'] = NodeTypeEnum.POLYMERIC_SCOPE.value | |||
| node.update_input({src_name: input_attr}) | |||
| for dst_name, output_attr in node.output.items(): | |||
| for dst_name, output_attr in node.outputs.items(): | |||
| if self._polymeric_nodes.get(dst_name): | |||
| output_attr['scope'] = NodeTypeEnum.POLYMERIC_SCOPE.value | |||
| node.update_output({dst_name: output_attr}) | |||
| for node in self._polymeric_nodes.values(): | |||
| for src_name, input_attr in node.input.items(): | |||
| for src_name, input_attr in node.inputs.items(): | |||
| if self._polymeric_nodes.get(src_name): | |||
| input_attr['scope'] = NodeTypeEnum.POLYMERIC_SCOPE.value | |||
| node.update_input({src_name: input_attr}) | |||
| for dst_name, output_attr in node.output.items(): | |||
| for dst_name, output_attr in node.outputs.items(): | |||
| if self._polymeric_nodes.get(dst_name): | |||
| output_attr['scope'] = NodeTypeEnum.POLYMERIC_SCOPE.value | |||
| node.update_output({dst_name: output_attr}) | |||
| @@ -297,21 +297,21 @@ class Graph: | |||
| def _update_polymeric_input_output(self): | |||
| """Calc polymeric input and output after build polymeric node.""" | |||
| for node in self._normal_nodes.values(): | |||
| polymeric_input = self._calc_polymeric_attr(node, 'input') | |||
| polymeric_input = self._calc_polymeric_attr(node, 'inputs') | |||
| node.update_polymeric_input(polymeric_input) | |||
| polymeric_output = self._calc_polymeric_attr(node, 'output') | |||
| polymeric_output = self._calc_polymeric_attr(node, 'outputs') | |||
| node.update_polymeric_output(polymeric_output) | |||
| for name, node in self._polymeric_nodes.items(): | |||
| polymeric_input = {} | |||
| for src_name in node.input: | |||
| for src_name in node.inputs: | |||
| output_name = self._calc_dummy_node_name(name, src_name) | |||
| polymeric_input.update({output_name: {'edge_type': EdgeTypeEnum.DATA.value}}) | |||
| node.update_polymeric_input(polymeric_input) | |||
| polymeric_output = {} | |||
| for dst_name in node.output: | |||
| for dst_name in node.outputs: | |||
| polymeric_output = {} | |||
| output_name = self._calc_dummy_node_name(name, dst_name) | |||
| polymeric_output.update({output_name: {'edge_type': EdgeTypeEnum.DATA.value}}) | |||
| @@ -410,12 +410,12 @@ class Graph: | |||
| # update the input and output of this to namescope node | |||
| name_scope_with_slash = name_scope + '/' | |||
| for src_name, input_attr in node.input.items(): | |||
| for src_name, input_attr in node.inputs.items(): | |||
| if src_name.startswith(name_scope_with_slash): | |||
| continue | |||
| name_scope_node.update_input({src_name: input_attr}) | |||
| for dst_name, output_attr in node.output.items(): | |||
| for dst_name, output_attr in node.outputs.items(): | |||
| if dst_name.startswith(name_scope_with_slash): | |||
| continue | |||
| name_scope_node.update_output({dst_name: output_attr}) | |||
| @@ -428,7 +428,7 @@ class Graph: | |||
| nodes.extend(self._normal_nodes.values()) | |||
| nodes.extend(self._polymeric_nodes.values()) | |||
| for node in nodes: | |||
| attrs = ['input', 'output', 'polymeric_input', 'polymeric_output'] | |||
| attrs = ['inputs', 'outputs', 'polymeric_inputs', 'polymeric_outputs'] | |||
| for item in attrs: | |||
| tmp_dict = dict(getattr(node, item)) | |||
| for name, value in tmp_dict.items(): | |||
| @@ -138,7 +138,7 @@ class MSGraph(Graph): | |||
| for name, node in self._leaf_nodes.items(): | |||
| if node.node_type == NodeTypeEnum.CONST.value: | |||
| continue | |||
| for src_name, input_attr in node.input.items(): | |||
| for src_name, input_attr in node.inputs.items(): | |||
| src_node = self._leaf_nodes[src_name] | |||
| if src_node.node_type == NodeTypeEnum.CONST.value: | |||
| continue | |||
| @@ -39,11 +39,11 @@ class Node: | |||
| self._name = name | |||
| self._type = "" | |||
| self._attr = dict() | |||
| self._input = dict() | |||
| self._inputs = dict() | |||
| self._output_i = -1 | |||
| self._output = {} | |||
| self._polymeric_input = {} | |||
| self._polymeric_output = {} | |||
| self._outputs = {} | |||
| self._polymeric_inputs = {} | |||
| self._polymeric_outputs = {} | |||
| self._polymeric_scope_name = "" | |||
| self._subnode_count = 0 | |||
| self._name_scope = "" | |||
| @@ -55,11 +55,11 @@ class Node: | |||
| 'name': self._name, | |||
| 'type': self._type, | |||
| 'attr': self._attr, | |||
| 'input': self._input, | |||
| 'input': self._inputs, | |||
| 'output_i': self._output_i, | |||
| 'output': self._output, | |||
| 'polymeric_input': self._polymeric_input, | |||
| 'polymeric_output': self._polymeric_output, | |||
| 'output': self._outputs, | |||
| 'polymeric_input': self._polymeric_inputs, | |||
| 'polymeric_output': self._polymeric_outputs, | |||
| 'subnode_count': self._subnode_count, | |||
| 'polymeric_scope_name': self._polymeric_scope_name | |||
| } | |||
| @@ -99,28 +99,32 @@ class Node: | |||
| Update node attr. | |||
| Args: | |||
| attr_dict (dict[str, str]): Format is {'<key>': '<value>'}. | |||
| attr_dict (dict[str, str]): The attr of node. | |||
| """ | |||
| self._attr.update(attr_dict) | |||
| @property | |||
| def input(self): | |||
| def inputs(self): | |||
| """ | |||
| Get all input of current node. | |||
| Returns: | |||
| dict[str, dict], format is {'<src_name>': {'shape': [], 'edge_type', 'scope'}}. | |||
| """ | |||
| return self._input | |||
| return self._inputs | |||
| def update_input(self, input_dict): | |||
| """ | |||
| Update input. | |||
| Args: | |||
| input_dict (dict[str, dict]): Format is {'<src_name>': {'shape': [], 'edge_type', 'scope'}}. | |||
| input_dict (dict[str, dict]): Key is a source node name, and the value is a dict. | |||
| - shape (list): The shape of input tensor. | |||
| - edge_type (str): The type of edge, optional value refer to `EdgeTypeEnum`. | |||
| - scope (str): The scope of this source node. | |||
| """ | |||
| self._input.update(input_dict) | |||
| self._inputs.update(input_dict) | |||
| @property | |||
| def output_i(self): | |||
| @@ -133,49 +137,51 @@ class Node: | |||
| self._output_i = output_i | |||
| @property | |||
| def polymeric_input(self): | |||
| def polymeric_inputs(self): | |||
| """ | |||
| The polymeric input is the input of the polymeric nodes. | |||
| Returns: | |||
| dict[str, dict], format is {'<src_name>': {'edge_type': '<value>'}}. | |||
| """ | |||
| return self._polymeric_input | |||
| return self._polymeric_inputs | |||
| def update_polymeric_input(self, polymeric_input): | |||
| """The polymeric input is the input of the polymeric nodes.""" | |||
| self._polymeric_input.update(polymeric_input) | |||
| self._polymeric_inputs.update(polymeric_input) | |||
| @property | |||
| def output(self): | |||
| def outputs(self): | |||
| """The output node of this node.""" | |||
| return self._output | |||
| return self._outputs | |||
| def update_output(self, output): | |||
| """ | |||
| Update output node. | |||
| Args: | |||
| output (dict[str, TypedDict('NodeType', {'type': str})]): Format | |||
| is {"<node_name>": {"type": "<node type>"}}. | |||
| output (dict[str, TypedDict('NodeType', {'type': str})]): Key is a dst node name, and value is a dict. | |||
| - type (str): The type of the dst node. | |||
| """ | |||
| self._output.update(output) | |||
| self._outputs.update(output) | |||
| @property | |||
| def polymeric_output(self): | |||
| def polymeric_outputs(self): | |||
| """Get polymeric output.""" | |||
| return self._polymeric_output | |||
| return self._polymeric_outputs | |||
| def update_polymeric_output(self, polymeric_output): | |||
| """ | |||
| Update polymeric output. | |||
| Args: | |||
| polymeric_output (dict[str, dict): Format is {dst_node.polymeric_scope_name: | |||
| {'edge_type': EdgeTypeEnum.DATA.value}}). | |||
| polymeric_output (dict[str, dict): Key is the polymeric scope name of dst name, and value is dict. | |||
| - edge_type (str): The edge type of the dst node. | |||
| """ | |||
| self._polymeric_output.update(polymeric_output) | |||
| self._polymeric_outputs.update(polymeric_output) | |||
| @property | |||
| def polymeric_scope_name(self): | |||
| @@ -12,3 +12,4 @@ | |||
| # See the License for the specific language governing permissions and | |||
| # limitations under the License. | |||
| # ============================================================================ | |||
| """This module defines the generator for the loaders.""" | |||
| @@ -32,7 +32,7 @@ class SummaryWatcher: | |||
| MAX_SUMMARY_DIR_COUNT = 999 | |||
| # scan at most 20000 files/directories (approximately 1 seconds) | |||
| # if overall=False in SummaryWatcher.list_summary_directories | |||
| # if overall is False in SummaryWatcher.list_summary_directories | |||
| # to avoid long-time blocking | |||
| MAX_SCAN_COUNT = 20000 | |||
| @@ -12,3 +12,4 @@ | |||
| # See the License for the specific language governing permissions and | |||
| # limitations under the License. | |||
| # ============================================================================ | |||
| """This module defines common utility methods.""" | |||