id
int64
0
190k
prompt
stringlengths
21
13.4M
docstring
stringlengths
1
12k
24,753
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
24,758
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
24,761
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
24,762
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
24,763
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
24,764
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
24,768
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
24,770
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
24,771
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
24,772
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
24,773
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
24,774
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
24,775
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
24,776
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
24,777
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
24,778
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
24,779
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
24,781
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
24,786
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
24,787
import torch from torch import nn from distutils.version import LooseVersion from enum import unique, Enum class CmpFlag(Enum): """ Enum for comparison flags """ EQUAL = 0 LESS = 1 LESS_EQUAL = 2 GREATER = 3 GREATER_EQUAL = 4 NOT_EQUAL = 5 def compare_torch_version(compare_type:CmpFlag, version:str):...
null
24,788
import torch from torch import nn from distutils.version import LooseVersion from enum import unique, Enum def strip_parallel(model): if isinstance( model, (nn.parallel.DataParallel, nn.parallel.DistributedDataParallel)): return model.module return model
null
24,791
import functools import inspect import types from typing import List, Optional from nndct_shared.utils import GLOBAL_MAP, NNDCT_KEYS, NndctScreenLogger, NNDCT_OP, QError, QWarning, QNote import torch from .nndct2torch_op_map import add_mapping_item from .torch_const import TorchSymbol from .torch_op_attr import gen_at...
null
24,793
from typing import NamedTuple from typing import Iterator, Iterable import math import numpy as np The provided code snippet includes necessary dependencies for implementing the `is_subnormal` function. Write a Python function `def is_subnormal(x)` to solve the following problem: Returns a boolean `numpy` array for wh...
Returns a boolean `numpy` array for whether the elements in `x` are subnormal. Args: x (numpy array): input Returns: Boolean array indicating whether elements are subnormal
24,794
from typing import NamedTuple from typing import Iterator, Iterable import math import numpy as np The provided code snippet includes necessary dependencies for implementing the `is_normal` function. Write a Python function `def is_normal(x)` to solve the following problem: Returns a boolean `numpy` array for whether ...
Returns a boolean `numpy` array for whether the elements in `x` are normal. Args: x (numpy array): input Returns: Boolean array indicating whether elements are normal
24,799
from torch import nn The provided code snippet includes necessary dependencies for implementing the `load_state_dict` function. Write a Python function `def load_state_dict(model, state_dict)` to solve the following problem: Update the model so that the shape of the parameters match the weights in state dict, and then...
Update the model so that the shape of the parameters match the weights in state dict, and then load the state dict to the updated model.
24,811
import re def convert_type_str(typing_str): if '[' not in typing_str: return typing_str special_type = typing_str.split('[')[0] pattern, rlp_fn = patterns_rlp_pair[special_type] return pattern.sub(rlp_fn, typing_str) def _match_brackets(match): outer_type_str = match[1] inner_type_str =...
null
24,814
from glob import glob from nndct_shared.base import NNDCT_OP from nndct_shared.utils import NndctScreenLogger def get_torch_op_2_nndct_op_map(): def get_nndct_op_type(torch_op_type): if get_torch_op_2_nndct_op_map().get(torch_op_type, None) is None: #raise Exception('please register the operator:"{}"'.format(...
null
24,816
import time import torch from torch import nn from nndct_shared.utils import common from pytorch_nndct.utils import logging from pytorch_nndct.utils import torch_utils class MetricName(object): def _accumulate_metric_value(module, metric_name, value): def count_linear(module, input, output): # (N, *, Hin) x (Hin, Ho...
null
24,820
import time import torch from torch import nn from nndct_shared.utils import common from pytorch_nndct.utils import logging from pytorch_nndct.utils import torch_utils class MetricName(object): def _accumulate_metric_value(module, metric_name, value): def count_prelu(module, input, output): MACs = input[0].numel() ...
null
24,822
import time import torch from torch import nn from nndct_shared.utils import common from pytorch_nndct.utils import logging from pytorch_nndct.utils import torch_utils class MetricName(object): def _accumulate_metric_value(module, metric_name, value): def count_sigmoid(module, input, output): MACs = 0 Flops = 4 * ...
null
24,825
import time import torch from torch import nn from nndct_shared.utils import common from pytorch_nndct.utils import logging from pytorch_nndct.utils import torch_utils class MetricName(object): MACs = 'MACs' FLOPs = 'FLOPs' TrainableParams = 'trainable' NonTrainableParams = 'non-trainable' def _accumulate_metri...
null
24,826
import time import torch from torch import nn from nndct_shared.utils import common from pytorch_nndct.utils import logging from pytorch_nndct.utils import torch_utils def prepare_for_inference(model, inputs): model = torch_utils.strip_parallel(model) if torch.cuda.is_available(): model.cuda() if isinstance...
null
24,829
import tensorflow as tf from typing import List, Mapping from tf1_nndct.optimization.constant import OpType from queue import Queue import numpy as np class NodeGroupUnion(object): def __init__(self) -> None: def add_node(self, node: str) -> None: def find(self, node: str) -> int: def union(self, no...
null
24,830
import tensorflow as tf from typing import List, Mapping from tf1_nndct.optimization.constant import OpType from queue import Queue import numpy as np def find_weight_nodes(node: tf.compat.v1.NodeDef, node_def_map: Mapping[str, tf.compat.v1.NodeDef]) -> List[tf.compat.v1.NodeDef]: class OpType(object): def calculate_...
null
24,833
import tensorflow as tf from typing import List, Mapping from tf1_nndct.optimization.constant import OpType from queue import Queue import numpy as np def get_input_node_name(input_name: str) -> str: if input_name.startswith("^"): input_name = input_name[1:] return input_name.split(":")[0] def topo_sort(graph_...
null
24,834
import tensorflow as tf from tensorflow.core.framework.tensor_pb2 import TensorProto from tf1_nndct.optimization.utils import group_conv_nodes, find_weight_nodes, is_matmul, \ is_conv, is_depthwise_conv, is_concat, is_weighted_node, calculate_flops, get_input_node_name, \ topo_sort, find_ancestor_target_nodes from ...
null
24,835
import argparse import sys import subprocess from xnnc.version import __version__, __git_version__ def version_string(): class BatchsizeAction(argparse.Action): def __call__(self, parser, namespace, values, option_string=None): class ParseKwargs(argparse.Action): def __call__(self, parser, namespace, values, ...
null
24,836
import sys from pathlib import Path from typing import List from xnnc.ir.enums import TargetType from xnnc.xconverter import XConverter, __version__ def validate(model_t: bool, model_files): t = model_t.lower() if t == "caffe": return len(model_files) == 2 elif t in ["tensorflow", "tensorflow2"]: ...
null
24,837
import time from collections import OrderedDict from typing import Any, Dict, List, NoReturn, Optional import numpy as np import torch from torch.onnx.utils import OperatorExportTypes import graphviz class NodePyIO(NodePy): def __init__(self, node_cpp, input_or_output=None): super(NodePyIO, self).__init__(n...
null
24,838
from pathlib import Path from enum import Enum, auto import graphviz The provided code snippet includes necessary dependencies for implementing the `copy_data` function. Write a Python function `def copy_data(src_layer, dst_layer)` to solve the following problem: Copy items from src_layer into dst_layer, which are in ...
Copy items from src_layer into dst_layer, which are in src_layer, but not in dst_layer :param src_layer: a source dict :param dst_layer: a destination dict
24,839
from pathlib import Path from enum import Enum, auto import graphviz The provided code snippet includes necessary dependencies for implementing the `check_filepath` function. Write a Python function `def check_filepath(file_path: Path, extension: str = None) -> (bool, str, Path)` to solve the following problem: Check ...
Check if the specified file path is valid. If extension is specified, also check if the file contained in the file path has the same extension name. Parameters: file_path: Path, an instance of Path indicating the path of a file. extension: str, the extension name the file should have. Return: (flag, error_msg, file_pat...
24,840
from pathlib import Path from enum import Enum, auto import graphviz The provided code snippet includes necessary dependencies for implementing the `render_xmodel` function. Write a Python function `def render_xmodel(xmodel, filename=None, directory=None, view=False, cleanup=False)` to solve the following problem: Vis...
Visualize an XModel instance with the Graphviz engine. Parameters: - xgraph: an XModel instance - filename: Filename for saving the source. - directory: (Sub)directory for source saving and rendering. - view: Open the rendered result with the default application. - cleanup: Delete the source file after rendering.
24,841
from pathlib import Path from enum import Enum, auto import graphviz The provided code snippet includes necessary dependencies for implementing the `render_xmodel_opt` function. Write a Python function `def render_xmodel_opt(xmodel, filename=None, directory=None, view=False, cleanup=False)` to solve the following prob...
Visualize an optimized XModel instance with the Graphviz engine. Parameters: - xgraph: an XModel instance - filename: Filename for saving the source. - directory: (Sub)directory for source saving and rendering. - view: Open the rendered result with the default application. - cleanup: Delete the source file after render...
24,842
from functools import wraps from contextlib import contextmanager import time def timefunc(func): @wraps(func) def wrapper(*args, **kwargs): start = time.clock() r = func(*args, **kwargs) end = time.clock() print("{}.{}: {} seconds".format(func.__module__, func.__name__, end - s...
null
24,843
from functools import wraps from contextlib import contextmanager import time def timeblock(label): start = time.clock() try: yield finally: end = time.clock() print("{} : {} seconds".format(label, end - start))
null
24,844
import numpy as np import tensorflow as tf import onnx import os from tf2onnx import utils from tf2onnx.handler import tf_op from tf2onnx.tf_loader import tf_placeholder tf_library_path = os.path.join(DIR_PATH, "double_and_add_one.so") import onnxruntime as ort def func(x): custom_op = tf.load_op_library(tf_librar...
null
24,845
import os import sys import time import tarfile import subprocess import datetime import numpy from tqdm import tqdm import tensorflow_hub as hub import onnxruntime as ort from tf2onnx import utils imgs = generate_random_images() def generate_random_images(shape=(100, 100), n=10): imgs = [] for i in range(n): ...
null
24,846
import os import sys import time import tarfile import subprocess import datetime import numpy from tqdm import tqdm import tensorflow_hub as hub import onnxruntime as ort from tf2onnx import utils The provided code snippet includes necessary dependencies for implementing the `measure_time` function. Write a Python fu...
Runs *n* times the same function taking one parameter from *imgs*. It stops if the total time overcomes *timeout*. It also runs once the function before measuring.
24,847
import os import sys import time import tarfile import subprocess import datetime import numpy from tqdm import tqdm import tensorflow_hub as hub import onnxruntime as ort from tf2onnx import utils fpath, tname = download_model(url, dest) print("Created %r, %r." % (fpath, tname)) print("Convert model in %r." % dest) pr...
Downloads a model from tfhub and unzips it. The function assumes the format is `.tar.gz`.
24,848
import os import sys import time import tarfile import subprocess import datetime import numpy from tqdm import tqdm import tensorflow_hub as hub import onnxruntime as ort from tf2onnx import utils print("Created %r, %r." % (fpath, tname)) print("Convert model in %r." % dest) print("Created %r." % onnx_name) print("Gen...
Converts the downloaded model into ONNX.
24,849
import tensorflow as tf import tf2onnx from onnx import helper _TENSORFLOW_DOMAIN = "ai.onnx.converters.tensorflow" def print_handler(ctx, node, name, args): # replace tf.Print() with Identity # T output = Print(T input, data, @list(type) U, @string message, @int first_n, @int summarize) # becomes: #...
null
24,850
import tensorflow as tf import tf2onnx import numpy as np import onnxruntime as ort import os def f(a, b): return a + b
null
24,851
import os import re import shutil import tempfile import types import zipfile import logging import requests from requests.adapters import HTTPAdapter from urllib3.util.retry import Retry import numpy as np from google.protobuf import text_format from onnx import helper, onnx_pb, defs, numpy_helper, ModelProto, __versi...
null
24,852
import os import re import shutil import tempfile import types import zipfile import logging import requests from requests.adapters import HTTPAdapter from urllib3.util.retry import Retry import numpy as np from google.protobuf import text_format from onnx import helper, onnx_pb, defs, numpy_helper, ModelProto, __versi...
Avoid name conflicts by initializing the counter used by make_name based on the provided model
24,853
import os import re import shutil import tempfile import types import zipfile import logging import requests from requests.adapters import HTTPAdapter from urllib3.util.retry import Retry import numpy as np from google.protobuf import text_format from onnx import helper, onnx_pb, defs, numpy_helper, ModelProto, __versi...
Save onnx model as file. Save a pbtxt file as well if as_text is True
24,854
import os import re import shutil import tempfile import types import zipfile import logging import requests from requests.adapters import HTTPAdapter from urllib3.util.retry import Retry import numpy as np from google.protobuf import text_format from onnx import helper, onnx_pb, defs, numpy_helper, ModelProto, __versi...
Produces an onnx float seed from two tf int seeds. Returns None if both seeds are 0.
24,855
import os import re import shutil import tempfile import types import zipfile import logging import requests from requests.adapters import HTTPAdapter from urllib3.util.retry import Retry import numpy as np from google.protobuf import text_format from onnx import helper, onnx_pb, defs, numpy_helper, ModelProto, __versi...
null
24,856
import os import re import shutil import tempfile import types import zipfile import logging import requests from requests.adapters import HTTPAdapter from urllib3.util.retry import Retry import numpy as np from google.protobuf import text_format from onnx import helper, onnx_pb, defs, numpy_helper, ModelProto, __versi...
Construct Graph from nodes and outputs with specified shapes and dtypes.
24,857
import os import re import shutil import tempfile import types import zipfile import logging import requests from requests.adapters import HTTPAdapter from urllib3.util.retry import Retry import numpy as np from google.protobuf import text_format from onnx import helper, onnx_pb, defs, numpy_helper, ModelProto, __versi...
null
24,858
import os import re import shutil import tempfile import types import zipfile import logging import requests from requests.adapters import HTTPAdapter from urllib3.util.retry import Retry import numpy as np from google.protobuf import text_format from onnx import helper, onnx_pb, defs, numpy_helper, ModelProto, __versi...
null
24,859
import os import re import shutil import tempfile import types import zipfile import logging import requests from requests.adapters import HTTPAdapter from urllib3.util.retry import Retry import numpy as np from google.protobuf import text_format from onnx import helper, onnx_pb, defs, numpy_helper, ModelProto, __versi...
null
24,860
import os import re import shutil import tempfile import types import zipfile import logging import requests from requests.adapters import HTTPAdapter from urllib3.util.retry import Retry import numpy as np from google.protobuf import text_format from onnx import helper, onnx_pb, defs, numpy_helper, ModelProto, __versi...
null
24,861
import os import re import shutil import tempfile import types import zipfile import logging import requests from requests.adapters import HTTPAdapter from urllib3.util.retry import Retry import numpy as np from google.protobuf import text_format from onnx import helper, onnx_pb, defs, numpy_helper, ModelProto, __versi...
null
24,862
import os import re import shutil import tempfile import types import zipfile import logging import requests from requests.adapters import HTTPAdapter from urllib3.util.retry import Retry import numpy as np from google.protobuf import text_format from onnx import helper, onnx_pb, defs, numpy_helper, ModelProto, __versi...
Returns True iff src is compatible with dest. None is compatible with all shapes, different ranks are not considered as compatible
24,863
import os import re import shutil import tempfile import types import zipfile import logging import requests from requests.adapters import HTTPAdapter from urllib3.util.retry import Retry import numpy as np from google.protobuf import text_format from onnx import helper, onnx_pb, defs, numpy_helper, ModelProto, __versi...
Check whether 2 shapes are equal.
24,864
import os import re import shutil import tempfile import types import zipfile import logging import requests from requests.adapters import HTTPAdapter from urllib3.util.retry import Retry import numpy as np from google.protobuf import text_format from onnx import helper, onnx_pb, defs, numpy_helper, ModelProto, __versi...
null
24,865
import os import re import shutil import tempfile import types import zipfile import logging import requests from requests.adapters import HTTPAdapter from urllib3.util.retry import Retry import numpy as np from google.protobuf import text_format from onnx import helper, onnx_pb, defs, numpy_helper, ModelProto, __versi...
null
24,866
import os import re import shutil import tempfile import types import zipfile import logging import requests from requests.adapters import HTTPAdapter from urllib3.util.retry import Retry import numpy as np from google.protobuf import text_format from onnx import helper, onnx_pb, defs, numpy_helper, ModelProto, __versi...
null
24,867
import os import re import shutil import tempfile import types import zipfile import logging import requests from requests.adapters import HTTPAdapter from urllib3.util.retry import Retry import numpy as np from google.protobuf import text_format from onnx import helper, onnx_pb, defs, numpy_helper, ModelProto, __versi...
null
24,868
import os import re import shutil import tempfile import types import zipfile import logging import requests from requests.adapters import HTTPAdapter from urllib3.util.retry import Retry import numpy as np from google.protobuf import text_format from onnx import helper, onnx_pb, defs, numpy_helper, ModelProto, __versi...
null
24,869
import os import re import shutil import tempfile import types import zipfile import logging import requests from requests.adapters import HTTPAdapter from urllib3.util.retry import Retry import numpy as np from google.protobuf import text_format from onnx import helper, onnx_pb, defs, numpy_helper, ModelProto, __versi...
null
24,870
import os import re import shutil import tempfile import types import zipfile import logging import requests from requests.adapters import HTTPAdapter from urllib3.util.retry import Retry import numpy as np from google.protobuf import text_format from onnx import helper, onnx_pb, defs, numpy_helper, ModelProto, __versi...
null
24,871
import os import re import shutil import tempfile import types import zipfile import logging import requests from requests.adapters import HTTPAdapter from urllib3.util.retry import Retry import numpy as np from google.protobuf import text_format from onnx import helper, onnx_pb, defs, numpy_helper, ModelProto, __versi...
null
24,872
import os import re import shutil import tempfile import types import zipfile import logging import requests from requests.adapters import HTTPAdapter from urllib3.util.retry import Retry import numpy as np from google.protobuf import text_format from onnx import helper, onnx_pb, defs, numpy_helper, ModelProto, __versi...
null
24,873
import os import re import shutil import tempfile import types import zipfile import logging import requests from requests.adapters import HTTPAdapter from urllib3.util.retry import Retry import numpy as np from google.protobuf import text_format from onnx import helper, onnx_pb, defs, numpy_helper, ModelProto, __versi...
null
24,874
import os import re import shutil import tempfile import types import zipfile import logging import requests from requests.adapters import HTTPAdapter from urllib3.util.retry import Retry import numpy as np from google.protobuf import text_format from onnx import helper, onnx_pb, defs, numpy_helper, ModelProto, __versi...
null
24,875
import os import re import shutil import tempfile import types import zipfile import logging import requests from requests.adapters import HTTPAdapter from urllib3.util.retry import Retry import numpy as np from google.protobuf import text_format from onnx import helper, onnx_pb, defs, numpy_helper, ModelProto, __versi...
null
24,876
import logging import numpy as np from onnx import onnx_pb from tf2onnx import constants, utils from tf2onnx.handler import tf_op from tf2onnx.onnx_opset import common def make_min_or_max_op(ctx, op_type, inputs, outputs, output_shapes=None, output_dtypes=None): # support more dtype supp...
null
24,877
import copy import logging import numpy as np from onnx import onnx_pb from onnx.onnx_pb import TensorProto from tf2onnx import utils from tf2onnx.handler import tf_op from tf2onnx.tf_loader import find_function from tf2onnx.graph_builder import GraphBuilder def inline_subgraph(parent, g, scope, binding): # make a ...
Wire subgraph graph into main.
24,878
import copy import logging import numpy as np from onnx import onnx_pb from onnx.onnx_pb import TensorProto from tf2onnx import utils from tf2onnx.handler import tf_op from tf2onnx.tf_loader import find_function from tf2onnx.graph_builder import GraphBuilder def parameter_binding(g, inputs, state_vars=None): bindin...
Wire subgraph graph into main.
24,879
import copy import logging import numpy as np from onnx import onnx_pb from onnx.onnx_pb import TensorProto from tf2onnx import utils from tf2onnx.handler import tf_op from tf2onnx.tf_loader import find_function from tf2onnx.graph_builder import GraphBuilder def dump_graph(g): print() print("--, graph=", g.gra...
null
24,880
import logging import sys import numpy as np from onnx import onnx_pb, helper from onnx.onnx_pb import TensorProto from tf2onnx import constants, utils from tf2onnx.graph_builder import GraphBuilder from tf2onnx.handler import tf_op from tf2onnx.onnx_opset import nn, math from tf2onnx.constants import NCHW_TO_NHWC, NHW...
cast int32 shape into int64 shape.
24,881
import logging import sys import numpy as np from onnx import onnx_pb, helper from onnx.onnx_pb import TensorProto from tf2onnx import constants, utils from tf2onnx.graph_builder import GraphBuilder from tf2onnx.handler import tf_op from tf2onnx.onnx_opset import nn, math from tf2onnx.constants import NCHW_TO_NHWC, NHW...
wrap concat in casts for opset < 8 since it only supports.
24,882
import logging import sys import numpy as np from onnx import onnx_pb, helper from onnx.onnx_pb import TensorProto from tf2onnx import constants, utils from tf2onnx.graph_builder import GraphBuilder from tf2onnx.handler import tf_op from tf2onnx.onnx_opset import nn, math from tf2onnx.constants import NCHW_TO_NHWC, NHW...
null
24,883
import logging import sys import numpy as np from onnx import onnx_pb, helper from onnx.onnx_pb import TensorProto from tf2onnx import constants, utils from tf2onnx.graph_builder import GraphBuilder from tf2onnx.handler import tf_op from tf2onnx.onnx_opset import nn, math from tf2onnx.constants import NCHW_TO_NHWC, NHW...
null
24,884
import logging from onnx import TensorProto from tf2onnx import utils from tf2onnx.handler import tf_op from tf2onnx.onnx_opset import common def _add_cast_to_inputs(graph, node, supported_dtypes, target_dtype): is_support = True for inp in node.input: if graph.get_dtype(inp) not in supported_dtypes: ...
null
24,885
import logging from onnx import TensorProto from tf2onnx import utils from tf2onnx.handler import tf_op from tf2onnx.onnx_opset import common def _add_cast_to_same_type_to_inputs(graph, node): common_dtype = graph.get_dtype(node.input[0]) for inp in node.input[1:]: if graph.get_dtype(inp) != common_dt...
null
24,886
import logging import numpy as np from onnx import onnx_pb, helper from onnx.numpy_helper import to_array from tf2onnx import utils from tf2onnx.handler import tf_op from tf2onnx.graph_builder import GraphBuilder def make_dft_constant(length, dtype, fft_length): utils.make_sure(fft_length > 0, "fft_length must be ...
null
24,887
import logging import numpy as np from onnx import onnx_pb, helper from onnx.onnx_pb import TensorProto from tf2onnx import constants, utils from tf2onnx.graph_builder import GraphBuilder from tf2onnx.handler import tf_op from tf2onnx.onnx_opset import common, controlflow, tensor The provided code snippet includes nec...
Makes a (N, C, ...) shape into (N, ..., C).
24,888
import logging import numpy as np from onnx import onnx_pb, helper from onnx.onnx_pb import TensorProto from tf2onnx import constants, utils from tf2onnx.graph_builder import GraphBuilder from tf2onnx.handler import tf_op from tf2onnx.onnx_opset import common, controlflow, tensor def spatial_map(shape, perm): new_s...
Convert input and kernel from tensorflow to onnx. This may be required to insert transpose ops for input, kernel, and output unless they are constants and we can transpose the constant. We transpose inputs if they are in NHWC. We always transpose the kernel from HWNC to NCHW. Outputs are transposed if the format is NHW...
24,889
import logging import numpy as np from onnx import onnx_pb, helper from onnx.onnx_pb import TensorProto from tf2onnx import constants, utils from tf2onnx.graph_builder import GraphBuilder from tf2onnx.handler import tf_op from tf2onnx.onnx_opset import common, controlflow, tensor logger = logging.getLogger(__name__) de...
null
24,890
import logging import numpy as np from onnx import onnx_pb, helper from onnx.onnx_pb import TensorProto from tf2onnx import constants, utils from tf2onnx.graph_builder import GraphBuilder from tf2onnx.handler import tf_op from tf2onnx.onnx_opset import common, controlflow, tensor def parse_dims_attr(node, dims, spatial...
null
24,891
import logging import numpy as np from onnx import onnx_pb, helper from onnx.onnx_pb import TensorProto from tf2onnx import constants, utils from tf2onnx.graph_builder import GraphBuilder from tf2onnx.handler import tf_op from tf2onnx.onnx_opset import common, controlflow, tensor def conv_kernel_shape(ctx, node, input...
null
24,892
import logging import numpy as np from onnx import onnx_pb, helper from onnx.onnx_pb import TensorProto from tf2onnx import constants, utils from tf2onnx.graph_builder import GraphBuilder from tf2onnx.handler import tf_op from tf2onnx.onnx_opset import common, controlflow, tensor class GraphBuilder(object): """hel...
Build the target tensor shape for the Resize op. Args: - ctx: the graph context - transposed_intput: A tensor of rank 4 of shape [n c h w] - target_hw: tensor of rank 2 containing the target size for a resize: [nh nw] Returns: A tensor of rank 2 containing [n c nh nw]
24,893
import logging import numpy as np from onnx import onnx_pb, helper from onnx.onnx_pb import TensorProto from tf2onnx import constants, utils from tf2onnx.graph_builder import GraphBuilder from tf2onnx.handler import tf_op from tf2onnx.onnx_opset import common, controlflow, tensor def get_shape_from_const_or_concat(ctx...
null
24,894
import logging import numpy as np from onnx import onnx_pb, helper from onnx.onnx_pb import TensorProto from tf2onnx import constants, utils from tf2onnx.graph_builder import GraphBuilder from tf2onnx.handler import tf_op from tf2onnx.onnx_opset import common, controlflow, tensor class GraphBuilder(object): def _...
null
24,895
import logging import numpy as np from onnx import onnx_pb, helper from onnx.onnx_pb import TensorProto from tf2onnx import constants, utils from tf2onnx.graph_builder import GraphBuilder from tf2onnx.handler import tf_op from tf2onnx.onnx_opset import common, controlflow, tensor class GraphBuilder(object): """hel...
null
24,896
import logging import numpy as np from onnx import onnx_pb, helper from onnx.onnx_pb import TensorProto from tf2onnx import constants, utils from tf2onnx.graph_builder import GraphBuilder from tf2onnx.handler import tf_op from tf2onnx.onnx_opset import common, controlflow, tensor class GraphBuilder(object): """hel...
null
24,897
import logging import copy from collections import defaultdict, OrderedDict from onnx import defs, helper, TensorProto, OperatorSetIdProto, shape_inference from . import constants from . import utils class OnnxOpSchema(object): """Wrapper for Onnx schema.""" def __init__(self, name, domain, since_version, attri...
Register all schemas with history
24,898
import logging import copy from collections import defaultdict, OrderedDict from onnx import defs, helper, TensorProto, OperatorSetIdProto, shape_inference from . import constants from . import utils The provided code snippet includes necessary dependencies for implementing the `_parse_domain_opset_versions` function....
Get max opset version among all schemas within each domain.