repo
stringclasses
454 values
file_path
stringlengths
5
201
extension
stringclasses
1 value
content
stringlengths
8
509k
num_lines
int64
3
16.9k
size_bytes
int64
8
511k
coremltools
coremltools/converters/mil/frontend/tensorflow/basic_graph_ops.py
.py
# Copyright (c) 2020, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause def connect_edge(g, source, dest): if isinstance(source, str): source = g[source] if...
364
11,344
coremltools
coremltools/converters/mil/frontend/tensorflow/test/test_parsed_tf_node.py
.py
# Copyright (c) 2020, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause import unittest import pytest pytest.importorskip("tensorflow", minversion="1.15.0") from tensorflo...
66
2,187
coremltools
coremltools/converters/mil/frontend/tensorflow/test/testing_utils.py
.py
# Copyright (c) 2020, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause import os import tempfile import numpy as np import pytest import coremltools.models.utils as corem...
397
15,118
coremltools
coremltools/converters/mil/frontend/tensorflow/test/test_tf_conversion_api.py
.py
# Copyright (c) 2022, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause import itertools import os import tempfile import numpy as np import pytest import coremltools as c...
1,500
66,131
coremltools
coremltools/converters/mil/frontend/tensorflow/test/test_ops.py
.py
# Copyright (c) 2020, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause import itertools import math import os import platform import shutil import tempfile from typing impo...
8,127
281,494
coremltools
coremltools/converters/mil/frontend/tensorflow/test/test_parse.py
.py
# Copyright (c) 2020, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause import unittest import pytest pytest.importorskip("tensorflow", minversion="1.15.0") from tensorflo...
125
5,013
coremltools
coremltools/converters/mil/frontend/tensorflow/test/test_custom_ops.py
.py
# Copyright (c) 2020, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause import itertools import numpy as np import pytest from coremltools.converters.mil.frontend.tensorfl...
289
11,065
coremltools
coremltools/converters/mil/frontend/tensorflow/test/test_composite_ops.py
.py
# Copyright (c) 2020, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause import itertools import numpy as np import pytest from coremltools.converters.mil.frontend.tensorfl...
70
2,413
coremltools
coremltools/converters/mil/frontend/tensorflow/test/test_load.py
.py
# Copyright (c) 2020, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause import os import shutil import tempfile import numpy as np import pytest import coremltools as ct i...
529
18,789
coremltools
coremltools/converters/mil/frontend/tensorflow/ssa_passes/backfill_make_list_elem_type.py
.py
# Copyright (c) 2020, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause from coremltools.converters.mil.mil import Builder as mb from coremltools.converters.mil.mil import t...
122
4,794
coremltools
coremltools/converters/mil/frontend/tensorflow/ssa_passes/expand_tf_lstm.py
.py
# Copyright (c) 2020, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause import numpy as np from coremltools import _logger as logger from coremltools.converters.mil.mil imp...
225
7,187
coremltools
coremltools/converters/mil/frontend/tensorflow/ssa_passes/test_passes.py
.py
# Copyright (c) 2020, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause import copy import pytest from coremltools.converters.mil.mil import Builder as mb from coremltools...
57
2,071
coremltools
coremltools/converters/mil/frontend/tensorflow/ssa_passes/tf_lstm_to_core_lstm.py
.py
# Copyright (c) 2020, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause import numpy as np from coremltools import _logger as logger from coremltools.converters.mil.mil imp...
309
12,440
coremltools
coremltools/converters/mil/frontend/tensorflow/tf_graph_pass/delete_disconnected_nodes.py
.py
# Copyright (c) 2020, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause def delete_disconnected_nodes(gd): # delete all nodes with no inputs and outputs empty_nodes...
22
669
coremltools
coremltools/converters/mil/frontend/tensorflow/tf_graph_pass/quantization_pass.py
.py
# Copyright (c) 2020, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause from ..basic_graph_ops import delete_node def delete_fakequant_node_and_repair_graph(g, node): ...
64
2,966
coremltools
coremltools/converters/mil/frontend/tensorflow/tf_graph_pass/visitors.py
.py
# Copyright (c) 2020, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause from ..parsed_tf_node import ParsedTFNode class FindAllDownstreamTerminals: # Find all nodes ma...
234
6,425
coremltools
coremltools/converters/mil/frontend/tensorflow/tf_graph_pass/functionalize_loops.py
.py
# Copyright (c) 2020, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause from coremltools import _logger as logger from ..basic_graph_ops import (connect_dests, connect_edge...
470
19,047
coremltools
coremltools/converters/mil/frontend/tensorflow/tf_graph_pass/delete_constant.py
.py
# Copyright (c) 2020, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause from coremltools import _logger as logger from ..basic_graph_ops import check_connections, delete_no...
83
3,059
coremltools
coremltools/converters/mil/frontend/tensorflow/tf_graph_pass/fuse_dilation_conv.py
.py
# Copyright (c) 2021, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause import numpy as np from ..basic_graph_ops import delete_node, replace_source from coremltools.converte...
181
6,498
coremltools
coremltools/converters/mil/frontend/tensorflow/tf_graph_pass/cond_to_where.py
.py
# Copyright (c) 2020, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause from coremltools import _logger as logger from coremltools._deps import _HAS_TF_2 from ..basic_graph...
131
4,377
coremltools
coremltools/converters/mil/frontend/tensorflow/tf_graph_pass/insert_get_tuple.py
.py
# Copyright (c) 2020, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause import copy from ..parsed_tf_node import ParsedTFNode def insert_get_tuple(gddict): """ Te...
112
3,398
coremltools
coremltools/converters/mil/frontend/tensorflow/tf_graph_pass/delete_asserts.py
.py
# -*- coding: utf-8 -*- # Copyright (c) 2020, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause import sys from coremltools import _logger as logger from ..basic_graph_ops...
69
2,386
coremltools
coremltools/converters/mil/frontend/tensorflow/tf_graph_pass/constant_propagation.py
.py
# Copyright (c) 2020, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause import gc import tensorflow as tf from packaging.version import Version from coremltools import _lo...
164
6,849
coremltools
coremltools/converters/mil/frontend/tensorflow/tf_graph_pass/variable_node_transform.py
.py
# Copyright (c) 2020, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause from ..basic_graph_ops import delete_node, disconnect_vertex_ins # Variable nodes are not horribly ...
86
2,898
coremltools
coremltools/converters/mil/frontend/tensorflow2/load.py
.py
# Copyright (c) 2020, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause import os.path as _os_path import tensorflow as _tf from packaging.version import Version from tenso...
345
14,795
coremltools
coremltools/converters/mil/frontend/tensorflow2/ops.py
.py
# Copyright (c) 2020, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause import numpy as _np from coremltools.converters.mil.frontend.tensorflow import ops # TF 2.x now impo...
232
8,352
coremltools
coremltools/converters/mil/frontend/tensorflow2/converter.py
.py
# Copyright (c) 2020, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause from coremltools.converters.mil.frontend.tensorflow.basic_graph_ops import \ simple_topsort from ...
41
1,540
coremltools
coremltools/converters/mil/frontend/tensorflow2/test/testing_utils.py
.py
# Copyright (c) 2020, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause import numpy as np import pytest tf = pytest.importorskip("tensorflow", minversion="2.1.0") from te...
307
10,337
coremltools
coremltools/converters/mil/frontend/tensorflow2/test/test_v2_ops.py
.py
# Copyright (c) 2020, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause import itertools import numpy as np import pytest import coremltools as ct from coremltools.convert...
793
25,555
coremltools
coremltools/converters/mil/frontend/tensorflow2/test/test_v2_load.py
.py
# Copyright (c) 2020, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause import os import shutil import tempfile import pytest import coremltools.converters as converter fr...
285
9,970
coremltools
coremltools/converters/mil/frontend/tensorflow2/test/test_v2_ops_tf_keras.py
.py
# Copyright (c) 2020, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause import itertools import platform import random import numpy as np import pytest from packaging.versi...
1,793
61,829
coremltools
coremltools/converters/mil/frontend/tensorflow2/test/test_tf2_conversion_api.py
.py
# Copyright (c) 2020, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause import itertools import os import platform from os import chdir, getcwd from shutil import rmtree fro...
550
21,884
coremltools
coremltools/converters/mil/frontend/tensorflow2/ssa_passes/remove_vacuous_cond.py
.py
# Copyright (c) 2020, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause from coremltools import _logger as logger from coremltools.converters.mil.mil import Builder as mb fr...
119
4,645
coremltools
coremltools/converters/mil/frontend/tensorflow2/ssa_passes/test_v2_passes.py
.py
# Copyright (c) 2020, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause import copy import numpy as np from coremltools.converters.mil.mil import Builder as mb from coreml...
55
1,850
coremltools
coremltools/converters/mil/frontend/tensorflow2/tf_graph_pass/rewrite_control_flow_functions.py
.py
# Copyright (c) 2020, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause from coremltools import _logger as logger from coremltools.converters.mil.frontend.tensorflow.basic_...
562
20,086
coremltools
coremltools/converters/mil/frontend/milproto/load.py
.py
# Copyright (c) 2022, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause import os from typing import Tuple import numpy as np from coremltools import _logger as logger from ...
619
24,617
coremltools
coremltools/converters/mil/frontend/milproto/test_load.py
.py
# Copyright (c) 2022, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause import itertools import numpy as np import pytest import coremltools as ct from coremltools import _SP...
497
19,651
coremltools
coremltools/converters/mil/frontend/milproto/helper.py
.py
# Copyright (c) 2022, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause from coremltools.converters.mil.mil import types from coremltools.converters.mil.mil.program import ge...
71
2,573
coremltools
coremltools/converters/mil/frontend/torch/dialect_ops.py
.py
# Copyright (c) 2021, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause from coremltools.converters.mil.mil import Operation, get_new_symbol, types from coremltools.converte...
217
7,912
coremltools
coremltools/converters/mil/frontend/torch/utils.py
.py
# Copyright (c) 2024, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause from enum import Enum import numpy as np import torch from coremltools.converters.mil.mil import ty...
186
5,381
coremltools
coremltools/converters/mil/frontend/torch/torchscript_utils.py
.py
# Copyright (c) 2023, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause import torch from coremltools._deps import version_lt def _jit_pass_lower_graph(graph, torchscript...
191
8,400
coremltools
coremltools/converters/mil/frontend/torch/internal_graph.py
.py
# Copyright (c) 2020, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause from collections import OrderedDict, deque from typing import Any, Dict, List, Optional, Tuple, Union...
713
27,856
coremltools
coremltools/converters/mil/frontend/torch/load.py
.py
# Copyright (c) 2020, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause import os.path as _os_path from typing import List, Optional, Union import torch as _torch from torc...
161
6,149
coremltools
coremltools/converters/mil/frontend/torch/ops.py
.py
# Copyright (c) 2020, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause import builtins import math as _math import numbers import re from collections.abc import Iterable fr...
9,987
359,013
coremltools
coremltools/converters/mil/frontend/torch/torch_op_registry.py
.py
# Copyright (c) 2020, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause from typing import Callable import torch from coremltools import _logger as logger from coremltools...
167
6,223
coremltools
coremltools/converters/mil/frontend/torch/converter.py
.py
# Copyright (c) 2020, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause import math from collections import OrderedDict from enum import Enum from typing import Dict, List, ...
1,473
68,316
coremltools
coremltools/converters/mil/frontend/torch/exir_utils.py
.py
# Copyright (c) 2023, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause from typing import Dict, List, Tuple import sympy import torch from coremltools import _logger as ...
372
14,280
coremltools
coremltools/converters/mil/frontend/torch/dim_order_ops.py
.py
# Copyright (c) 2025, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause from typing import Tuple import numpy as np import torch from coremltools.converters.mil.mil.builde...
138
5,872
coremltools
coremltools/converters/mil/frontend/torch/quantization_ops.py
.py
# Copyright (c) 2023, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause import numpy as _np import torch as _torch from packaging.version import Version from coremltools im...
808
31,371
coremltools
coremltools/converters/mil/frontend/torch/torchir_passes.py
.py
# Copyright (c) 2021, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause from collections import OrderedDict, defaultdict from typing import Dict, Optional from coremltools ...
422
16,562
coremltools
coremltools/converters/mil/frontend/torch/test/test_internal_graph.py
.py
# Copyright (c) 2020, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause import itertools import numpy as np import pytest torch = pytest.importorskip("torch") import torc...
1,853
68,809
coremltools
coremltools/converters/mil/frontend/torch/test/test_torch_quantization_ops.py
.py
# Copyright (c) 2023, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause import itertools from contextlib import nullcontext from typing import Optional import numpy as np i...
1,499
62,196
coremltools
coremltools/converters/mil/frontend/torch/test/test_torch_export_quantization.py
.py
# Copyright (c) 2024, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause import itertools from typing import Tuple import pytest from ..utils import TorchFrontend from .tes...
231
8,496
coremltools
coremltools/converters/mil/frontend/torch/test/testing_utils.py
.py
# Copyright (c) 2020, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause import os import platform from pathlib import Path from typing import List, Union import numpy as np...
386
13,719
coremltools
coremltools/converters/mil/frontend/torch/test/test_torch_export_conversion_api.py
.py
# Copyright (c) 2023, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause import itertools from sys import version_info import numpy as np import pytest from ..utils import ...
810
31,797
coremltools
coremltools/converters/mil/frontend/torch/test/test_custom_ops.py
.py
# Copyright (c) 2020, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause import pytest import torch import torch.nn as nn from coremltools.converters.mil.frontend.torch.ops ...
145
5,640
coremltools
coremltools/converters/mil/frontend/torch/test/test_torch_conversion_api.py
.py
# Copyright (c) 2022, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause from datetime import date import itertools import os import platform import re import shutil import t...
3,299
137,818
coremltools
coremltools/converters/mil/frontend/torch/test/test_examples.py
.py
# Copyright (c) 2022, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause import pytest import coremltools from coremltools._deps import _HAS_TORCH, MSG_TORCH_NOT_FOUND from cor...
68
2,043
coremltools
coremltools/converters/mil/frontend/torch/test/test_torch_stateful_model.py
.py
# Copyright (c) 2024, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause import itertools from sys import version_info import numpy as np import pytest import coremltools as ...
1,194
42,528
coremltools
coremltools/converters/mil/frontend/torch/test/test_passes.py
.py
# Copyright (c) 2021, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause from collections import OrderedDict import numpy as np import pytest import torch from ..internal_g...
458
14,794
coremltools
coremltools/converters/mil/frontend/torch/ssa_passes/torch_upsample_to_core_upsample.py
.py
# Copyright (c) 2021, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause import numpy as np from coremltools import _logger as logger from coremltools.converters.mil.mil imp...
198
7,041
coremltools
coremltools/converters/mil/frontend/torch/ssa_passes/torch_tensor_assign_to_core.py
.py
# Copyright (c) 2021, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause from coremltools.converters.mil.mil import Builder as mb from coremltools.converters.mil.mil.passes.g...
64
2,397
coremltools
coremltools/converters/mil/test/test_rms_norm.py
.py
# Copyright (c) 2020, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at # https://opensource.org/licenses/BSD-3-Clause # # Test suite for RMSNorm feature (Issue #2585) import pytest from coremltools._deps import _HAS...
193
6,064
coremltools
coremltools/converters/mil/test/test_input_types.py
.py
import numpy as np import pytest from coremltools.converters.mil.mil import types from coremltools.converters.mil.input_types import RangeDim, TensorType def test_rangedim_default_within_bounds(): dim = RangeDim(lower_bound=0, upper_bound=10, default=5) assert dim.default == 5 def test_rangedim_default_falls...
41
1,522
coremltools
coremltools/converters/mil/backend/backend_helper.py
.py
# Copyright (c) 2021, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause from coremltools import proto from coremltools.converters.mil import input_types from coremltools.con...
81
4,045
coremltools
coremltools/converters/mil/backend/nn/load.py
.py
# Copyright (c) 2020, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause import coremltools as ct from coremltools.converters._profile_utils import _profile from coremltools....
312
13,862
coremltools
coremltools/converters/mil/backend/nn/mil_to_nn_mapping_registry.py
.py
# Copyright (c) 2020, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause MIL_TO_NN_MAPPING_REGISTRY = {} def register_mil_to_nn_mapping(func=None, override=False): def f...
19
739
coremltools
coremltools/converters/mil/backend/nn/op_mapping.py
.py
# Copyright (c) 2020, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause import numpy as _np from tqdm import tqdm as _tqdm from coremltools import _logger as logger from co...
3,837
129,701
coremltools
coremltools/converters/mil/backend/nn/passes/handle_return_inputs_as_outputs.py
.py
# Copyright (c) 2020, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause from coremltools.converters.mil.mil import Builder as mb from coremltools.converters.mil.mil.passes.g...
63
2,153
coremltools
coremltools/converters/mil/backend/nn/passes/handle_unused_inputs.py
.py
# Copyright (c) 2020, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause from coremltools.converters.mil.mil import Block from coremltools.converters.mil.mil import Builder a...
57
1,841
coremltools
coremltools/converters/mil/backend/nn/passes/__init__.py
.py
# Copyright (c) 2020, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause from . import ( alert_return_type_cast, commingle_loop_vars, conv1d_decomposition, ha...
15
432
coremltools
coremltools/converters/mil/backend/nn/passes/mlmodel_passes.py
.py
# Copyright (c) 2020, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause def _get_nn_spec(spec): if spec.WhichOneof("Type") == "neuralNetwork": nn_spec = spec.ne...
468
18,489
coremltools
coremltools/converters/mil/backend/nn/passes/conv1d_decomposition.py
.py
# Copyright (c) 2023, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause from coremltools.converters.mil.mil import Block from coremltools.converters.mil.mil import Builder a...
102
3,693
coremltools
coremltools/converters/mil/backend/nn/passes/test_mlmodel_passes.py
.py
# Copyright (c) 2020, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause import copy import unittest from sys import platform import numpy as np import coremltools.models.d...
1,053
37,208
coremltools
coremltools/converters/mil/backend/nn/passes/handle_return_unused_inputs.py
.py
# Copyright (c) 2020, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause from coremltools.converters.mil.mil import Builder as mb from coremltools.converters.mil.mil.passes.g...
60
2,086
coremltools
coremltools/converters/mil/backend/nn/passes/test_passes.py
.py
# Copyright (c) 2020, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause import copy import itertools import numpy as np import pytest from coremltools.converters.mil impor...
228
7,734
coremltools
coremltools/converters/mil/backend/nn/passes/commingle_loop_vars.py
.py
# Copyright (c) 2020, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause from coremltools.converters.mil.mil.passes.graph_pass import AbstractGraphPass from coremltools.conv...
75
2,472
coremltools
coremltools/converters/mil/backend/nn/passes/alert_return_type_cast.py
.py
# Copyright (c) 2020, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause from coremltools import _logger as logger from coremltools.converters.mil.mil import Var, types from ...
49
1,698
coremltools
coremltools/converters/mil/backend/mil/test_helper.py
.py
# Copyright (c) 2020, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause from coremltools.converters.mil.mil.passes.defs.preprocess import NameSanitizer as _NameSanitizer c...
28
1,265
coremltools
coremltools/converters/mil/backend/mil/load.py
.py
# Copyright (c) 2021, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause import os import warnings from collections import OrderedDict from typing import Any, Dict, List, Opt...
1,105
47,312
coremltools
coremltools/converters/mil/backend/mil/test_load.py
.py
# Copyright (c) 2021, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause import itertools import math import os import platform import shutil import tempfile from typing impo...
1,240
49,715
coremltools
coremltools/converters/mil/backend/mil/helper.py
.py
# Copyright (c) 2021, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause import numpy as np from coremltools import proto from coremltools.converters.mil.mil import types ...
325
12,984
coremltools
coremltools/converters/mil/backend/mil/passes/adjust_io_to_supported_types.py
.py
# Copyright (c) 2021, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause from typing import Set, Tuple from coremltools import _logger as logger from coremltools.converters....
242
11,489
coremltools
coremltools/converters/mil/backend/mil/passes/sanitize_name_strings.py
.py
# Copyright (c) 2020, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause from coremltools.converters.mil.mil.passes.defs.preprocess import NameSanitizer from coremltools.conv...
30
1,272
coremltools
coremltools/converters/mil/backend/mil/passes/decompose_const_base2_pow.py
.py
# Copyright (c) 2025, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause import numpy as np from coremltools.converters.mil.mil import Builder as mb from coremltools.convert...
66
2,153
coremltools
coremltools/converters/mil/backend/mil/passes/insert_image_preprocessing_op.py
.py
# Copyright (c) 2020, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause import numpy as np from coremltools.converters.mil import input_types as _input_types from coremltoo...
83
3,726
coremltools
coremltools/converters/mil/backend/mil/passes/fuse_activation_silu.py
.py
# Copyright (c) 2020, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause from coremltools.converters.mil.mil import Builder as mb from coremltools.converters.mil.mil.passes.g...
84
2,702
coremltools
coremltools/converters/mil/backend/mil/passes/test_passes.py
.py
# Copyright (c) 2020, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause import copy import itertools import numpy as np import pytest import coremltools as ct from coremlt...
1,281
44,661
coremltools
coremltools/converters/mil/backend/mil/passes/fuse_pow2_sqrt.py
.py
# Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause import numpy as np from coremltools.converters.mil.mil import Builder as mb from coremltools.converters.mil.mil.passes.graph_pass import AbstractGraphPass fr...
103
3,036
coremltools
coremltools/converters/xgboost/_tree_ensemble.py
.py
# Copyright (c) 2017, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause from copy import deepcopy import numpy as _np from ..._deps import _HAS_XGBOOST from ...models.tree_en...
348
11,931
coremltools
coremltools/converters/xgboost/_tree.py
.py
# Copyright (c) 2017, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause import coremltools as ct from coremltools import __version__ as ct_version from ._tree_ensemble import ...
91
2,691
coremltools
coremltools/converters/sklearn/_decision_tree_classifier.py
.py
# Copyright (c) 2017, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause from ..._deps import _HAS_SKLEARN from ...models import MLModel as _MLModel from ._tree_ensemble import ...
72
1,775
coremltools
coremltools/converters/sklearn/_converter_internal.py
.py
# Copyright (c) 2017, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause """ The primary file for converting Scikit-learn models. """ from ..._deps import _HAS_SKLEARN from ......
349
12,900
coremltools
coremltools/converters/sklearn/_SVR.py
.py
# Copyright (c) 2017, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause from coremltools import proto from ... import SPECIFICATION_VERSION from ..._deps import _HAS_SKLEARN f...
83
2,363
coremltools
coremltools/converters/sklearn/_decision_tree_regressor.py
.py
# Copyright (c) 2017, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause from ..._deps import _HAS_SKLEARN from ...models import MLModel as _MLModel from ._tree_ensemble import ...
55
1,530
coremltools
coremltools/converters/sklearn/_normalizer.py
.py
# Copyright (c) 2017, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause from coremltools import proto from ... import SPECIFICATION_VERSION from ..._deps import _HAS_SKLEARN f...
82
2,275
coremltools
coremltools/converters/sklearn/_svm_common.py
.py
# Copyright (c) 2017, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause """ Common stuff for SVMs """ def _set_kernel(model, spec): """ Takes the sklearn SVM model an...
38
1,210
coremltools
coremltools/converters/sklearn/_tree_ensemble.py
.py
# Copyright (c) 2017, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause from ..._deps import _HAS_SKLEARN from ...models._feature_management import process_or_validate_features...
273
7,998
coremltools
coremltools/converters/sklearn/_random_forest_regressor.py
.py
# Copyright (c) 2017, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause from ..._deps import _HAS_SKLEARN from ...models import MLModel as _MLModel from ._tree_ensemble import ...
59
1,710
coremltools
coremltools/converters/sklearn/_LinearSVC.py
.py
# Copyright (c) 2017, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause from ..._deps import _HAS_SKLEARN from ...models import MLModel as _MLModel if _HAS_SKLEARN: from s...
59
1,500