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/test/optimize/torch/palettization/palettization_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 coremltools.optimize.torch.palettization._supported_modules import DKMPalettizerModulesRegistry
... | 29 | 1,196 |
coremltools | coremltools/test/optimize/torch/quantization/test_quantizer.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 collections import OrderedDict
import cattrs
import pytest
import torch
import torch.ao.quantiz... | 701 | 25,621 |
coremltools | coremltools/test/optimize/torch/quantization/test_learnable_fake_quantize.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 pytest
import torch
import torch.ao.quantization as aoquant
from coremltools.optimize.torch.q... | 314 | 8,851 |
coremltools | coremltools/test/optimize/torch/quantization/test_post_training_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 numpy as np
import pytest
import torch
ct = pytest.importorskip("coremltools")
pytest.import... | 384 | 11,769 |
coremltools | coremltools/test/optimize/torch/quantization/test_observers.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 pytest
import torch
from torch.ao.quantization import FakeQuantize
from coremltools.optimize.... | 245 | 7,785 |
coremltools | coremltools/test/optimize/torch/quantization/test_coreml_quantizer.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 collections import OrderedDict
from typing import Dict, Optional
import pytest
import torch
im... | 238 | 8,225 |
coremltools | coremltools/test/optimize/torch/quantization/test_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
import pytest
import torch
import torch.ao.quantization as _aoquant
from coremltools.optimize.torch.... | 117 | 3,776 |
coremltools | coremltools/test/optimize/torch/quantization/test_configure.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 math
import operator
from collections import OrderedDict
from typing import List
import pytes... | 1,280 | 48,198 |
coremltools | coremltools/test/optimize/torch/conversion/conversion_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
import random
import sys
import numpy as np
import torch
import coremltools as ct
torch.manual_see... | 141 | 4,215 |
coremltools | coremltools/test/optimize/torch/conversion/palettization/test_palettization_conversion.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 pytest
import torch
import torch.nn as nn
import coremltools.test.optimize.torch.conversion.c... | 481 | 14,860 |
coremltools | coremltools/test/optimize/torch/conversion/quantization/test_quantization_conversion.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 pytest
ct = pytest.importorskip("coremltools")
import coremltools.test.optimize.torch.convers... | 169 | 5,061 |
coremltools | coremltools/test/optimize/torch/conversion/joint/test_joint_compression_conversion.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 pytest
ct = pytest.importorskip("coremltools")
import coremltools.test.optimize.torch.convers... | 98 | 3,376 |
coremltools | coremltools/test/optimize/torch/conversion/pruning/test_pruning_conversion.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 pytest
ct = pytest.importorskip("coremltools")
import coremltools.test.optimize.torch.convers... | 89 | 2,394 |
coremltools | coremltools/test/optimize/torch/test_utils/test_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
import pytest
import torch as _torch
from coremltools.optimize.torch._utils.torch_utils import (
... | 55 | 1,718 |
coremltools | coremltools/test/optimize/torch/test_utils/test_optimizer_utils.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 pytest
import torch.nn as nn
import coremltools.optimize.torch
from coremltools.optimize.torc... | 99 | 3,673 |
coremltools | coremltools/test/optimize/torch/test_utils/test_metadata_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 contextlib import nullcontext as does_not_raise
import pytest
import torch
from coremltools.op... | 159 | 5,373 |
coremltools | coremltools/test/optimize/torch/test_utils/test_validation_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
import pytest
import torch
from coremltools.optimize.torch._utils.validation_utils import (
Conf... | 137 | 5,089 |
coremltools | coremltools/test/optimize/torch/test_utils/test_report_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 collections import OrderedDict
from typing import Tuple
import pytest
import torch
from coreml... | 315 | 10,277 |
coremltools | coremltools/test/optimize/torch/test_utils/test_k_means.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 time
import pytest
import torch
from coremltools.optimize.torch._utils.k_means import (
... | 302 | 11,629 |
coremltools | coremltools/test/optimize/torch/test_utils/test_fsdp_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
import pytest
import torch
from coremltools.optimize.torch._utils.fsdp_utils import (
ModuleWrap... | 55 | 1,649 |
coremltools | coremltools/test/optimize/torch/joint/test_api_ordering.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 contextlib import nullcontext as does_not_raise
import numpy as np
import pytest
import torch
... | 325 | 11,999 |
coremltools | coremltools/test/optimize/torch/pruning/pruning_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
import os
import numpy as np
import torch
import coremltools.test.optimize.torch.utils as utils
ba... | 88 | 3,011 |
coremltools | coremltools/test/optimize/torch/pruning/test_magnitude_pruner.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 copy
from collections import OrderedDict
import numpy as np
import pytest
import torch
import... | 624 | 21,827 |
coremltools | coremltools/test/optimize/torch/pruning/test_base_pruner.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 collections import OrderedDict
import pytest
import torch.nn as nn
from coremltools.optimize.t... | 49 | 1,694 |
coremltools | coremltools/test/optimize/torch/pruning/test_pruning_scheduler.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 sys
import pytest
import torch
from coremltools.optimize.torch.pruning import (
Constant... | 88 | 3,421 |
coremltools | coremltools/test/optimize/torch/models/multi_input_net.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 torch.nn as nn
num_classes = 10
class MultiInputNet(nn.Module):
def __init__(self):
... | 61 | 1,975 |
coremltools | coremltools/test/optimize/torch/models/mnist.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
# type: ignore
import os
from collections import OrderedDict
import pytest
import torch
import torch... | 239 | 8,522 |
coremltools | coremltools/test/optimize/torch/layerwise_compression/test_algorithms.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 contextlib import nullcontext as does_not_raise
import pytest
import torch
import torch.nn as n... | 361 | 11,863 |
coremltools | coremltools/test/optimize/torch/layerwise_compression/test_quant.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 pytest
import torch
from coremltools.optimize.torch.layerwise_compression._quant import Quant... | 84 | 2,840 |
coremltools | coremltools/test/blob/test_weights.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 shutil
import tempfile
import numpy as np
import pytest
import coremltools as ct
from... | 290 | 11,884 |
coremltools | coremltools/test/lightgbm_tests/test_boosted_trees_classifier.py | .py | # Copyright (c) 2026, 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 numpy as np
from coremltools._deps import _HAS_LIGHTGBM, _HAS_SKLEARN, MSG_LIGH... | 355 | 12,913 |
coremltools | coremltools/test/xgboost_tests/test_decision_tree_regression_numeric.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 itertools
import unittest
import pandas as pd
import pytest
from packaging.version import Versio... | 106 | 3,737 |
coremltools | coremltools/test/xgboost_tests/test_boosted_trees_regression.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 json
import tempfile
import unittest
from ..utils import load_boston
from coremltools._deps impo... | 270 | 10,280 |
coremltools | coremltools/test/xgboost_tests/test_boosted_trees_classifier_numeric.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 itertools
import unittest
import numpy as np
import pandas as pd
import pytest
from ..utils imp... | 265 | 9,754 |
coremltools | coremltools/test/xgboost_tests/test_boosted_trees_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
import json
import tempfile
import unittest
import numpy as np
from ..utils import load_boston
from co... | 390 | 14,395 |
coremltools | coremltools/test/xgboost_tests/test_decision_tree_regression.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 unittest
from ..utils import load_boston
from coremltools._deps import _HAS_SKLEARN, _HAS_XGBOOS... | 83 | 2,902 |
coremltools | coremltools/test/xgboost_tests/test_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
import unittest
import numpy as np
from ..utils import load_boston
from coremltools._deps import _HAS_... | 147 | 5,114 |
coremltools | coremltools/test/xgboost_tests/test_decision_tree_classifier_numeric.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 itertools
import unittest
import numpy as np
import pandas as pd
import pytest
from packaging.ve... | 138 | 5,025 |
coremltools | coremltools/test/xgboost_tests/test_boosted_trees_regression_numeric.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 itertools
import unittest
import pandas as pd
import pytest
from ..utils import load_boston
fro... | 310 | 11,011 |
coremltools | coremltools/test/converters/torch/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
#
# Test suite for dynamic padding conversion (Issue #2583)
# These tests verify the fix for conv... | 187 | 6,641 |
coremltools | coremltools/test/sklearn_tests/test_nearest_neighbors_builder.py | .py | # Copyright (c) 2019, 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 unittest
from coremltools._deps import _HAS_SKLEARN
from coremltools.mod... | 419 | 16,089 |
coremltools | coremltools/test/sklearn_tests/test_one_hot_encoder.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 unittest
from copy import copy
import numpy as np
from packaging.version import Version
from ..... | 291 | 10,311 |
coremltools | coremltools/test/sklearn_tests/test_k_neighbors_classifier.py | .py | # Copyright (c) 2019, 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
from scipy import sparse
from coremltools._deps import _HAS_SKLEARN
if _HAS_SKLEARN:
... | 278 | 11,433 |
coremltools | coremltools/test/sklearn_tests/test_imputer.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 unittest
import numpy as np
import numpy.random as rn
from packaging.version import Version
fro... | 79 | 2,526 |
coremltools | coremltools/test/sklearn_tests/test_random_forest_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
import unittest
import numpy as np
from ..utils import load_boston
from coremltools._deps import _HAS_... | 165 | 6,285 |
coremltools | coremltools/test/sklearn_tests/test_io_types.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 unittest
import numpy as np
import PIL.Image
from ..utils import load_boston
import coremltools... | 344 | 14,420 |
coremltools | coremltools/test/sklearn_tests/test_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
import unittest
import numpy as _np
from ..utils import load_boston
from coremltools._deps import _HAS... | 60 | 1,912 |
coremltools | coremltools/test/sklearn_tests/test_composite_pipelines.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 unittest
import pandas as pd
from packaging.version import Version
from ..utils import load_bos... | 86 | 3,033 |
coremltools | coremltools/test/sklearn_tests/test_standard_scalar.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 unittest
import numpy as np
from ..utils import load_boston
from coremltools._deps import _HAS_... | 65 | 1,955 |
coremltools | coremltools/test/sklearn_tests/test_glm_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
import itertools
import random
import unittest
import pandas as pd
from coremltools._deps import _HAS_... | 113 | 4,400 |
coremltools | coremltools/test/sklearn_tests/test_dict_vectorizer.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 unittest
import numpy as np
import numpy.random as rn
import pandas as pd
import coremltools
fr... | 103 | 3,358 |
coremltools | coremltools/test/sklearn_tests/test_NuSVC.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 random
import tempfile
import unittest
import pandas as pd
import pytest
from coremltools._deps... | 309 | 11,841 |
coremltools | coremltools/test/sklearn_tests/test_NuSVR.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 random
import tempfile
import unittest
import pandas as pd
import pytest
from ..utils import lo... | 222 | 7,336 |
coremltools | coremltools/test/sklearn_tests/test_feature_names.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 unittest
import coremltools.models._feature_management as fm
import coremltools.models.datatypes... | 31 | 1,031 |
coremltools | coremltools/test/sklearn_tests/test_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
import random
import tempfile
import unittest
import numpy as np
import pandas as pd
import pytest
fro... | 260 | 8,749 |
coremltools | coremltools/test/sklearn_tests/test_categorical_imputer.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 unittest
import numpy as np
from packaging.version import Version
from ..utils import load_bost... | 78 | 2,569 |
coremltools | coremltools/test/sklearn_tests/test_ridge_regression.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 unittest
import pandas as pd
from ..utils import load_boston
from coremltools._deps import _HAS... | 107 | 3,883 |
coremltools | coremltools/test/sklearn_tests/test_random_forest_regression_numeric.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 itertools
import unittest
import pandas as pd
import pytest
from ..utils import load_boston
fro... | 108 | 3,695 |
coremltools | coremltools/test/sklearn_tests/test_linear_regression.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 unittest
import pandas as pd
from ..utils import load_boston
from coremltools._deps import _HAS... | 137 | 4,962 |
coremltools | coremltools/test/sklearn_tests/test_random_forest_regression.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 unittest
from ..utils import load_boston
from coremltools._deps import _HAS_SKLEARN
if _HAS_SK... | 88 | 3,275 |
coremltools | coremltools/test/sklearn_tests/test_random_forest_classifier_numeric.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 itertools
import unittest
import numpy as np
import pandas as pd
import pytest
from packaging.ve... | 142 | 5,039 |
coremltools | coremltools/test/sklearn_tests/test_SVC.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 copy
import random
import tempfile
import unittest
import numpy as np
import pandas as pd
import... | 370 | 14,260 |
coremltools | coremltools/test/sklearn_tests/test_utils.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 unittest
from ..utils import load_boston
from coremltools._deps import _HAS_SKLEARN
from coremltoo... | 51 | 1,864 |
coremltools | coremltools/models/pipeline.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
"""
Pipeline utils for this package.
"""
from coremltools import proto as _proto
from .. import SPECIF... | 310 | 10,843 |
coremltools | coremltools/models/array_feature_extractor.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 . import datatypes
from ._inter... | 62 | 2,006 |
coremltools | coremltools/models/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
"""
Tree ensemble builder class to construct CoreML models.
"""
import collections as _collections
from... | 432 | 15,797 |
coremltools | coremltools/models/utils.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
"""
Utilities for the entire package.
"""
import copy as _copy
import gc as _gc
import math as _math
imp... | 2,480 | 88,773 |
coremltools | coremltools/models/datatypes.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
"""
Basic Data Types.
"""
import numpy as _np
from coremltools import proto
class _DatatypeBase:
... | 246 | 6,823 |
coremltools | coremltools/models/model.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 atexit as _atexit
import json
import os as _os
import shutil as _shutil
import tempfile as _tempf... | 1,192 | 45,001 |
coremltools | coremltools/models/__init__.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 . import (
_feature_management,
_interface_management,
array_feature_extractor,
com... | 40 | 1,105 |
coremltools | coremltools/models/feature_vectorizer.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 . import datatypes
from ._featu... | 99 | 3,674 |
coremltools | coremltools/models/compute_plan.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 dataclasses import dataclass as _dataclass
from typing import Any as _Any
from typing import Di... | 449 | 13,106 |
coremltools | coremltools/models/_interface_management.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 _feature_management as _fm
from . import datatypes
def se... | 216 | 7,137 |
coremltools | coremltools/models/_feature_management.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 operator as op
from collections import defaultdict
from copy import copy
from functools import re... | 355 | 11,762 |
coremltools | coremltools/models/_deprecation.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 functools
import warnings
def deprecated(obj=None, suffix="", version="", obj_prefix=""):
""... | 36 | 1,149 |
coremltools | coremltools/models/compute_device.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 abc import ABC as _ABC
from typing import List as _List
from coremltools import _logger
try:
... | 136 | 4,057 |
coremltools | coremltools/models/_compiled_model.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 os.path import expanduser as _expanduser
from typing import Optional as _Optional
from typing impor... | 250 | 8,748 |
coremltools | coremltools/models/nearest_neighbors/builder.py | .py | # Copyright (c) 2019, 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 coremltools
from coremltools import proto
from .. import datatypes
class ... | 665 | 21,165 |
coremltools | coremltools/models/ml_program/compression_utils.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 numpy as _np
from coremltools.converters.mil.mil import Operation as _Operation
from coremltools... | 113 | 4,516 |
coremltools | coremltools/models/ml_program/experimental/debugging_utils.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 gc
import random
from collections import OrderedDict, deque
from collections.abc import AsyncIter... | 1,591 | 57,197 |
coremltools | coremltools/models/ml_program/experimental/async_wrapper.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 atexit
import os
import shutil
import tempfile
from abc import ABC, abstractmethod
from pathlib i... | 453 | 15,124 |
coremltools | coremltools/models/ml_program/experimental/__init__.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 . import (
async_wrapper,
compute_plan_utils,
debugging_utils,
model_structure_path... | 15 | 370 |
coremltools | coremltools/models/ml_program/experimental/model_structure_path.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 collections.abc import Mapping as _Mapping
from collections.abc import Sequence as _Sequence
from d... | 399 | 14,270 |
coremltools | coremltools/models/ml_program/experimental/remote_device.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 asyncio as _asyncio
import json as _json
import os as _os
import shutil as _shutil
import subproc... | 2,576 | 83,221 |
coremltools | coremltools/models/ml_program/experimental/compute_plan_utils.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 copy
from typing import Callable, List, Optional
from coremltools import ComputeUnit, _logger, p... | 554 | 19,394 |
coremltools | coremltools/models/ml_program/experimental/perf_utils.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 gc
import random
import string
from dataclasses import dataclass
from typing import Any, Dict, Li... | 485 | 16,703 |
coremltools | coremltools/models/ml_program/experimental/torch/debugging_utils.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 coremltools.converters import convert
from collections import OrderedDict, deque
from dataclasses... | 2,335 | 79,102 |
coremltools | coremltools/models/ml_program/experimental/torch/perf_utils.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 collections import defaultdict
from dataclasses import dataclass
from typing import Any, Dict, List... | 266 | 10,220 |
coremltools | coremltools/models/neural_network/utils.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 copy as _copy
from coremltools.models.utils import _get_model
from .builder import NeuralNetwor... | 212 | 6,852 |
coremltools | coremltools/models/neural_network/builder.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
"""
Neural network builder class to construct Core ML models.
"""
from math import floor as _math_floor
... | 8,889 | 339,341 |
coremltools | coremltools/models/neural_network/printer.py | .py | # Copyright (c) 2018, 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 .spec_inspection_utils import (_get_feature_description_summary,
... | 115 | 3,748 |
coremltools | coremltools/models/neural_network/optimization_utils.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
"""
Neural Network optimization utilities.
"""
import numpy as _np
from coremltools import _logger
de... | 280 | 9,167 |
coremltools | coremltools/models/neural_network/flexible_shape_utils.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
"""
Utilities to annotate neural network features with flexible shape information.
"""
from typing impo... | 825 | 29,618 |
coremltools | coremltools/models/neural_network/update_optimizer_utils.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
"""
Neural Network optimizer utilities.
"""
class AdamParams:
"""
Adam - A Method for Stochast... | 192 | 4,775 |
coremltools | coremltools/models/neural_network/quantization_utils.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
"""
Utilities to compress Neural Network Models.
Only available in coremltools 2.0b1 and onwards
"""
fro... | 1,701 | 59,271 |
coremltools | coremltools/models/neural_network/spec_inspection_utils.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
def _get_weight_param_summary(wp):
"""Get a summary of proto.NeuralN... | 298 | 10,766 |
coremltools | coremltools/converters/__init__.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
# expose directories as imports
from . import libsvm, lightgbm, sklearn, xgboost
from ._converters_entry... | 19 | 489 |
coremltools | coremltools/converters/_converters_entry.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 collections
from datetime import date
import gc
import os
from typing import List, Optional, Text... | 1,191 | 50,180 |
coremltools | coremltools/converters/_profile_utils.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 time
_FUNCTION_PROFILE_REGISTRY = {} # str -> list (function name to time stack)
_... | 79 | 2,375 |
coremltools | coremltools/converters/libsvm/_libsvm_util.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_LIBSVM
def load_model(model_path):
"""Load a libsvm model from a path on... | 38 | 971 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.