id
int64
0
190k
prompt
stringlengths
21
13.4M
docstring
stringlengths
1
12k
24,469
import torch from torch.autograd import Variable from nndct_shared.quantization import maybe_get_quantizer from nndct_shared.quantization import quantize_tensors import pytorch_nndct.utils as py_utils class deephi_MaxPool1d(torch.nn.modules.MaxPool1d): def __init__(self, *args, **kwards): def forward(self, in...
null
24,472
import torch from torch.autograd import Variable import math from nndct_shared.utils import NndctOption, NndctScreenLogger from nndct_shared.quantization import maybe_get_quantizer from nndct_shared.quantization import quantize_tensors from .quant_noise import eval_qnoise import pytorch_nndct.utils as py_utils import ...
null
24,478
import os import torch import torch.nn.functional as F from nndct_shared.utils import NndctOption, NndctScreenLogger from nndct_shared.base import NNDCT_CONSTANT from nndct_shared.quantization import maybe_get_quantizer from nndct_shared.quantization import quantize_tensors from nndct_shared.quantization import quant_r...
null
24,480
import os import torch import torch.nn.functional as F from nndct_shared.utils import NndctOption, NndctScreenLogger from nndct_shared.base import NNDCT_CONSTANT from nndct_shared.quantization import maybe_get_quantizer from nndct_shared.quantization import quantize_tensors from nndct_shared.quantization import quant_r...
null
24,481
import os import torch import torch.nn.functional as F from nndct_shared.utils import NndctOption, NndctScreenLogger from nndct_shared.base import NNDCT_CONSTANT from nndct_shared.quantization import maybe_get_quantizer from nndct_shared.quantization import quantize_tensors from nndct_shared.quantization import quant_r...
null
24,482
import os import torch import torch.nn.functional as F from nndct_shared.utils import NndctOption, NndctScreenLogger from nndct_shared.base import NNDCT_CONSTANT from nndct_shared.quantization import maybe_get_quantizer from nndct_shared.quantization import quantize_tensors from nndct_shared.quantization import quant_r...
null
24,487
import os import torch import torch.nn.functional as F from nndct_shared.utils import NndctOption, NndctScreenLogger from nndct_shared.base import NNDCT_CONSTANT from nndct_shared.quantization import maybe_get_quantizer from nndct_shared.quantization import quantize_tensors from nndct_shared.quantization import quant_r...
null
24,488
import os import torch import torch.nn.functional as F from nndct_shared.utils import NndctOption, NndctScreenLogger from nndct_shared.base import NNDCT_CONSTANT from nndct_shared.quantization import maybe_get_quantizer from nndct_shared.quantization import quantize_tensors from nndct_shared.quantization import quant_r...
null
24,490
import os import torch import torch.nn.functional as F from nndct_shared.utils import NndctOption, NndctScreenLogger from nndct_shared.base import NNDCT_CONSTANT from nndct_shared.quantization import maybe_get_quantizer from nndct_shared.quantization import quantize_tensors from nndct_shared.quantization import quant_r...
null
24,494
import torch from nndct_shared.quantization import maybe_get_quantizer from nndct_shared.quantization import quantize_tensors import pytorch_nndct.utils as py_utils class deephi_Cat(torch.nn.Module): r"""DeePhi Concat operation""" def __init__(self, *args, **kwargs): super(deephi_Cat, self).__init__() # sel...
null
24,502
import functools import torch from nndct_shared.base import GLOBAL_MAP, NNDCT_KEYS from nndct_shared.utils import NndctScreenLogger, QWarning from pytorch_nndct.utils.module_util import to_device, collect_input_devices, get_flattened_input_args GLOBAL_MAP = GlobalMap() def get_flattened_input_args(input): def _fla...
null
24,503
import torch from torch.autograd import Variable import torch.nn.functional as F from nndct_shared.quantization import maybe_get_quantizer from nndct_shared.quantization import quantize_tensors from nndct_shared.utils import NndctOption import pytorch_nndct.utils as py_utils from .fix_ops import fake_quantize_per_tenso...
null
24,504
import torch from nndct_shared.utils import NndctOption from nndct_shared.quantization import maybe_get_quantizer from nndct_shared.quantization import quantize_tensors import pytorch_nndct.utils as py_utils class deephi_Embedding(torch.nn.modules.sparse.Embedding): def __init__(self, *args, **kwargs): def f...
null
24,505
import torch from torch.autograd import Variable import math from nndct_shared.utils import NndctOption, NndctScreenLogger, QError, QWarning from nndct_shared.quantization import maybe_get_quantizer from nndct_shared.quantization import quantize_tensors from .quant_noise import eval_qnoise import pytorch_nndct.utils a...
null
24,507
import torch from torch.autograd import Variable import math from nndct_shared.utils import NndctOption, NndctScreenLogger from nndct_shared.quantization import maybe_get_quantizer from nndct_shared.quantization import quantize_tensors from .quant_noise import eval_qnoise import pytorch_nndct.utils as py_utils class de...
null
24,509
import torch from nndct_shared.quantization.utils import maybe_get_quantizer from nndct_shared.quantization import quantize_tensors import pytorch_nndct.utils as py_utils class deephi_Matmul(torch.nn.Module): def __init__(self): super(deephi_Matmul, self).__init__() self.quant_mode, self.quantizer = maybe_get...
null
24,510
import sys import torch from ..load_kernels import * import copy import numpy as np from nndct_shared.utils import NndctOption, NndctScreenLogger from pytorch_nndct.nn.utils.decorator import pre_and_post_process_f16_tensor from pytorch_nndct.utils.torch_utils import CmpFlag, compare_torch_version import torch from tor...
null
24,516
import sys import torch from ..load_kernels import * import copy import numpy as np from nndct_shared.utils import NndctOption, NndctScreenLogger from pytorch_nndct.nn.utils.decorator import pre_and_post_process_f16_tensor from pytorch_nndct.utils.torch_utils import CmpFlag, compare_torch_version def support_onnx_...
null
24,526
import sys import torch from ..load_kernels import * import copy import numpy as np from nndct_shared.utils import NndctOption, NndctScreenLogger from pytorch_nndct.nn.utils.decorator import pre_and_post_process_f16_tensor from pytorch_nndct.utils.torch_utils import CmpFlag, compare_torch_version def clone_view_te...
null
24,530
import sys import torch from ..load_kernels import * import copy import numpy as np from nndct_shared.utils import NndctOption, NndctScreenLogger from pytorch_nndct.nn.utils.decorator import pre_and_post_process_f16_tensor from pytorch_nndct.utils.torch_utils import CmpFlag, compare_torch_version def clone_view_te...
null
24,531
import sys import torch from ..load_kernels import * import copy import numpy as np from nndct_shared.utils import NndctOption, NndctScreenLogger from pytorch_nndct.nn.utils.decorator import pre_and_post_process_f16_tensor from pytorch_nndct.utils.torch_utils import CmpFlag, compare_torch_version def clone_view_te...
null
24,540
import torch from torch.autograd import Variable import math from nndct_shared.utils import NndctOption, NndctScreenLogger, QError from nndct_shared.quantization import kernel_need_quant from nndct_shared.quantization import quantize_tensors from nndct_shared.quantization import maybe_get_quantizer import pytorch_nndct...
null
24,541
import torch import torch.nn as nn import torch.nn.functional as F def get_same_padding(kernel_size): if isinstance(kernel_size, (tuple, list)): assert len(kernel_size) == 2, 'invalid kernel size: %s' % kernel_size p1 = get_same_padding(kernel_size[0]) p2 = get_same_padding(kernel_size[1]) return p1,...
null
24,542
import torch import torch.nn as nn import torch.nn.functional as F def sub_filter_start_end(kernel_size, sub_kernel_size): center = kernel_size // 2 dev = sub_kernel_size // 2 start, end = center - dev, center + dev + 1 assert end - start == sub_kernel_size return start, end
null
24,550
class ApproxModes(object): NO_APPROX = 'no_approx' EXP_POLY = 'exp_poly' EXP_LUT = 'exp_lut' QIO = 'quant_input_output' def is_quant_input_output(mode): return mode == ApproxModes.QIO
null
24,553
import torch import numpy as np from .coefficient import get_sigmoid_positive_ploy_coeffcients, get_exp_poly_coeffcients, get_gelu_tanh_poly_coeffcients, get_tanh_positive_poly_coeffcients from pytorch_nndct.utils.hw_dtype import is_subnormal, is_normal def ploy_HORNER_SCHEME(r, cs, degree): from pytorch_nndct.utils.to...
null
24,555
import torch import numpy as np from .coefficient import get_sigmoid_positive_ploy_coeffcients, get_exp_poly_coeffcients, get_gelu_tanh_poly_coeffcients, get_tanh_positive_poly_coeffcients from pytorch_nndct.utils.hw_dtype import is_subnormal, is_normal from pytorch_nndct.utils.torch_utils import CmpFlag, compare_torch...
null
24,556
import torch import numpy as np from .coefficient import get_sigmoid_positive_ploy_coeffcients, get_exp_poly_coeffcients, get_gelu_tanh_poly_coeffcients, get_tanh_positive_poly_coeffcients from pytorch_nndct.utils.hw_dtype import is_subnormal, is_normal from pytorch_nndct.utils.torch_utils import CmpFlag, compare_torch...
null
24,557
import torch import numpy as np from .coefficient import get_sigmoid_positive_ploy_coeffcients, get_exp_poly_coeffcients, get_gelu_tanh_poly_coeffcients, get_tanh_positive_poly_coeffcients from pytorch_nndct.utils.hw_dtype import is_subnormal, is_normal from pytorch_nndct.utils.torch_utils import CmpFlag, compare_torch...
null
24,568
import math import numpy as np import torch import torch.nn as nn import torch.nn.functional as F from pytorch_nndct.nn.modules import fix_ops from pytorch_nndct.nn.quantization.ops import tqt_ops class FakeQuantizer(nn.Module): """Simulate the quantize and dequantize operations in training time. In general, the ou...
null
24,570
import math import numpy as np import torch import torch.nn as nn import torch.nn.functional as F from pytorch_nndct.nn.modules import fix_ops from pytorch_nndct.nn.quantization.ops import tqt_ops class TQTQuantizer(FakeQuantizer): def __init__(self, bitwidth, tensor_type, rounding_mode): super(TQTQuantizer, self...
null
24,571
import math import numpy as np import torch import torch.nn as nn import torch.nn.functional as F from pytorch_nndct.nn.modules import fix_ops from pytorch_nndct.nn.quantization.ops import tqt_ops class TQTQuantizer(FakeQuantizer): def __init__(self, bitwidth, tensor_type, rounding_mode): def _init_threshold(...
null
24,572
import math import numpy as np import torch import torch.nn as nn import torch.nn.functional as F from pytorch_nndct.nn.modules import fix_ops from pytorch_nndct.nn.quantization.ops import tqt_ops class TQTQuantizer(FakeQuantizer): def __init__(self, bitwidth, tensor_type, rounding_mode): def _init_threshold(...
null
24,573
import math import numpy as np import torch import torch.nn as nn import torch.nn.functional as F from pytorch_nndct.nn.modules import fix_ops from pytorch_nndct.nn.quantization.ops import tqt_ops class TQTQuantizer(FakeQuantizer): def __init__(self, bitwidth, tensor_type, rounding_mode): super(TQTQuantizer, self...
null
24,579
import torch import torch.nn as nn import torch.nn.functional as F from pytorch_nndct.nn.quantization.ops import quantize_ops from pytorch_nndct.utils import onnx_utils def transform_to_block_wise(input, block_size=8, axis=1): """Transform input tensor to block-wised format (i.e. the block in last dimension) at giv...
null
24,581
import torch import torch.nn as nn import torch.nn.functional as F from pytorch_nndct.nn.quantization.ops import quantize_ops from pytorch_nndct.utils import onnx_utils def pad_to_block_last(tensor, block_size=8, axis=1): """Transpose input tensor to block-wised format (i.e. the block in last dimension) by given ax...
null
24,582
import torch import torch.nn as nn import torch.nn.functional as F from pytorch_nndct.nn.quantization.ops import quantize_ops from pytorch_nndct.utils import onnx_utils def transform_to_block_wise(input, block_size=8, axis=1): """Transform input tensor to block-wised format (i.e. the block in last dimension) at giv...
null
24,584
import torch from pytorch_nndct.nn.quantization.ops import round_ops def quantize(tensor, scale, round_mode, min_v, max_v): round_fn = round_ops.get(round_mode) #return torch.min(torch.max(round_fn(tensor / scale) * scale, min_v), max_v) return torch.clamp(round_fn(tensor / scale) * scale, min_v, max_v)
null
24,586
import torch The provided code snippet includes necessary dependencies for implementing the `get` function. Write a Python function `def get(identifier)` to solve the following problem: Returns rounding function. Args: identifier: String identifier. Returns: Function corresponding to the input string. For example: >>>...
Returns rounding function. Args: identifier: String identifier. Returns: Function corresponding to the input string. For example: >>> round.get('round_even') <function round_even at 0x1222a3d90> Raises: ValueError: Input is an unknown string. TypeError: If input is not string.
24,595
import copy import importlib import os import random import string import sys import tempfile import torch from torch.nn import DataParallel from torch.nn.parallel import DistributedDataParallel from nndct_shared.nndct_graph.base_tensor import Tensor from nndct_shared.pruning import errors from pytorch_nndct import par...
Pad tensor with zeros by given pruning_info. Restore the tensor to its original unpruned shape and use zeros to fill in the removed input/output channels. [100, 60, 3, 3] -> [128, 64, 3, 3]
24,597
import copy import importlib import os import random import string import sys import tempfile import torch from torch.nn import DataParallel from torch.nn.parallel import DistributedDataParallel from nndct_shared.nndct_graph.base_tensor import Tensor from nndct_shared.pruning import errors from pytorch_nndct import par...
null
24,601
import copy import importlib import os import random import string import sys import tempfile import torch from torch.nn import DataParallel from torch.nn.parallel import DistributedDataParallel from nndct_shared.nndct_graph.base_tensor import Tensor from nndct_shared.pruning import errors from pytorch_nndct import par...
null
24,614
from nndct_shared.nndct_graph.base_tensor import Tensor from pytorch_nndct.utils import TorchGraphSymbol from .rich_in_out_helper import FlattenInOutModelForTrace class TorchScriptModuleHandler(object): def __init__(self): self._extra_node_input_args = defaultdict(list) def build_torch_graph(self, graph_n...
null
24,617
import torch import torch import math import functools from nndct_shared.utils import (AddXopError, NndctOption, NndctScreenLogger, option_util, QError, QWarning) def convert_tensor_to_tracetensor(data): if isinstance(data, torch.Tensor): return data.as_subclass(TraceTensor) ...
null
24,618
import torch import torch import math import functools from nndct_shared.utils import (AddXopError, NndctOption, NndctScreenLogger, option_util, QError, QWarning) class TraceTensor(torch.Tensor): def __torch_function__(cls, func, types, args=(), kwargs=None): if kwargs is None: ...
null
24,621
import torch import torch import math import functools from nndct_shared.utils import (AddXopError, NndctOption, NndctScreenLogger, option_util, QError, QWarning) def logging_warn(message): class TraceTensor(torch.Tensor): def __torch_function__(cls, func, types, args=(), kwargs=Non...
null
24,622
import torch import torch import math import functools from nndct_shared.utils import (AddXopError, NndctOption, NndctScreenLogger, option_util, QError, QWarning) def logging_warn(message): NndctScreenLogger().warning2user(QWarning.FLOAT_OP, message) class TraceTensor(torch.Tensor): ...
null
24,626
import math import numpy as np from nndct_shared.base import NNDCT_OP from nndct_shared.utils import PatternType from nndct_shared.nndct_graph import GraphSearcher, Tensor from pytorch_nndct.parse.torch_op_def import TorchConvTranspose2d, TorchConv2d from .device import DeviceInfo, DeviceType from .target_helper import...
null
24,627
import math import numpy as np from nndct_shared.base import NNDCT_OP from nndct_shared.utils import PatternType from nndct_shared.nndct_graph import GraphSearcher, Tensor from pytorch_nndct.parse.torch_op_def import TorchConvTranspose2d, TorchConv2d from .device import DeviceInfo, DeviceType from .target_helper import...
null
24,632
import math import numpy as np from nndct_shared.base import NNDCT_OP from nndct_shared.utils import PatternType from nndct_shared.nndct_graph import GraphSearcher, Tensor from pytorch_nndct.parse.torch_op_def import TorchConvTranspose2d, TorchConv2d from .device import DeviceInfo, DeviceType from .target_helper import...
null
24,641
import math import numpy as np from nndct_shared.base import NNDCT_OP from nndct_shared.utils import PatternType from nndct_shared.nndct_graph import GraphSearcher, Tensor from pytorch_nndct.parse.torch_op_def import TorchConvTranspose2d, TorchConv2d from .device import DeviceInfo, DeviceType from .target_helper import...
null
24,642
import math import numpy as np from nndct_shared.base import NNDCT_OP from nndct_shared.utils import PatternType from nndct_shared.nndct_graph import GraphSearcher, Tensor from pytorch_nndct.parse.torch_op_def import TorchConvTranspose2d, TorchConv2d from .device import DeviceInfo, DeviceType from .target_helper import...
null
24,643
def get_meta_info(meta, info_type): return getattr(meta, info_type)
null
24,644
The provided code snippet includes necessary dependencies for implementing the `convert_dtype` function. Write a Python function `def convert_dtype(dtype)` to solve the following problem: r"""convert torch dtype to nndct dtype Here is the function: def convert_dtype(dtype): r"""convert torch dtype to nndct dtype"...
r"""convert torch dtype to nndct dtype
24,645
def convert_shape(shape): return list(shape)
null
24,653
import numbers from collections import namedtuple import torch from nndct_shared.base import NNDCT_OP from nndct_shared.nndct_graph import Tensor from pytorch_nndct.parse.torch_op_def import * from pytorch_nndct.fx.translator_utils import convert_dtype, convert_shape def int2tuple(obj, tuple_size): if isinstance(obj,...
null
24,665
import itertools import torch from torch.fx.passes.fake_tensor_prop import FakeTensorProp from torch._subclasses.fake_tensor import FakeTensor from torch.fx.passes.shape_prop import _extract_tensor_metadata from torch.fx.node import map_aggregate from torch.fx.passes.shape_prop import ShapeProp class ValueMetaProp(Fake...
null
24,666
def replace_node(graph, old_node, new_node): old_node.replace_all_uses_with(new_node) graph.erase_node(old_node) new_node.meta = old_node.meta
null
24,668
import operator import itertools import torch from pytorch_nndct.fx.optimization.utils import replace_node LEAF_MODULES = { "Conv2d", "BatchNorm2d", "Linear" } NORMALIZE_METHOD_FUNCTION = { operator.add : torch.add, operator.iadd : torch.add } def expand_module_call(prefix: str, graph: torch.fx.graph, module,...
null
24,669
import copy import torch from torch.fx.experimental.optimization import ( matches_module_pattern, replace_node_module) from torch.nn import functional as F from torch.nn.utils.fusion import fuse_conv_bn_eval, fuse_conv_bn_weights from torch.fx.interpreter import Transformer from pytorch_nndct.fx.optimization.ut...
null
24,671
import copy import os from typing import Any, Optional, Sequence, Union, List, Dict, Tuple import torch from nndct_shared.utils import NndctScreenLogger, NndctOption, QError, QWarning, QNote from .qproc import TorchQuantProcessor from .qproc import base as qp from .qproc import LSTMTorchQuantProcessor, RNNQuantProcesso...
null
24,672
from nndct_shared.utils import set_option_value, NndctOption from pytorch_nndct.qproc.utils import (get_deploy_graph_list, prepare_quantizable_module, register_output_hook, set_outputs_recorder_status, t...
null
24,674
import importlib.util import os import sys from typing import Any, NoReturn, Optional, Sequence, Tuple, Union, List import itertools import torch import torch.nn as nn import torch.nn.functional as F import nndct_shared.utils as nndct_utils import pytorch_nndct.utils.jit_utils as jit_utils import pytorch_nndct.utils.mo...
null
24,675
import importlib.util import os import sys from typing import Any, NoReturn, Optional, Sequence, Tuple, Union, List import itertools import torch import torch.nn as nn import torch.nn.functional as F import nndct_shared.utils as nndct_utils import pytorch_nndct.utils.jit_utils as jit_utils import pytorch_nndct.utils.mo...
null
24,677
import importlib.util import os import sys from typing import Any, NoReturn, Optional, Sequence, Tuple, Union, List import itertools import torch import torch.nn as nn import torch.nn.functional as F import nndct_shared.utils as nndct_utils import pytorch_nndct.utils.jit_utils as jit_utils import pytorch_nndct.utils.mo...
null
24,682
import importlib.util import os import sys from typing import Any, NoReturn, Optional, Sequence, Tuple, Union, List import itertools import torch import torch.nn as nn import torch.nn.functional as F import nndct_shared.utils as nndct_utils import pytorch_nndct.utils.jit_utils as jit_utils import pytorch_nndct.utils.mo...
null
24,688
import copy import os import torch from nndct_shared.base import GLOBAL_MAP, NNDCT_KEYS, NNDCT_OP from nndct_shared.utils import (AddXopError, NndctOption, NndctScreenLogger, option_util, QError, QWarning, set_option_value) from pytorch_nndct.utils.torch_utils import CmpFlag, compare_tor...
null
24,691
import copy import functools import itertools import types import torch from torch.utils._python_dispatch import _disable_current_modes from nndct_shared.base import GLOBAL_MAP, NNDCT_KEYS, NNDCT_OP from nndct_shared.nndct_graph import (Block, Graph, Node, convert_graph_to_block_no...
null
24,692
import copy import functools import itertools import types import torch from torch.utils._python_dispatch import _disable_current_modes from nndct_shared.base import GLOBAL_MAP, NNDCT_KEYS, NNDCT_OP from nndct_shared.nndct_graph import (Block, Graph, Node, convert_graph_to_block_no...
null
24,700
from torch import nn from typing import Any, List, Mapping import os import torch import torch.onnx from nndct_shared.expanding.spec import ExpandingSpec from nndct_shared.pruning import logging from pytorch_nndct.expanding.structured import ExpandingRunner from pytorch_nndct.utils import profiler class ExpandingRunne...
null
24,701
from torch import nn from typing import Any, List, Mapping import os import torch import torch.onnx from nndct_shared.expanding.spec import ExpandingSpec from nndct_shared.pruning import logging from pytorch_nndct.expanding.structured import ExpandingRunner from pytorch_nndct.utils import profiler class ExpandingSpec(...
null
24,706
import copy import os import torch import types from nndct_shared.base import NNDCT_OP as OpTypes from nndct_shared.optimization.optimizer import QuantOptimizer from nndct_shared.utils import NndctOption from nndct_shared.utils import NndctScreenLogger from nndct_shared.utils import io as io_util from nndct_shared.util...
null
24,707
import copy import os import torch import types from nndct_shared.base import NNDCT_OP as OpTypes from nndct_shared.optimization.optimizer import QuantOptimizer from nndct_shared.utils import NndctOption from nndct_shared.utils import NndctScreenLogger from nndct_shared.utils import io as io_util from nndct_shared.util...
null
24,708
import copy import os import torch import types from nndct_shared.base import NNDCT_OP as OpTypes from nndct_shared.optimization.optimizer import QuantOptimizer from nndct_shared.utils import NndctOption from nndct_shared.utils import NndctScreenLogger from nndct_shared.utils import io as io_util from nndct_shared.util...
null
24,709
import copy import os import torch import types from nndct_shared.base import NNDCT_OP as OpTypes from nndct_shared.optimization.optimizer import QuantOptimizer from nndct_shared.utils import NndctOption from nndct_shared.utils import NndctScreenLogger from nndct_shared.utils import io as io_util from nndct_shared.util...
null
24,710
import copy import os import torch import types from nndct_shared.base import NNDCT_OP as OpTypes from nndct_shared.optimization.optimizer import QuantOptimizer from nndct_shared.utils import NndctOption from nndct_shared.utils import NndctScreenLogger from nndct_shared.utils import io as io_util from nndct_shared.util...
null
24,711
import copy import os import torch import types from nndct_shared.base import NNDCT_OP as OpTypes from nndct_shared.optimization.optimizer import QuantOptimizer from nndct_shared.utils import NndctOption from nndct_shared.utils import NndctScreenLogger from nndct_shared.utils import io as io_util from nndct_shared.util...
null
24,712
import copy import os import torch import types from nndct_shared.base import NNDCT_OP as OpTypes from nndct_shared.optimization.optimizer import QuantOptimizer from nndct_shared.utils import NndctOption from nndct_shared.utils import NndctScreenLogger from nndct_shared.utils import io as io_util from nndct_shared.util...
null
24,713
import copy import os import torch import types from nndct_shared.base import NNDCT_OP as OpTypes from nndct_shared.optimization.optimizer import QuantOptimizer from nndct_shared.utils import NndctOption from nndct_shared.utils import NndctScreenLogger from nndct_shared.utils import io as io_util from nndct_shared.util...
null
24,714
import copy import os import torch import types from nndct_shared.base import NNDCT_OP as OpTypes from nndct_shared.optimization.optimizer import QuantOptimizer from nndct_shared.utils import NndctOption from nndct_shared.utils import NndctScreenLogger from nndct_shared.utils import io as io_util from nndct_shared.util...
null
24,715
import copy import os import torch import types from nndct_shared.base import NNDCT_OP as OpTypes from nndct_shared.optimization.optimizer import QuantOptimizer from nndct_shared.utils import NndctOption from nndct_shared.utils import NndctScreenLogger from nndct_shared.utils import io as io_util from nndct_shared.util...
null
24,716
import copy import os import torch import types from nndct_shared.base import NNDCT_OP as OpTypes from nndct_shared.optimization.optimizer import QuantOptimizer from nndct_shared.utils import NndctOption from nndct_shared.utils import NndctScreenLogger from nndct_shared.utils import io as io_util from nndct_shared.util...
null
24,718
import copy import numpy as np from abc import ABC, abstractmethod import torch from nndct_shared.base import key_names, NNDCT_OP from nndct_shared.utils import tensor_util, NndctOption, NndctScreenLogger, QWarning, QError from pytorch_nndct.nn import fake_quantize_per_tensor def has_inf_nan(): def is_valid_tensor_for...
null
24,721
import copy import json import yaml from typing import Union def get(identifier): globs = globals() if identifier not in globs: raise ValueError(f'Unknown dtype: {identifier}') return globs[identifier]()
null
24,722
import sys import numpy as np from abc import ABC, abstractmethod from scipy.stats import entropy from scipy import stats import torch from collections import Counter import pytorch_nndct as py_nndct from pytorch_nndct.nn.modules.fix_ops import diffs_fix_pos from nndct_shared.utils import NndctOption, NndctScreenLogger...
null
24,724
from pytorch_nndct.utils import module_util as mod_util class TopoNode(object): def __init__(self, name, in_quant_part, spec=None, module=None, inputs=None, op=None): def __str__(self): class Mode...
null
24,726
from torch import nn import numpy as np import torch import types from nndct_shared.base import NNDCT_OP from nndct_shared.pruning.pruner import load_pruning_info from pytorch_nndct.utils import TorchGraphSymbol from pytorch_nndct.utils import tensor_util def state_dict_from_node(node): state_dict = {} # Copy from ...
null
24,729
from torch import nn import numpy as np import torch import types from nndct_shared.base import NNDCT_OP from nndct_shared.pruning.pruner import load_pruning_info from pytorch_nndct.utils import TorchGraphSymbol from pytorch_nndct.utils import tensor_util def enable_dump_blob(model, graph=False, mode='print'): node_a...
null
24,731
from torch import nn import numpy as np import torch import types from nndct_shared.base import NNDCT_OP from nndct_shared.pruning.pruner import load_pruning_info from pytorch_nndct.utils import TorchGraphSymbol from pytorch_nndct.utils import tensor_util def get_module_name(module): if isinstance(module, torch.jit....
null
24,733
from torch import nn import numpy as np import torch import types from nndct_shared.base import NNDCT_OP from nndct_shared.pruning.pruner import load_pruning_info from pytorch_nndct.utils import TorchGraphSymbol from pytorch_nndct.utils import tensor_util def get_flattened_input_args(input): def _flatten_args(input...
null
24,734
from torch import nn import numpy as np import torch import types from nndct_shared.base import NNDCT_OP from nndct_shared.pruning.pruner import load_pruning_info from pytorch_nndct.utils import TorchGraphSymbol from pytorch_nndct.utils import tensor_util def collect_input_devices(input_args): def _collect_device(i...
null
24,735
from torch import nn import numpy as np import torch import types from nndct_shared.base import NNDCT_OP from nndct_shared.pruning.pruner import load_pruning_info from pytorch_nndct.utils import TorchGraphSymbol from pytorch_nndct.utils import tensor_util def to_device(module, input_args, device): if input_args is ...
null
24,736
from torch import nn import numpy as np import torch import types from nndct_shared.base import NNDCT_OP from nndct_shared.pruning.pruner import load_pruning_info from pytorch_nndct.utils import TorchGraphSymbol from pytorch_nndct.utils import tensor_util class FlattenInOutModelForTrace(torch.nn.Module): def getMo...
null
24,737
from nndct_shared.pruning.pruning_lib import PruningSpec from nndct_shared.nndct_graph import Graph from nndct_shared.pruning.sensitivity import NetSensitivity from typing import Mapping, List from pytorch_nndct.utils import TorchGraphSymbol, logging def extract_scope_name(node_name: str) -> str: return node_name.rsp...
null
24,738
from nndct_shared.pruning.pruning_lib import PruningSpec from nndct_shared.nndct_graph import Graph from nndct_shared.pruning.sensitivity import NetSensitivity from typing import Mapping, List from pytorch_nndct.utils import TorchGraphSymbol, logging def extract_scope_name(node_name: str) -> str: return node_name.rsp...
null
24,740
import numpy as np import nndct_shared.utils.tensor_util as tu from nndct_shared.base import FrameworkType def param_to_nndct_format(tensor): tu.convert_parameter_tensor_format(tensor, FrameworkType.TORCH, FrameworkType.NNDCT)
null
24,741
import numpy as np import nndct_shared.utils.tensor_util as tu from nndct_shared.base import FrameworkType def param_to_torch_format(tensor): tu.convert_parameter_tensor_format(tensor, FrameworkType.NNDCT, FrameworkType.TORCH)
null
24,749
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
24,750
import torch from pytorch_nndct.utils.torch_utils import CmpFlag, compare_torch_version def get_opset_version(): if "_onnx_stable_opsets" in torch.onnx.symbolic_helper.__dict__: return torch.onnx.symbolic_helper._onnx_stable_opsets[-1] elif "onnx_stable_opsets" in torch.onnx._constants.__dict__: return t...
null
24,752
import contextlib import re import itertools import torch.jit from torch.jit import _unique_state_dict from torch.nn import ModuleList from .schema import SchemaHelper, convert_type_str from .torch_const import TorchGraphSymbol from nndct_shared.utils import DeprecatedAPIError, NndctScreenLogger, NndctDebugLogger, Nndc...
null