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/optimize/torch/optimization_config.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 re as _re
from collections import OrderedDict as _OrderedDict
from enum import Enum as _Enum
f... | 198 | 7,446 |
coremltools | coremltools/optimize/torch/_logging.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 logging
import os
def init_root_logger():
logger = get_root_logger()
logger.propagat... | 52 | 1,472 |
coremltools | coremltools/optimize/torch/palettization/palettizer.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 logging as _logging
from typing import Dict as _Dict
from typing import Optional as _Optional
... | 420 | 19,524 |
coremltools | coremltools/optimize/torch/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 typing import Tuple as _Tuple
import torch as _torch
import torch.distributed as _dist
def ve... | 85 | 3,096 |
coremltools | coremltools/optimize/torch/palettization/_fake_palettizer_tensor_hook.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 gc
from typing import Callable as _Callable
from typing import Tuple as _Tuple
import torch a... | 297 | 9,876 |
coremltools | coremltools/optimize/torch/palettization/fake_palettize.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 contextlib
import logging as _logging
from typing import Optional as _Optional
from typing imp... | 805 | 32,363 |
coremltools | coremltools/optimize/torch/palettization/post_training_palettization.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 logging as _logging
from collections import OrderedDict as _OrderedDict
from typing import Any... | 345 | 15,751 |
coremltools | coremltools/optimize/torch/palettization/_supported_modules.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 typing import Dict as _Dict
from typing import List as _List
from typing import Optional as _Opt... | 369 | 12,659 |
coremltools | coremltools/optimize/torch/palettization/sensitive_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 copy as _copy
import logging as _logging
import tempfile as _tempfile
from collections import ... | 703 | 33,516 |
coremltools | coremltools/optimize/torch/palettization/__init__.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
"""
.. _coremltools_optimize_torch_palettization:
.. include:: palettization_desc.rst
:end-line... | 68 | 2,283 |
coremltools | coremltools/optimize/torch/palettization/_efficient_kmeans.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 typing import Optional as _Optional
from typing import Union as _Union
import numpy as _np
impo... | 278 | 10,651 |
coremltools | coremltools/optimize/torch/palettization/_custom_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
from typing import Dict as _Dict
from typing import Type as _Type
import torch as _torch
import torc... | 375 | 16,554 |
coremltools | coremltools/optimize/torch/palettization/_partitioner.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 as _math
from typing import Optional as _Optional
from typing import Tuple as _Tuple
imp... | 356 | 14,652 |
coremltools | coremltools/optimize/torch/palettization/palettization_config.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 as _OrderedDict
from typing import Any as _Any
from typing import... | 545 | 26,345 |
coremltools | coremltools/optimize/torch/quantization/_coreml_quantizer_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 itertools as _itertools
from typing import Callable as _Callable
from typing import List as _L... | 785 | 27,954 |
coremltools | coremltools/optimize/torch/quantization/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 logging as _logging
from collections import OrderedDict as _OrderedDict
from typing import Any... | 569 | 23,810 |
coremltools | coremltools/optimize/torch/quantization/_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 math
import operator as _operator
from collections import defaultdict
from enum import Enum as... | 262 | 8,119 |
coremltools | coremltools/optimize/torch/quantization/quantization_config.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 logging as _logging
from collections import OrderedDict as _OrderedDict
from enum import Enum ... | 455 | 20,046 |
coremltools | coremltools/optimize/torch/quantization/_annotation_config.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 typing import Optional as _Optional
import torch as _torch
import torch.ao.quantization as _aoq... | 110 | 4,080 |
coremltools | coremltools/optimize/torch/quantization/__init__.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
"""
.. _coremltools_optimize_torch_qat:
Quantization refers to techniques for performing neural netw... | 57 | 1,991 |
coremltools | coremltools/optimize/torch/quantization/_backend_config_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 copy import deepcopy as _deepcopy
from typing import Any as _Any
from typing import Callable as ... | 451 | 14,593 |
coremltools | coremltools/optimize/torch/quantization/_qconfig_mapping.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 logging as _logging
from typing import Any as _Any
from typing import Callable as _Callable
fr... | 394 | 15,517 |
coremltools | coremltools/optimize/torch/quantization/_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
import operator as _operator
from typing import Callable as _Callable
from typing import List as _Lis... | 625 | 19,656 |
coremltools | coremltools/optimize/torch/quantization/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
import copy as _copy
import logging as _logging
from typing import Any as _Any
from typing import Opt... | 445 | 20,350 |
coremltools | coremltools/optimize/torch/quantization/_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
from collections import defaultdict as _defaultdict
from typing import Any as _Any
from typing import... | 548 | 25,535 |
coremltools | coremltools/optimize/torch/quantization/_backend_config.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 operator as _operator
from typing import Any as _Any
from typing import List as _List
from typ... | 1,142 | 31,349 |
coremltools | coremltools/optimize/torch/quantization/modules/quantized_modules.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 as _OrderedDict
from typing import Type as _Type
import torch.ao... | 63 | 1,811 |
coremltools | coremltools/optimize/torch/quantization/modules/conv_transpose_fused.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
# Original implementation from https://github.com/pytorch/pytorch/blob/main/torch/ao/nn/intrinsic/qat... | 531 | 16,077 |
coremltools | coremltools/optimize/torch/quantization/modules/conv_transpose.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
# Original implementation from https://github.com/pytorch/pytorch/blob/main/torch/ao/nn/qat/modules/c... | 404 | 13,078 |
coremltools | coremltools/optimize/torch/quantization/modules/qat_modules.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 as _OrderedDict
from typing import Type as _Type
from typing impo... | 264 | 7,367 |
coremltools | coremltools/optimize/torch/quantization/modules/fused_modules.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 as _OrderedDict
from typing import Union as _Union
import torch ... | 122 | 2,418 |
coremltools | coremltools/optimize/torch/quantization/modules/observers.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
# Implementation for reset_min_max_vals, _save_to_state_dict and _load_from_state_dict
# has been ada... | 262 | 10,349 |
coremltools | coremltools/optimize/torch/quantization/modules/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
# Implementation for LearnableFakeQuantize class adapted from:
# - https://github.com/pytorch/pytorch... | 380 | 15,337 |
coremltools | coremltools/optimize/torch/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 logging as _logging
from typing import List as _List
from typing import Optional as _Optional
... | 242 | 8,804 |
coremltools | coremltools/optimize/torch/pruning/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
from abc import ABC as _ABC
from abc import abstractmethod as _abstractmethod
from typing import Unio... | 145 | 5,587 |
coremltools | coremltools/optimize/torch/pruning/__init__.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
"""
.. _coremltools_optimize_torch_pruning:
.. include:: pruning_desc.rst
_`MagnitudePruner`
======... | 59 | 1,775 |
coremltools | coremltools/optimize/torch/pruning/_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
import copy as _copy
import logging as _logging
from typing import Optional as _Optional
from typing ... | 163 | 7,160 |
coremltools | coremltools/optimize/torch/pruning/_base_pruning_method.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 logging as _logging
import types as _types
from typing import Any as _Any
from typing import D... | 288 | 13,035 |
coremltools | coremltools/optimize/torch/pruning/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 as _copy
import logging as _logging
from collections import OrderedDict as _OrderedDict
f... | 552 | 24,571 |
coremltools | coremltools/optimize/torch/layerwise_compression/input_cacher.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
# Original implementation from https://github.com/IST-DASLab/sparsegpt
# Copyright 2023 IST Austria D... | 185 | 6,584 |
coremltools | coremltools/optimize/torch/layerwise_compression/__init__.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
"""
.. _coremltools_optimize_torch_layerwise_compression:
_`LayerwiseCompressor`
===================... | 99 | 2,939 |
coremltools | coremltools/optimize/torch/layerwise_compression/_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
# Original implementation from https://github.com/IST-DASLab/sparsegpt
# Copyright 2023 IST Austria D... | 212 | 7,474 |
coremltools | coremltools/optimize/torch/layerwise_compression/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
# Original implementation from https://github.com/IST-DASLab/sparsegpt
# Copyright 2023 IST Austria D... | 717 | 31,336 |
coremltools | coremltools/optimize/torch/layerwise_compression/layerwise_compressor.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
# Original implementation from https://github.com/IST-DASLab/sparsegpt
# Copyright 2023 IST Austria D... | 430 | 18,146 |
coremltools | coremltools/optimize/torch/_utils/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
import logging as _logging
from typing import Tuple, Type
import torch
from coremltools.optimize.to... | 103 | 3,872 |
coremltools | coremltools/optimize/torch/_utils/graph_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 operator as _operator
from typing import Any as _Any
from typing import Dict as _Dict
from typ... | 558 | 23,075 |
coremltools | coremltools/optimize/torch/_utils/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
from abc import ABC as _ABC
from abc import abstractmethod as _abstractmethod
from functools import p... | 92 | 3,756 |
coremltools | coremltools/optimize/torch/_utils/state_dict_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 typing import Any, Dict, Mapping, NamedTuple
import torch
class AddMetadataStateDictHook:
... | 61 | 2,228 |
coremltools | coremltools/optimize/torch/_utils/python_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 logging as _logging
from collections import OrderedDict as _OrderedDict
from typing import IO ... | 122 | 3,781 |
coremltools | coremltools/optimize/torch/_utils/transforms.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 operator as _operator
from abc import ABC as _ABC
from abc import abstractmethod as _abstractm... | 1,189 | 38,536 |
coremltools | coremltools/optimize/torch/_utils/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
from typing import Type as _Type
import torch as _torch
from coremltools.optimize.torch._utils.pyth... | 67 | 2,403 |
coremltools | coremltools/optimize/torch/_utils/registry.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
class BaseRegistry(_ABC):
"""
Base class for registries that re... | 110 | 4,067 |
coremltools | coremltools/optimize/torch/_utils/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 enum import Enum
from typing import Dict as _Dict
from typing import List as _List
from typing i... | 145 | 6,075 |
coremltools | coremltools/optimize/torch/_utils/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
# Implementation for transform_to_ch_axis function has been adapted from
# https://github.com/pytorch... | 255 | 8,009 |
coremltools | coremltools/optimize/torch/_utils/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 copy as _copy
import logging as _logging
from typing import Dict as _Dict
from typing import L... | 190 | 7,424 |
coremltools | coremltools/optimize/torch/_utils/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 logging as _logging
import queue as _queue
from abc import abstractmethod as _abstractmethod
f... | 1,102 | 43,883 |
coremltools | coremltools/optimize/torch/_utils/model_size_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 math
import torch.nn
from coremltools.optimize.torch._utils.metadata_utils import Compressio... | 43 | 1,516 |
coremltools | coremltools/optimize/torch/_utils/version_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 torch as _torch
from packaging import version
def version_ge(module, target_version):
re... | 20 | 508 |
coremltools | coremltools/optimize/torch/_utils/dist_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 as _os
import torch as _torch
import torch.distributed as _dist
def ddp_setup(rank: int,... | 37 | 1,100 |
coremltools | coremltools/optimize/torch/_utils/joint_compression_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
def is_pruner_prepared(optimizer):
"""
Check if any layer to be compressed with `optimizer` h... | 46 | 1,689 |
coremltools | coremltools/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 os.path
import numpy as np
import pandas as pd
import requests
def load_boston():
DATA_UR... | 33 | 1,025 |
coremltools | coremltools/test/modelpackage/test_mlmodel.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 numpy as np
import torch
import coremltools as ct
from coremltools._dep... | 75 | 2,137 |
coremltools | coremltools/test/modelpackage/test_mlmodel_temp_cleanup.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
"""Regression tests for MLModel temporary .mlpackage cleanup.
Historically `MLModel` constructed from a... | 128 | 5,070 |
coremltools | coremltools/test/modelpackage/test_modelpackage.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 json
import os
import platform
import shutil
import tempfile
import numpy as n... | 762 | 30,485 |
coremltools | coremltools/test/ml_program/test_compression.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 typing import Optional
import numpy as np
import torch
import coremltools as ct
from coremltools.... | 175 | 8,123 |
coremltools | coremltools/test/ml_program/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 copy
import itertools
import os
import platform
import shutil
import tempfile
from sys import ver... | 1,904 | 74,405 |
coremltools | coremltools/test/ml_program/experimental/test_async_wrapper.py | .py | # Copyright (c) 2025, Apple Inc. All rights reserved.
import gc
import os
import coremltools as ct
from coremltools.converters.mil import Builder as mb
import pytest
from coremltools.models.ml_program.experimental.async_wrapper import (
MLModelAsyncWrapper,
)
class TestMLModelAsyncWrapper:
@staticmethod
... | 44 | 1,392 |
coremltools | coremltools/test/ml_program/experimental/test_torch_debugging_utils.py | .py | # Copyright (c) 2024, Apple Inc. All rights reserved.
from typing import Callable, Tuple
import numpy as np
import pytest
import torch
import coremltools as ct
from coremltools import proto
from coremltools._deps import _HAS_TORCH_EXPORT_API
from coremltools.models.ml_program.experimental.torch.debugging_utils impo... | 461 | 17,153 |
coremltools | coremltools/test/ml_program/experimental/test_remote_device.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 random
import platform
import subprocess
import tempfile
import time
from pathlib import Path
fro... | 437 | 14,746 |
coremltools | coremltools/test/ml_program/experimental/test_compute_plan_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 typing import Optional
import platform
import pytest
import coremltools as ct
from coremltools... | 204 | 7,847 |
coremltools | coremltools/test/ml_program/experimental/test_debugging_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 re
from typing import Callable
import numpy as np
import pytest
import coremltools as ct
fro... | 367 | 14,511 |
coremltools | coremltools/test/ml_program/experimental/test_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 platform
from typing import Optional
import numpy as np
import pytest
import torch
import co... | 298 | 10,482 |
coremltools | coremltools/test/neural_network/test_simple_nn_inference.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 numpy as np
import coremltools
import coremltools.models.datatypes as datatypes
from ... | 54 | 1,780 |
coremltools | coremltools/test/neural_network/test_tf_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 pytest
import coremltools.models.datatypes ... | 515 | 19,569 |
coremltools | coremltools/test/neural_network/test_numpy_nn_layers.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 random
import tempfile
import unittest
im... | 7,112 | 282,016 |
coremltools | coremltools/test/neural_network/test_quantization.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
"""
Module containing unit tests for verifying various quantizations.
"""
import itertools
import unitt... | 681 | 23,412 |
coremltools | coremltools/test/neural_network/test_custom_neural_nets.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 tempfile
import unittest
import numpy as np
import coremltools
import coremltools.mod... | 90 | 3,320 |
coremltools | coremltools/test/neural_network/test_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
import itertools
from shutil import copytree, rmtree
from tempfile import TemporaryDirectory
import py... | 155 | 5,618 |
coremltools | coremltools/test/neural_network/test_neural_networks.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 unittest
import coremltools
from coremltools import proto
from coremltools.models.utils import _... | 60 | 2,017 |
coremltools | coremltools/test/neural_network/test_nn_builder.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
import pytest
import unittest
import coremltools
from coremltools import ComputeUnit... | 628 | 24,047 |
coremltools | coremltools/test/neural_network/test_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 os
import tempfile
import unittest
import numpy as np
import PIL.Image
import coremltools
from ... | 590 | 23,297 |
coremltools | coremltools/test/api/test_api_examples.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
import os
import platform
import shutil
import tempfile
from collections import Counter
from... | 980 | 39,103 |
coremltools | coremltools/test/api/test_api_visibilities.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 re
import coremltools as ct
def _get_visible_items(d):
return [x for x in dir(d) if not x... | 358 | 11,333 |
coremltools | coremltools/test/pipeline/test_model_updatable.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 os
import shutil
import tempfile
import unittest
import numpy as _np
import coremltools.models.... | 797 | 28,313 |
coremltools | coremltools/test/pipeline/test_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
import itertools
import tempfile
import unittest
import numpy as np
import pytest
from ..utils import ... | 404 | 15,103 |
coremltools | coremltools/test/optimize/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 itertools
import numpy as np
import pytest
from coremltools.converters.mil.mil import types
fro... | 248 | 9,683 |
coremltools | coremltools/test/optimize/api/test_optimize_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 tempfile
import pytest
from coremltools.converters.mil.testing_utils import get_op_types_in_... | 680 | 23,419 |
coremltools | coremltools/test/optimize/coreml/test_post_training_quantization.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
import logging
import platform
import re
import shutil
import tempfile
from contextlib ... | 3,018 | 126,965 |
coremltools | coremltools/test/optimize/coreml/test_passes.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
import os
import re
import tempfile
import cattrs
import numpy as np
import pytest
imp... | 3,860 | 139,904 |
coremltools | coremltools/test/optimize/torch/test_api_surface.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 typing import List
import coremltools.optimize.torch
def _get_visible_items(d):
return [x... | 163 | 5,833 |
coremltools | coremltools/test/optimize/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 contextlib
import importlib
import inspect
import io
import logging
import os
import pathlib
i... | 253 | 6,791 |
coremltools | coremltools/test/optimize/torch/test_base_optimizer.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.base_model_optimizer import (
BaseDat... | 69 | 2,355 |
coremltools | coremltools/test/optimize/torch/smoke_test.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
class TestSmokeTest:
def test_coremltools_optimize_torch_import(self):
imp... | 32 | 1,322 |
coremltools | coremltools/test/optimize/torch/conftest.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
# Needed for test_compression_for_dkm_on_non_cpu_device_with_pcs that uses mps in test/con... | 120 | 3,361 |
coremltools | coremltools/test/optimize/torch/palettization/test_palettization_api.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
import pytest
import torch
import torch.nn as nn
import torch.nn.functional as F
from c... | 781 | 30,514 |
coremltools | coremltools/test/optimize/torch/palettization/test_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
import copy
import pytest
import torch
from coremltools.optimize.torch.palettization._utils import ... | 55 | 1,835 |
coremltools | coremltools/test/optimize/torch/palettization/test_palettizer.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.palettization import (
DKMPalettizer,... | 121 | 4,600 |
coremltools | coremltools/test/optimize/torch/palettization/test_efficient_kmeans.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 torch
from coremltools.optimize.torch.palettization._efficient_kmeans import _EfficientKMeans... | 39 | 1,360 |
coremltools | coremltools/test/optimize/torch/palettization/test_post_training_palettization.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
import pytest
import torch
import torch.functional as F
import torch.nn as nn
from core... | 230 | 7,502 |
coremltools | coremltools/test/optimize/torch/palettization/test_sensitive_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
from collections import OrderedDict
from contextlib import nullcontext
from typing import Any, Dict
f... | 360 | 11,866 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.