id
int64
0
190k
prompt
stringlengths
21
13.4M
docstring
stringlengths
1
12k
23,126
from __future__ import absolute_import from __future__ import division from __future__ import print_function from typing import List, Mapping, Any, Union, Tuple import collections from nndct_shared.base.key_names import NNDCT_OP as OpTypes from nndct_shared.nndct_graph.base_node import Node from nndct_shared.metaclass ...
null
23,127
from __future__ import absolute_import from __future__ import division from __future__ import print_function from typing import List, Mapping, Any, Union, Tuple import collections from nndct_shared.base.key_names import NNDCT_OP as OpTypes from nndct_shared.nndct_graph.base_node import Node from nndct_shared.metaclass ...
null
23,128
from collections import deque def graph_search_handler(start_node, generator, frontier, handler=None, gen_params={}): class FIFOQueue(Queue): def __init__(self): def append(self, item): def __len__(self): ...
null
23,129
import sys from typing import List, Optional from nndct_shared.base import NNDCT_OP from nndct_shared.nndct_graph import Graph, Operation, Node, Block from nndct_shared.nndct_graph import operator_definition as base_op from nndct_shared.utils import NndctOption, NndctScreenLogger def reset_group_members(graph, groups,...
null
23,130
import sys from typing import List, Optional from nndct_shared.base import NNDCT_OP from nndct_shared.nndct_graph import Graph, Operation, Node, Block from nndct_shared.nndct_graph import operator_definition as base_op from nndct_shared.utils import NndctOption, NndctScreenLogger def glue_group_members(graph, groups, s...
null
23,131
import sys from typing import List, Optional from nndct_shared.base import NNDCT_OP from nndct_shared.nndct_graph import Graph, Operation, Node, Block from nndct_shared.nndct_graph import operator_definition as base_op from nndct_shared.utils import NndctOption, NndctScreenLogger def reorder_multi_subgraph_nodes(graph...
null
23,132
import sys from typing import List, Optional from nndct_shared.base import NNDCT_OP from nndct_shared.nndct_graph import Graph, Operation, Node, Block from nndct_shared.nndct_graph import operator_definition as base_op from nndct_shared.utils import NndctOption, NndctScreenLogger def merge_multi_subgraphs(graphs: List...
null
23,133
import sys from typing import List, Optional from nndct_shared.base import NNDCT_OP from nndct_shared.nndct_graph import Graph, Operation, Node, Block from nndct_shared.nndct_graph import operator_definition as base_op from nndct_shared.utils import NndctOption, NndctScreenLogger def convert_graph_to_block_node(top_gra...
null
23,134
import sys from typing import List, Optional from nndct_shared.base import NNDCT_OP from nndct_shared.nndct_graph import Graph, Operation, Node, Block from nndct_shared.nndct_graph import operator_definition as base_op from nndct_shared.utils import NndctOption, NndctScreenLogger def convert_block_node_to_graph(block_...
null
23,135
import json import numpy as np from collections import OrderedDict from enum import Enum, auto from functools import partial from typing import Dict, List, Callable, Optional, Union, Any, Set from nndct_shared.nndct_graph.base_tensor import Tensor from nndct_shared.utils.common import AutoName The provided code snippe...
r""" if in_out == 0 stamp value in memory, otherwise get memory_value
23,136
import copy from collections import defaultdict, deque, namedtuple from typing import List from nndct_shared.quantization import BaseQuantizer from nndct_shared.base import NNDCT_OP from nndct_shared.nndct_graph import Graph, Node, Tensor, GraphSearcher from nndct_shared.nndct_graph import operator_definition as base_o...
null
23,137
import math import itertools from typing import List, Dict, Any, NoReturn, Tuple import numpy as np from functools import partial from nndct_shared.base import NNDCT_OP, NNDCT_KEYS from nndct_shared.nndct_graph import Tensor, Node from .xgraph import XGraph from nndct_shared.utils import calculate_op_scale, DataXopErro...
null
23,138
import math import itertools from typing import List, Dict, Any, NoReturn, Tuple import numpy as np from functools import partial from nndct_shared.base import NNDCT_OP, NNDCT_KEYS from nndct_shared.nndct_graph import Tensor, Node from .xgraph import XGraph from nndct_shared.utils import calculate_op_scale, DataXopErro...
null
23,139
import math import itertools from typing import List, Dict, Any, NoReturn, Tuple import numpy as np from functools import partial from nndct_shared.base import NNDCT_OP, NNDCT_KEYS from nndct_shared.nndct_graph import Tensor, Node from .xgraph import XGraph from nndct_shared.utils import calculate_op_scale, DataXopErro...
null
23,140
import math import itertools from typing import List, Dict, Any, NoReturn, Tuple import numpy as np from functools import partial from nndct_shared.base import NNDCT_OP, NNDCT_KEYS from nndct_shared.nndct_graph import Tensor, Node from .xgraph import XGraph from nndct_shared.utils import calculate_op_scale, DataXopErro...
r""" nndct reshape is a macro operator, including pack, reshape
23,141
import math import itertools from typing import List, Dict, Any, NoReturn, Tuple import numpy as np from functools import partial from nndct_shared.base import NNDCT_OP, NNDCT_KEYS from nndct_shared.nndct_graph import Tensor, Node from .xgraph import XGraph from nndct_shared.utils import calculate_op_scale, DataXopErro...
resize is a macro operator, including concat , resize
23,142
import math import itertools from typing import List, Dict, Any, NoReturn, Tuple import numpy as np from functools import partial from nndct_shared.base import NNDCT_OP, NNDCT_KEYS from nndct_shared.nndct_graph import Tensor, Node from .xgraph import XGraph from nndct_shared.utils import calculate_op_scale, DataXopErro...
null
23,143
import math import itertools from typing import List, Dict, Any, NoReturn, Tuple import numpy as np from functools import partial from nndct_shared.base import NNDCT_OP, NNDCT_KEYS from nndct_shared.nndct_graph import Tensor, Node from .xgraph import XGraph from nndct_shared.utils import calculate_op_scale, DataXopErro...
null
23,144
import math import itertools from typing import List, Dict, Any, NoReturn, Tuple import numpy as np from functools import partial from nndct_shared.base import NNDCT_OP, NNDCT_KEYS from nndct_shared.nndct_graph import Tensor, Node from .xgraph import XGraph from nndct_shared.utils import calculate_op_scale, DataXopErro...
null
23,145
import math import itertools from typing import List, Dict, Any, NoReturn, Tuple import numpy as np from functools import partial from nndct_shared.base import NNDCT_OP, NNDCT_KEYS from nndct_shared.nndct_graph import Tensor, Node from .xgraph import XGraph from nndct_shared.utils import calculate_op_scale, DataXopErro...
null
23,146
import math import itertools from typing import List, Dict, Any, NoReturn, Tuple import numpy as np from functools import partial from nndct_shared.base import NNDCT_OP, NNDCT_KEYS from nndct_shared.nndct_graph import Tensor, Node from .xgraph import XGraph from nndct_shared.utils import calculate_op_scale, DataXopErro...
null
23,147
import math import itertools from typing import List, Dict, Any, NoReturn, Tuple import numpy as np from functools import partial from nndct_shared.base import NNDCT_OP, NNDCT_KEYS from nndct_shared.nndct_graph import Tensor, Node from .xgraph import XGraph from nndct_shared.utils import calculate_op_scale, DataXopErro...
null
23,148
import math import itertools from typing import List, Dict, Any, NoReturn, Tuple import numpy as np from functools import partial from nndct_shared.base import NNDCT_OP, NNDCT_KEYS from nndct_shared.nndct_graph import Tensor, Node from .xgraph import XGraph from nndct_shared.utils import calculate_op_scale, DataXopErro...
null
23,149
import math import itertools from typing import List, Dict, Any, NoReturn, Tuple import numpy as np from functools import partial from nndct_shared.base import NNDCT_OP, NNDCT_KEYS from nndct_shared.nndct_graph import Tensor, Node from .xgraph import XGraph from nndct_shared.utils import calculate_op_scale, DataXopErro...
null
23,150
import math import itertools from typing import List, Dict, Any, NoReturn, Tuple import numpy as np from functools import partial from nndct_shared.base import NNDCT_OP, NNDCT_KEYS from nndct_shared.nndct_graph import Tensor, Node from .xgraph import XGraph from nndct_shared.utils import calculate_op_scale, DataXopErro...
null
23,151
from nndct_shared.base import NNDCT_CONSTANT def shape_attr_transform_fn(node, transpose_order): shape = node.node_attr(node.op.AttrName.SHAPE) new_shape = len(shape) * [None] for i, dim in enumerate(transpose_order): new_shape[i] = shape[dim] node.set_node_attr(node.op.AttrName.SHAPE, new_shape)
null
23,152
from nndct_shared.base import NNDCT_CONSTANT def axis_attr_transform_fn(node, transpose_order): dim = node.node_attr(node.op.AttrName.AXIS) new_dim = transpose_order.index(dim) node.set_node_attr(node.op.AttrName.AXIS, new_dim)
null
23,153
from nndct_shared.base import NNDCT_CONSTANT def slice_attr_transform_fn(node, transpose_order): begin = node.node_attr(node.op.AttrName.BEGIN) new_begin = [None] * len(begin) for dim, pos in enumerate(begin): new_dim = transpose_order.index(dim) new_begin[new_dim] = pos begin_mask =...
null
23,154
from nndct_shared.base import NNDCT_CONSTANT def reduce_op_attr_transform_fn(node, transpose_order): dims = node.node_attr(node.op.AttrName.DIMS) new_dims = [None] * len(dims) for i, dim in enumerate(dims): new_dim = transpose_order.index(dim) new_dims[i] = new_dim node.set_node_attr(node.op.AttrN...
null
23,155
from collections import defaultdict from nndct_shared.utils import NndctDebugLogger, NndctOption def convert_quant_config_to_dict(quant_config, init=False): config = {'param': defaultdict(list), 'output': defaultdict(list), 'input': defaultdict(list)} for key in quant_config.get_output_keys(): for quant_info i...
null
23,156
from collections import defaultdict from nndct_shared.utils import NndctDebugLogger, NndctOption NNDCTIR2XIR_CONVERTOR = { # NNDCT op type: (XIR op type , XIR_CONVERT_FUNCTION) NNDCT_OP.INPUT: ("data", data_xop), NNDCT_OP.CONV1D: ("conv1d", to_xir("conv1d")), NNDCT_OP.CONV2D: ("conv2d", to_xir("conv2d"...
null
23,157
import copy import networkx as nx from networkx.algorithms import is_isomorphic from nndct_shared.base import NNDCT_OP from nndct_shared.inspector.utils import build_xir_nndct_op_map, log_debug_info from nndct_shared.compile.xir_helper import XIRHelper from .graph import Graph, Node _SIMULATION_PATTERNS = [ {"name":...
null
23,158
import copy import networkx as nx from networkx.algorithms import is_isomorphic from nndct_shared.base import NNDCT_OP from nndct_shared.inspector.utils import build_xir_nndct_op_map, log_debug_info from nndct_shared.compile.xir_helper import XIRHelper from .graph import Graph, Node class XIRHelper(object): def f...
null
23,159
import copy import networkx as nx from networkx.algorithms import is_isomorphic from nndct_shared.base import NNDCT_OP from nndct_shared.inspector.utils import build_xir_nndct_op_map, log_debug_info from nndct_shared.compile.xir_helper import XIRHelper from .graph import Graph, Node def get_templates_from_dpu_compiler(...
null
23,160
import copy import networkx as nx from networkx.algorithms import is_isomorphic from nndct_shared.base import NNDCT_OP from nndct_shared.inspector.utils import build_xir_nndct_op_map, log_debug_info from nndct_shared.compile.xir_helper import XIRHelper from .graph import Graph, Node class Graph(object): def __init__...
null
23,161
from typing import Mapping from nndct_shared.nndct_graph.base_graph import Graph from nndct_shared.nndct_graph.base_node import Node from nndct_shared.expanding.op_modifier import op_modifier from nndct_shared.expanding.spec import DataInsert, GenericStructuredExpanding, StructuredExpanding from nndct_shared.expanding....
null
23,162
from typing import Mapping from nndct_shared.expanding.spec import BatchNormStructuredExpanding, InstanceNormStructuredExpanding, \ DataInsert, GenericStructuredExpanding, StructuredExpanding, WeightedNodeStructuredExpanding from nndct_shared.nndct_graph.base_graph import Graph from nndct_shared.nndct_graph.base_node...
null
23,163
from typing import Mapping from nndct_shared.expanding.spec import BatchNormStructuredExpanding, InstanceNormStructuredExpanding, \ DataInsert, GenericStructuredExpanding, StructuredExpanding, WeightedNodeStructuredExpanding from nndct_shared.nndct_graph.base_graph import Graph from nndct_shared.nndct_graph.base_node...
null
23,164
from typing import Mapping from nndct_shared.expanding.spec import BatchNormStructuredExpanding, InstanceNormStructuredExpanding, \ DataInsert, GenericStructuredExpanding, StructuredExpanding, WeightedNodeStructuredExpanding from nndct_shared.nndct_graph.base_graph import Graph from nndct_shared.nndct_graph.base_node...
null
23,165
from typing import Mapping from nndct_shared.expanding.spec import BatchNormStructuredExpanding, InstanceNormStructuredExpanding, \ DataInsert, GenericStructuredExpanding, StructuredExpanding, WeightedNodeStructuredExpanding from nndct_shared.nndct_graph.base_graph import Graph from nndct_shared.nndct_graph.base_node...
null
23,166
from typing import Mapping from nndct_shared.expanding.spec import BatchNormStructuredExpanding, InstanceNormStructuredExpanding, \ DataInsert, GenericStructuredExpanding, StructuredExpanding, WeightedNodeStructuredExpanding from nndct_shared.nndct_graph.base_graph import Graph from nndct_shared.nndct_graph.base_node...
null
23,167
from typing import Mapping from nndct_shared.expanding.spec import BatchNormStructuredExpanding, InstanceNormStructuredExpanding, \ DataInsert, GenericStructuredExpanding, StructuredExpanding, WeightedNodeStructuredExpanding from nndct_shared.nndct_graph.base_graph import Graph from nndct_shared.nndct_graph.base_node...
null
23,168
from typing import Mapping from nndct_shared.expanding.spec import BatchNormStructuredExpanding, InstanceNormStructuredExpanding, \ DataInsert, GenericStructuredExpanding, StructuredExpanding, WeightedNodeStructuredExpanding from nndct_shared.nndct_graph.base_graph import Graph from nndct_shared.nndct_graph.base_node...
null
23,169
import numpy as np import math from nndct_shared.base import NNDCT_KEYS, GLOBAL_MAP from nndct_shared.utils import NndctOption from nndct_shared.algorithms import breadth_first_search_handler from .quant_ops import normal_quant_neuron def kernel_need_quant(quantizer, node): if NndctOption.nndct_quant_off.value: ...
null
23,170
import numpy as np import math from nndct_shared.base import NNDCT_KEYS, GLOBAL_MAP from nndct_shared.utils import NndctOption from nndct_shared.algorithms import breadth_first_search_handler from .quant_ops import normal_quant_neuron def normal_quant_neuron(data, maxamps=[[32768], [2048]], ...
null
23,171
import numpy as np import math from nndct_shared.base import NNDCT_KEYS, GLOBAL_MAP from nndct_shared.utils import NndctOption from nndct_shared.algorithms import breadth_first_search_handler from .quant_ops import normal_quant_neuron def is_quant_end_point(graph, node, quant_types): if len(graph.parents(node.name))...
null
23,172
import numpy as np import math from nndct_shared.base import NNDCT_KEYS, GLOBAL_MAP from nndct_shared.utils import NndctOption from nndct_shared.algorithms import breadth_first_search_handler from .quant_ops import normal_quant_neuron def get_flows_and_info(quant_mode, quantizer, ...
null
23,173
import numpy as np import math from nndct_shared.base import NNDCT_KEYS, GLOBAL_MAP from nndct_shared.utils import NndctOption from nndct_shared.algorithms import breadth_first_search_handler from .quant_ops import normal_quant_neuron def maybe_get_quantizer(quantizer=None): quantizer = quantizer or GLOBAL_MAP.get_el...
null
23,174
import numpy as np import math from nndct_shared.base import NNDCT_KEYS, GLOBAL_MAP from nndct_shared.utils import NndctOption from nndct_shared.algorithms import breadth_first_search_handler from .quant_ops import normal_quant_neuron def maybe_get_quantizer(quantizer=None): quantizer = quantizer or GLOBAL_MAP.get_el...
null
23,175
import numpy as np import math from nndct_shared.base import NNDCT_KEYS, GLOBAL_MAP from nndct_shared.utils import NndctOption from nndct_shared.algorithms import breadth_first_search_handler from .quant_ops import normal_quant_neuron def maybe_get_quantizer(quantizer=None): quantizer = quantizer or GLOBAL_MAP.get_el...
null
23,176
import numpy as np import math def max(data, name='', quantizer=None): return data.max()
null
23,177
import numpy as np import math def min(data, name='', quantizer=None): return data.min()
null
23,178
import numpy as np import math def quant_diff_s(data, bitwidth, range, round_method=2, name='', quantizer=None): raise NotImplementedError("please implement the diffs operation")
null
23,179
import numpy as np import math def nonlin(data, alpha, signed): if signed: return np.clip(data, -alpha, alpha) else: return np.clip(data, 0, alpha)
null
23,180
import numpy as np import math def pact_quant_neuron(data, bitw, bita, alpha_init_value=None, signed=False, trainable=True, warmup=False, name='', ...
null
23,181
import numpy as np import math def graffitist_quant_neuron(data, bn, fp, method=2, name=''): raise NotImplementedError( "please implement the lowbit_quant_neuron operation")
null
23,182
from __future__ import absolute_import from __future__ import division from __future__ import print_function import numpy as np from nndct_shared.base.key_names import NNDCT_OP from nndct_shared.base.key_names import FrameworkType from nndct_shared.nndct_graph import base_tensor class DataFormatMap(object): """A dict...
null
23,183
from __future__ import absolute_import from __future__ import division from __future__ import print_function import numpy as np from nndct_shared.base.key_names import NNDCT_OP from nndct_shared.base.key_names import FrameworkType from nndct_shared.nndct_graph import base_tensor class DataFormatMap(object): """A dict...
null
23,184
from __future__ import absolute_import from __future__ import division from __future__ import print_function import numpy as np from nndct_shared.base.key_names import NNDCT_OP from nndct_shared.base.key_names import FrameworkType from nndct_shared.nndct_graph import base_tensor class DataFormat(object): channel_firs...
NC* -> N*C/ N*C ->NC*
23,185
from __future__ import absolute_import from __future__ import division from __future__ import print_function import numpy as np from nndct_shared.base.key_names import NNDCT_OP from nndct_shared.base.key_names import FrameworkType from nndct_shared.nndct_graph import base_tensor def permute_data(data, order): if ord...
null
23,186
from __future__ import absolute_import from __future__ import division from __future__ import print_function import numpy as np from nndct_shared.base.key_names import NNDCT_OP from nndct_shared.base.key_names import FrameworkType from nndct_shared.nndct_graph import base_tensor def permute_axes(axes, order): if ord...
null
23,187
from __future__ import absolute_import from __future__ import division from __future__ import print_function import numpy as np from nndct_shared.base.key_names import NNDCT_OP from nndct_shared.base.key_names import FrameworkType from nndct_shared.nndct_graph import base_tensor def combine_orders(order1, order2): n...
null
23,188
from __future__ import absolute_import from __future__ import division from __future__ import print_function import logging as _logging import os as _os import sys as _sys import time as _time import traceback as _traceback from logging import DEBUG from logging import ERROR from logging import FATAL from logging impor...
null
23,189
from __future__ import absolute_import from __future__ import division from __future__ import print_function import logging as _logging import os as _os import sys as _sys import time as _time import traceback as _traceback from logging import DEBUG from logging import ERROR from logging import FATAL from logging impor...
null
23,190
from __future__ import absolute_import from __future__ import division from __future__ import print_function import logging as _logging import os as _os import sys as _sys import time as _time import traceback as _traceback from logging import DEBUG from logging import ERROR from logging import FATAL from logging impor...
Return how much logging output will be produced.
23,191
from __future__ import absolute_import from __future__ import division from __future__ import print_function import logging as _logging import os as _os import sys as _sys import time as _time import traceback as _traceback from logging import DEBUG from logging import ERROR from logging import FATAL from logging impor...
Sets the threshold for what messages will be logged.
23,192
from __future__ import absolute_import from __future__ import division from __future__ import print_function import logging as _logging import os as _os import sys as _sys import time as _time import traceback as _traceback from logging import DEBUG from logging import ERROR from logging import FATAL from logging impor...
null
23,193
def set_kwargs_or_defaults(obj, kwargs, default_attrs=None, keys=None): if default_attrs: keys = keys or default_attrs.keys() attrs_dict = get_kwargs_or_defaults(kwargs, default_attrs, keys) else: keys = keys or kwargs.keys() attrs_dict = kwargs for k, v in attrs_dict.items(): setattr(obj, k, ...
null
23,194
def not_implement(func): def wrapper(obj, *args, **kwargs): func(obj, *args, **kwargs) raise NotImplemented("{} {}".format(obj, func.__name__)) return wrapper
null
23,195
import numpy as np from nndct_shared.base import NNDCT_OP def get_batchnorm_params(param_list, param_getter, center=True, scale=True): #order: gamma,beta,mean,var if all(param_getter(p) is not None for p in param_list): param_shape = param_getter(param_list[-1]).shape bn_params = [] if center and scale...
null
23,196
import numpy as np from nndct_shared.base import NNDCT_OP def get_batchnorm_param_names(param_list, center=True, scale=True): if center and scale: assert len( param_list) == 4, "expect 4 parameters names, got " + str(param_list) return { 'gamma': param_list[0], 'beta': param_list[1], ...
null
23,197
import numpy as np from nndct_shared.base import NNDCT_OP def get_in_out_channel_idx(ndim, optype, data_formats): #TODO: same shape with different format, is this possible? if ndim == 1: return 0, 0 if optype == NNDCT_OP.CONV2D: if data_formats[optype] == 'HWIO': in_idx, out_idx = 2, 3 elif data...
null
23,198
import numpy as np from nndct_shared.base import NNDCT_OP def get_in_out_channel_idx(ndim, optype, data_formats): #TODO: same shape with different format, is this possible? if ndim == 1: return 0, 0 if optype == NNDCT_OP.CONV2D: if data_formats[optype] == 'HWIO': in_idx, out_idx = 2, 3 elif data...
null
23,199
import numpy as np from nndct_shared.base import NNDCT_OP def delete_in_out_channel_indexs(data, in_idx=None, out_idx=None, in_channel_array=None, out_channel_array=None): if in_idx is ...
null
23,200
import numpy as np from nndct_shared.base import NNDCT_OP def insert_in_out_channel_indexs(data, in_idx=None, out_idx=None, in_channel_array=None, out_channel_array=None): if in_idx is ...
null
23,201
import numpy as np from nndct_shared.base import NNDCT_OP def expand_in_out_channel_indexs(data, in_idx=None, out_idx=None, in_channel_array=None, out_channel_array=None): # assert len(...
null
23,202
from typing import TypeVar, NoReturn, Optional, Iterator, List from .option_list import NndctOption from .option_def import Option, T class NndctOption(object): nndct_help = Option(name="help", dtype=bool, default=False, action="store_true", help="list all api usage description") nndct_quan...
null
23,203
from typing import TypeVar, NoReturn, Optional, Iterator, List from .option_list import NndctOption from .option_def import Option, T class NndctOption(object): nndct_help = Option(name="help", dtype=bool, default=False, action="store_true", help="list all api usage description") nndct_quan...
null
23,204
from nndct_shared.base import NNDCT_KEYS, GLOBAL_MAP, NNDCT_DEBUG_LVL from .log import nndct_debug_print def get_split_sym(model_type): if model_type == 'Nndct': return '_' elif model_type in ['tensorflow', 'tf-keras']: return '/' elif model_type == 'torch': return '.' raise Exception("can not find...
null
23,205
from nndct_shared.base import NNDCT_KEYS, GLOBAL_MAP, NNDCT_DEBUG_LVL from .log import nndct_debug_print def default_scoped_name(obj): if isinstance(obj, str): name = obj else: name = obj.name return '/'.join(name.split('/')[:-1]), name.split('/')[-1]
null
23,206
from nndct_shared.base import NNDCT_KEYS, GLOBAL_MAP, NNDCT_DEBUG_LVL from .log import nndct_debug_print def get_default_name(obj): if isinstance(obj, str): return obj name = getattr(obj, 'name', None) if not name: raise Exception("{} has no attribute name, please check!".format(obj)) return name.split...
null
23,207
from nndct_shared.base import NNDCT_KEYS, GLOBAL_MAP, NNDCT_DEBUG_LVL from .log import nndct_debug_print def default_legal_name(name): return name.replace('.', 'DOT').replace('/', 'SPL')
null
23,208
from nndct_shared.base import NNDCT_KEYS, GLOBAL_MAP, NNDCT_DEBUG_LVL from .log import nndct_debug_print def derive_scope_name(name, scope, split_sym, offset=0): name_list = name.split(split_sym) for idx in range(len(name_list)): if name_list[idx].startswith(scope): base_idx = idx break return sp...
null
23,209
from nndct_shared.base import NNDCT_KEYS, GLOBAL_MAP, NNDCT_DEBUG_LVL from .log import nndct_debug_print def reverse_default_legal_name(name): return name.replace('DOT', '.').replace('SPL', '/')
null
23,210
from nndct_shared.base import NNDCT_KEYS, GLOBAL_MAP, NNDCT_DEBUG_LVL from .log import nndct_debug_print def remove_suffix(obj, suffix): if obj is None: return obj if suffix is None or suffix == '': return obj if isinstance(suffix, str): if isinstance(obj, str) and len(suffix) > 0 and obj.endswith(su...
null
23,211
from nndct_shared.base import NNDCT_KEYS, GLOBAL_MAP, NNDCT_DEBUG_LVL from .log import nndct_debug_print def remove_trans_scp_prefix(name, scp=None): def scoped_untrans_name(name, scp): org_name = remove_trans_scp_prefix(name, scp) return scp + org_name
null
23,212
from nndct_shared.base import NNDCT_KEYS, GLOBAL_MAP, NNDCT_DEBUG_LVL from .log import nndct_debug_print def remove_prefix(obj, prefix): def scoped_trans_name(name, scp): org_name = remove_prefix(name, scp) if org_name.startswith(NNDCT_KEYS.TRANS_SCOPE): return scp + org_name else: return scp + NNDCT_KEY...
null
23,213
from nndct_shared.base import NNDCT_KEYS, GLOBAL_MAP, NNDCT_DEBUG_LVL from .log import nndct_debug_print def remove_trans_scp_prefix(name, scp=None): GLOBAL_MAP = GlobalMap() def nndct_debug_print(string, title='', level=1): def map_output_and_node(output, node_or_name, model_type): if node_or_name is None: re...
null
23,214
from nndct_shared.base import NNDCT_KEYS, GLOBAL_MAP, NNDCT_DEBUG_LVL from .log import nndct_debug_print GLOBAL_MAP = GlobalMap() def node_from_output(output_name, model_type): if model_type == 'Nndct': return output_name if model_type == 'tensorflow': output_name = output_name.split(':')[0] elif model_...
null
23,215
from nndct_shared.base import NNDCT_KEYS, GLOBAL_MAP, NNDCT_DEBUG_LVL from .log import nndct_debug_print GLOBAL_MAP = GlobalMap() def get_output_from_node(node_name, idx=-1): node_map = GLOBAL_MAP.get_ele(NNDCT_KEYS.NODE_TO_OUTPUT_MAP) if node_map and node_name in node_map: return node_map[node_name][idx] r...
null
23,216
from nndct_shared.base import NNDCT_KEYS, GLOBAL_MAP, NNDCT_DEBUG_LVL from .log import nndct_debug_print GLOBAL_MAP = GlobalMap() def get_all_outputs_from_node(node_name): node_map = GLOBAL_MAP.get_ele(NNDCT_KEYS.NODE_TO_OUTPUT_MAP) if node_map and node_name in node_map: return node_map[node_name] return no...
null
23,217
import os import shutil import json import sys import numpy as np from .log import log_or_print from nndct_shared.base import NNDCT_KEYS, GLOBAL_MAP def to_des_dict(dicts, as_des=True, extra_types={}): assert isinstance(dicts,list) and all(isinstance(d,dict) for d in dicts),\ "dicts should be list of dictionari...
null
23,218
import os import shutil import json import sys import numpy as np from .log import log_or_print from nndct_shared.base import NNDCT_KEYS, GLOBAL_MAP def check_diff(matA, matB, nameA, nameB, error, with_msg=True): is_pass = True mat = matA - matB mat = mat / np.sqrt(matA**2 + error) title = "{:25} VS {:25} : "....
null
23,219
import os import shutil import json import sys import numpy as np from .log import log_or_print from nndct_shared.base import NNDCT_KEYS, GLOBAL_MAP def to_jsonstr(obj, pre_space=2): def _json_lst_str(lst): string = "" for idx in range(len(lst)): if isinstance(lst[idx], str): string += '"{}",'...
null
23,220
import os import shutil import json import sys import numpy as np from .log import log_or_print from nndct_shared.base import NNDCT_KEYS, GLOBAL_MAP def load_json_obj(file_or_obj): if isinstance(file_or_obj, str): with open(file_or_obj, 'r') as f: obj = json.load(f) elif isinstance(file_or_obj, dict): ...
null
23,221
import os import shutil import json import sys import numpy as np from .log import log_or_print from nndct_shared.base import NNDCT_KEYS, GLOBAL_MAP def dpu_format_print(mat): flatten_mat = mat.reshape(mat.size) cnt = 0 while cnt < len(flatten_mat): print(("{:0>2x}" * 16).format(*tuple(flatten_mat[cnt:cnt + ...
null
23,222
import os import shutil import json import sys import numpy as np from .log import log_or_print from nndct_shared.base import NNDCT_KEYS, GLOBAL_MAP def copy_folder_files(new_dir, old_dir): for file_name in os.listdir(old_dir): full_file_name = os.path.join(old_dir, file_name) if (os.path.isfile(full_file_nam...
null
23,223
import os import shutil import json import sys import numpy as np from .log import log_or_print from nndct_shared.base import NNDCT_KEYS, GLOBAL_MAP def print_center_edge(string, to_str=False, blank_line=0, width=120): center_str = "{0}>>{1:40}<<{0}".format("=" * 30, string.c...
null
23,224
import os import shutil import json import sys import numpy as np from .log import log_or_print from nndct_shared.base import NNDCT_KEYS, GLOBAL_MAP def log_or_print(str, logger=None): if logger: logger.info(str) else: print(str) def basic_info(mat, name=None, logger=None, to_str=False): if isinstance(m...
null
23,225
import os import shutil import json import sys import numpy as np from .log import log_or_print from nndct_shared.base import NNDCT_KEYS, GLOBAL_MAP def print_csv_format(mat): assert mat.ndim == 2 for row in range(mat.shape[0]): for col in range(mat.shape[1]): print(str(mat[row, col]) + ',', end='') ...
null