Search is not available for this dataset
repo stringlengths 2 152 ⌀ | file stringlengths 15 239 | code stringlengths 0 58.4M | file_length int64 0 58.4M | avg_line_length float64 0 1.81M | max_line_length int64 0 12.7M | extension_type stringclasses 364
values |
|---|---|---|---|---|---|---|
nni | nni-master/nni/experiment/config/training_services/k8s_storage.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
"""
Storage config classes for ``KubeflowConfig`` and ``FrameworkControllerConfig``
"""
__all__ = ['K8sStorageConfig', 'K8sAzureStorageConfig', 'K8sNfsConfig']
from dataclasses import dataclass
from typing import Optional
from typing_extension... | 1,528 | 29.58 | 119 | py |
nni | nni-master/nni/experiment/config/training_services/kubeflow.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
"""
Configuration for Kubeflow training service.
Check the reference_ for explaination of each field.
You may also want to check `Kubeflow training service doc`_.
.. _reference: https://nni.readthedocs.io/en/stable/reference/experiment_config.... | 1,872 | 29.704918 | 105 | py |
nni | nni-master/nni/experiment/config/training_services/local.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
"""
Configuration for local training service.
Check the reference_ for explaination of each field.
You may also want to check `local training service doc`_.
.. _reference: https://nni.readthedocs.io/en/stable/reference/experiment_config.html
... | 1,707 | 33.16 | 108 | py |
nni | nni-master/nni/experiment/config/training_services/openpai.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
"""
Configuration for OpenPAI training service.
Check the reference_ for explaination of each field.
You may also want to check `OpenPAI training service doc`_.
.. _reference: https://nni.readthedocs.io/en/stable/reference/experiment_config.ht... | 2,180 | 33.619048 | 113 | py |
nni | nni-master/nni/experiment/config/training_services/remote.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
"""
Configuration for remote training service.
Check the reference_ for explaination of each field.
You may also want to check `remote training service doc`_.
.. _reference: https://nni.readthedocs.io/en/stable/reference/experiment_config.html... | 2,862 | 35.705128 | 118 | py |
nni | nni-master/nni/experiment/config/utils/__init__.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
"""
Utility functions for experiment config classes.
Check "public.py" to see which functions you can utilize.
"""
from .public import *
from .internal import *
| 237 | 18.833333 | 57 | py |
nni | nni-master/nni/experiment/config/utils/internal.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
"""
Utility functions for experiment config classes, internal part.
If you are implementing a config class for a training service, it's unlikely you will need these.
"""
from __future__ import annotations
__all__ = [
'get_base_path', 'set_... | 7,910 | 35.123288 | 111 | py |
nni | nni-master/nni/experiment/config/utils/public.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
"""
Utility functions for experiment config classes.
"""
import dataclasses
import math
from pathlib import Path
from typing import Union
__all__ = [
'PathLike', 'is_missing',
'canonical_gpu_indices', 'validate_gpu_indices',
'parse_... | 2,320 | 29.946667 | 103 | py |
nni | nni-master/nni/feature_engineering/__init__.py | 1 | 0 | 0 | py | |
nni | nni-master/nni/feature_engineering/feature_selector.py | # Copyright (c) Microsoft Corporation. All rights reserved.
#
# MIT License
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
# associated documentation files (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to u... | 2,149 | 34.833333 | 100 | py |
nni | nni-master/nni/mutable/__init__.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from .annotation import *
from .container import *
from .exception import *
from .frozen import *
from .mutable import *
from .utils import *
| 216 | 20.7 | 38 | py |
nni | nni-master/nni/mutable/_notimplemented.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
"""Several planned features that are under discussion / not implemented yet."""
from __future__ import annotations
from .annotation import MutableAnnotation
from .mutable import LabeledMutable, MutableSymbol, Categorical, Numerical
def randin... | 3,845 | 31.05 | 120 | py |
nni | nni-master/nni/mutable/annotation.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from __future__ import annotations
__all__ = [
'MutableAnnotation', 'Constraint', 'ExpressionConstraint',
]
import logging
from typing import Iterable, Callable
from numpy.random import RandomState
from .exception import ConstraintViolati... | 6,468 | 37.052941 | 112 | py |
nni | nni-master/nni/mutable/container.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from __future__ import annotations
__all__ = [
'MutableList', 'MutableDict'
]
from typing import Any, Iterable, Iterator, Mapping, Callable, Sequence
from .exception import SampleValidationError
from .mutable import Mutable, Sample, Labele... | 12,741 | 36.366569 | 134 | py |
nni | nni-master/nni/mutable/exception.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from __future__ import annotations
__all__ = ['ConstraintViolation', 'SampleValidationError', 'SampleMissingError']
from typing import overload
class SampleValidationError(ValueError):
"""Exception raised when a sample is invalid."""
... | 1,319 | 29 | 103 | py |
nni | nni-master/nni/mutable/frozen.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from __future__ import annotations
"""Utilities to freeze mutables upon its creation (either before or after),
such that when a proper context is provided, the mutables should look exactly the same as its frozen version.
"""
__all__ = [
'en... | 8,116 | 33.394068 | 128 | py |
nni | nni-master/nni/mutable/mutable.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from __future__ import annotations
__all__ = [
'Mutable', 'LabeledMutable', 'MutableSymbol', 'MutableExpression', 'Sample',
'Categorical', 'CategoricalMultiple', 'Numerical',
]
import copy
import itertools
import logging
from collection... | 51,711 | 40.073868 | 133 | py |
nni | nni-master/nni/mutable/shortcut.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
"""High-level API for mutables."""
from __future__ import annotations
__all__ = [
'choice', 'uniform', 'quniform', 'loguniform', 'qloguniform',
'normal', 'qnormal',
]
import logging
from typing import TYPE_CHECKING, TypeVar, overload, ... | 6,904 | 34.410256 | 117 | py |
nni | nni-master/nni/mutable/symbol.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
"""
Infrastructure for symbolic execution.
Symbolic execution is a technique for executing programs on symbolic inputs.
It supports arithmetic operations and comparisons on abstract symbols,
and can be used to represent symbolic expressions for ... | 21,328 | 37.56962 | 134 | py |
nni | nni-master/nni/mutable/utils.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from __future__ import annotations
__all__ = [
'uid', 'reset_uid',
'NoContextError', 'ContextStack', 'get_current_context',
'label_scope', 'auto_label',
]
import logging
from collections import defaultdict
from typing import Any, Li... | 13,845 | 35.151436 | 134 | py |
nni | nni-master/nni/nas/__init__.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from .utils import *
| 95 | 18.2 | 38 | py |
nni | nni-master/nni/nas/benchmark/__init__.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
try:
import peewee
except ImportError:
import warnings
warnings.warn('peewee is not installed. Please install it to use NAS benchmarks.')
del peewee
from .evaluator import *
from .space import *
from .utils import load_benchmark, do... | 337 | 21.533333 | 86 | py |
nni | nni-master/nni/nas/benchmark/constants.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import os
from nni.common.blob_utils import NNI_BLOB, nni_cache_home
ENV_NASBENCHMARK_DIR = 'NASBENCHMARK_DIR'
def _get_nasbenchmark_dir():
nni_home = nni_cache_home()
return os.getenv(ENV_NASBENCHMARK_DIR, os.path.join(nni_home, 'na... | 586 | 23.458333 | 82 | py |
nni | nni-master/nni/nas/benchmark/download.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import argparse
if __name__ == '__main__':
parser = argparse.ArgumentParser('NAS benchmark downloader')
parser.add_argument('benchmark_name', choices=['nasbench101', 'nasbench201', 'nds'])
args = parser.parse_args()
from .utils... | 391 | 27 | 88 | py |
nni | nni-master/nni/nas/benchmark/evaluator.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from __future__ import annotations
__all__ = ['BenchmarkEvaluator', 'NasBench101Benchmark', 'NasBench201Benchmark']
import itertools
import logging
import random
import warnings
from typing import Any, cast
import nni
from nni.mutable import S... | 8,938 | 36.245833 | 134 | py |
nni | nni-master/nni/nas/benchmark/space.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from __future__ import annotations
__all__ = ['BenchmarkModelSpace', 'SlimBenchmarkSpace']
import logging
from typing import TYPE_CHECKING, overload
from nni.mutable import MutableDict
from nni.nas.space import RawFormatModelSpace, BaseModelSp... | 2,697 | 28.326087 | 125 | py |
nni | nni-master/nni/nas/benchmark/utils.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import functools
import json
import os
from playhouse.sqlite_ext import SqliteExtDatabase
from nni.common.blob_utils import load_or_download_file
from .constants import DB_URLS, DATABASE_DIR
json_dumps = functools.partial(json.dumps, sort_ke... | 1,528 | 26.303571 | 125 | py |
nni | nni-master/nni/nas/benchmark/nasbench101/__init__.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from .constants import INPUT, OUTPUT, CONV3X3_BN_RELU, CONV1X1_BN_RELU, MAXPOOL3X3
from .schema import Nb101TrialStats, Nb101IntermediateStats, Nb101TrialConfig
from .query import query_nb101_trial_stats
| 278 | 38.857143 | 82 | py |
nni | nni-master/nni/nas/benchmark/nasbench101/constants.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
INPUT = 'input'
OUTPUT = 'output'
CONV3X3_BN_RELU = 'conv3x3-bn-relu'
CONV1X1_BN_RELU = 'conv1x1-bn-relu'
MAXPOOL3X3 = 'maxpool3x3'
LABEL2ID = {
INPUT: -1,
OUTPUT: -2,
CONV3X3_BN_RELU: 0,
CONV1X1_BN_RELU: 1,
MAXPOOL3X3: 2
}
| 320 | 16.833333 | 38 | py |
nni | nni-master/nni/nas/benchmark/nasbench101/db_gen.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import argparse
from tqdm import tqdm
from nasbench import api # pylint: disable=import-error
from nni.nas.benchmark.utils import load_benchmark
from .schema import Nb101TrialConfig, Nb101TrialStats, Nb101IntermediateStats
from .graph_util imp... | 2,585 | 42.1 | 94 | py |
nni | nni-master/nni/nas/benchmark/nasbench101/graph_util.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import hashlib
import numpy as np
from .constants import INPUT, LABEL2ID, OUTPUT
def _labeling_from_architecture(architecture, vertices):
return [INPUT] + [architecture['op{}'.format(i)] for i in range(1, vertices - 1)] + [OUTPUT]
def _... | 3,877 | 32.721739 | 96 | py |
nni | nni-master/nni/nas/benchmark/nasbench101/query.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import functools
from peewee import fn
from playhouse.shortcuts import model_to_dict
from nni.nas.benchmark.utils import load_benchmark
from .schema import Nb101TrialStats, Nb101TrialConfig, proxy
from .graph_util import hash_module, infer_num_... | 3,135 | 38.2 | 109 | py |
nni | nni-master/nni/nas/benchmark/nasbench101/schema.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from peewee import CharField, FloatField, ForeignKeyField, IntegerField, Model, Proxy
from playhouse.sqlite_ext import JSONField
from nni.nas.benchmark.utils import json_dumps
proxy = Proxy()
class Nb101TrialConfig(Model):
"""
Trial c... | 3,569 | 33.660194 | 118 | py |
nni | nni-master/nni/nas/benchmark/nasbench201/__init__.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from .constants import NONE, SKIP_CONNECT, CONV_1X1, CONV_3X3, AVG_POOL_3X3
from .schema import Nb201TrialStats, Nb201IntermediateStats, Nb201TrialConfig
from .query import query_nb201_trial_stats
| 271 | 37.857143 | 77 | py |
nni | nni-master/nni/nas/benchmark/nasbench201/constants.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
NONE = 'none'
SKIP_CONNECT = 'skip_connect'
CONV_1X1 = 'conv_1x1'
CONV_3X3 = 'conv_3x3'
AVG_POOL_3X3 = 'avg_pool_3x3'
PRIMITIVES = [
NONE,
SKIP_CONNECT,
CONV_1X1,
CONV_3X3,
AVG_POOL_3X3,
]
| 283 | 16.75 | 38 | py |
nni | nni-master/nni/nas/benchmark/nasbench201/db_gen.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import argparse
import re
import tqdm
import torch
from nni.nas.benchmark.utils import load_benchmark
from .constants import NONE, SKIP_CONNECT, CONV_1X1, CONV_3X3, AVG_POOL_3X3
from .schema import Nb201TrialConfig, Nb201TrialStats, Nb201Interm... | 5,453 | 47.265487 | 115 | py |
nni | nni-master/nni/nas/benchmark/nasbench201/query.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import functools
from peewee import fn
from playhouse.shortcuts import model_to_dict
from nni.nas.benchmark.utils import load_benchmark
from .schema import Nb201TrialStats, Nb201TrialConfig, proxy
def query_nb201_trial_stats(arch, num_epochs,... | 3,010 | 38.103896 | 117 | py |
nni | nni-master/nni/nas/benchmark/nasbench201/schema.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from peewee import CharField, FloatField, ForeignKeyField, IntegerField, Model, Proxy
from playhouse.sqlite_ext import JSONField
from nni.nas.benchmark.utils import json_dumps
proxy = Proxy()
class Nb201TrialConfig(Model):
"""
Trial c... | 5,970 | 36.086957 | 112 | py |
nni | nni-master/nni/nas/benchmark/nds/__init__.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from .constants import *
from .schema import NdsTrialConfig, NdsTrialStats, NdsIntermediateStats
from .query import query_nds_trial_stats
| 212 | 29.428571 | 71 | py |
nni | nni-master/nni/nas/benchmark/nds/constants.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
NONE = 'none'
SKIP_CONNECT = 'skip_connect'
AVG_POOL_3X3 = 'avg_pool_3x3'
MAX_POOL_3X3 = 'max_pool_3x3'
MAX_POOL_5X5 = 'max_pool_5x5'
MAX_POOL_7X7 = 'max_pool_7x7'
CONV_1X1 = 'conv_1x1'
CONV_3X3 = 'conv_3x3'
CONV_3X1_1X3 = 'conv_3x1_1x3'
CONV_7X1... | 530 | 25.55 | 38 | py |
nni | nni-master/nni/nas/benchmark/nds/db_gen.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import json
import argparse
import os
import numpy as np
import tqdm
from nni.nas.benchmark.utils import load_benchmark
from .schema import NdsTrialConfig, NdsTrialStats, NdsIntermediateStats
def inject_item(db, item, proposer, dataset, gener... | 5,989 | 36.4375 | 116 | py |
nni | nni-master/nni/nas/benchmark/nds/query.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import functools
from peewee import fn
from playhouse.shortcuts import model_to_dict
from nni.nas.benchmark.utils import load_benchmark
from .schema import NdsTrialStats, NdsTrialConfig, proxy
def query_nds_trial_stats(model_family, proposer,... | 3,585 | 41.690476 | 126 | py |
nni | nni-master/nni/nas/benchmark/nds/schema.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from peewee import CharField, FloatField, ForeignKeyField, IntegerField, Model, Proxy
from playhouse.sqlite_ext import JSONField
from nni.nas.benchmark.utils import json_dumps
proxy = Proxy()
class NdsTrialConfig(Model):
"""
Trial con... | 5,545 | 37.513889 | 133 | py |
nni | nni-master/nni/nas/benchmark/nlp/__init__.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from .schema import NlpTrialStats, NlpIntermediateStats, NlpTrialConfig
from .query import query_nlp_trial_stats
| 187 | 30.333333 | 71 | py |
nni | nni-master/nni/nas/benchmark/nlp/db_gen.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import json
import os
import argparse
import tqdm
from .schema import db, NlpTrialConfig, NlpTrialStats, NlpIntermediateStats
def main():
parser = argparse.ArgumentParser()
parser.add_argument('input_dir', help='Path to extracted NLP d... | 2,310 | 44.313725 | 137 | py |
nni | nni-master/nni/nas/benchmark/nlp/query.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import functools
from peewee import fn
from playhouse.shortcuts import model_to_dict
from .schema import NlpTrialStats, NlpTrialConfig
def query_nlp_trial_stats(arch, dataset, reduction=None, include_intermediates=False):
"""
Query tri... | 2,657 | 39.272727 | 126 | py |
nni | nni-master/nni/nas/benchmark/nlp/schema.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import os
from peewee import CharField, FloatField, ForeignKeyField, IntegerField, Model
from playhouse.sqlite_ext import JSONField, SqliteExtDatabase
from nni.nas.benchmark.utils import json_dumps
from nni.nas.benchmark.constants import DATABA... | 3,403 | 33.734694 | 127 | py |
nni | nni-master/nni/nas/evaluator/__init__.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from nni.common.framework import shortcut_framework
from .evaluator import *
from .functional import FunctionalEvaluator
shortcut_framework(__name__)
del shortcut_framework
| 250 | 19.916667 | 51 | py |
nni | nni-master/nni/nas/evaluator/evaluator.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from __future__ import annotations
__all__ = ['Evaluator', 'MutableEvaluator', 'FrozenEvaluator']
import logging
from contextlib import contextmanager
from typing import Any, Callable, Iterator, Iterable, Generator, TYPE_CHECKING, cast
from typ... | 16,746 | 41.613232 | 135 | py |
nni | nni-master/nni/nas/evaluator/functional.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from __future__ import annotations
from typing import ClassVar
from nni.common.serializer import SerializableObject
from .evaluator import MutableEvaluator
class FunctionalEvaluator(MutableEvaluator):
"""
Functional evaluator that dir... | 1,681 | 27.033333 | 93 | py |
nni | nni-master/nni/nas/evaluator/tensorflow.py | 0 | 0 | 0 | py | |
nni | nni-master/nni/nas/evaluator/pytorch/__init__.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import warnings
try:
from .lightning import *
except ImportError:
warnings.warn("PyTorch-Lightning must be installed to use PyTorch in NAS. "
"If you are not using PyTorch, please `nni.set_default_framework('none')`")
... | 329 | 26.5 | 93 | py |
nni | nni-master/nni/nas/evaluator/pytorch/lightning.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import logging
import os
import warnings
from pathlib import Path
from typing import Any, Dict, Union, Optional, List, Type
import pytorch_lightning as pl
import torch.nn as nn
import torch.nn.functional as nn_functional
import torch.optim as op... | 22,209 | 43.42 | 138 | py |
nni | nni-master/nni/nas/evaluator/pytorch/cgo/__init__.py | 0 | 0 | 0 | py | |
nni | nni-master/nni/nas/evaluator/pytorch/cgo/evaluator.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import warnings
from typing import Dict, List, Optional, Union, Type
import torch.nn as nn
import torch.optim as optim
import torchmetrics
from torch.utils.data import DataLoader
import nni
from ..lightning import LightningModule, _AccuracyWi... | 10,358 | 42.708861 | 135 | py |
nni | nni-master/nni/nas/evaluator/pytorch/cgo/trainer.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import pytorch_lightning as pl
from pytorch_lightning.strategies import SingleDeviceStrategy
class BypassStrategy(SingleDeviceStrategy):
strategy_name = "single_device"
def model_to_device(self) -> None:
pass
class Trainer(pl... | 1,318 | 31.170732 | 121 | py |
nni | nni-master/nni/nas/execution/__init__.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from .engine import *
from .event import *
from .sequential import *
from .training_service import *
| 175 | 21 | 38 | py |
nni | nni-master/nni/nas/execution/engine.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from __future__ import annotations
import logging
import time
from collections import defaultdict
from typing import Any, Iterable, NewType, Callable, Type, overload
from nni.nas.space import ExecutableModelSpace, ModelStatus
from .event impor... | 13,143 | 40.333333 | 126 | py |
nni | nni-master/nni/nas/execution/event.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from __future__ import annotations
__all__ = ['ModelEventType', 'ModelEvent', 'FinalMetricEvent', 'IntermediateMetricEvent', 'TrainingEndEvent']
from enum import Enum
from typing import ClassVar
from dataclasses import dataclass
from nni.nas.s... | 2,136 | 27.878378 | 109 | py |
nni | nni-master/nni/nas/execution/sequential.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from __future__ import annotations
__all__ = ['SequentialExecutionEngine']
import logging
import time
import traceback
from typing import Iterable, List, cast
from typing_extensions import Literal
import nni
from nni.runtime.trial_command_chan... | 6,966 | 39.982353 | 128 | py |
nni | nni-master/nni/nas/execution/training_service.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from __future__ import annotations
__all__ = ['TrainingServiceExecutionEngine']
import logging
import sys
import time
import weakref
from threading import Event, Thread
from typing import Iterable, TYPE_CHECKING, Any, cast
import nni
from nni.... | 17,297 | 42.792405 | 140 | py |
nni | nni-master/nni/nas/execution/cgo/__init__.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from .evaluator import *
from .middleware import CrossGraphOptimization
| 146 | 23.5 | 46 | py |
nni | nni-master/nni/nas/execution/cgo/evaluator.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from __future__ import annotations
__all__ = ['MultiModelLightningModule', 'MultiModelTrainer']
import pytorch_lightning
import torch
from pytorch_lightning.strategies import SingleDeviceStrategy
from torch import nn
from torchmetrics import Me... | 5,242 | 33.953333 | 121 | py |
nni | nni-master/nni/nas/execution/cgo/middleware.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from __future__ import annotations
__all__ = ['CrossGraphOptimization']
import logging
import time
import threading
from collections.abc import Iterable
from typing import List, Dict, Tuple, cast
from nni.common.device import GPUDevice, Device... | 19,538 | 47.725686 | 139 | py |
nni | nni-master/nni/nas/execution/cgo/logical_optimizer/__init__.py | 0 | 0 | 0 | py | |
nni | nni-master/nni/nas/execution/cgo/logical_optimizer/interface.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from abc import ABC
from .logical_plan import LogicalPlan
class AbstractOptimizer(ABC):
def __init__(self) -> None:
pass
def convert(self, logical_plan: LogicalPlan) -> None:
raise NotImplementedError
| 303 | 19.266667 | 57 | py |
nni | nni-master/nni/nas/execution/cgo/logical_optimizer/logical_plan.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import copy
from typing import Dict, Tuple, Any, Type, cast
from nni.common.device import Device, CPUDevice
from nni.mutable.utils import uid
from nni.nas.space import Edge, Graph, GraphModelSpace, Node
from nni.nas.space.graph_op import Cell, ... | 15,133 | 43.381232 | 112 | py |
nni | nni-master/nni/nas/execution/cgo/logical_optimizer/opt_dedup_input.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from typing import List, Dict, Tuple, cast
from nni.mutable.utils import uid
from nni.common.device import GPUDevice
from nni.nas.space import GraphModelSpace, Graph, Node
from .interface import AbstractOptimizer
from .logical_plan import Abstr... | 4,658 | 43.371429 | 110 | py |
nni | nni-master/nni/nas/experiment/__init__.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from .experiment import NasExperiment
from .config import NasExperimentConfig
| 152 | 24.5 | 39 | py |
nni | nni-master/nni/nas/experiment/experiment.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from __future__ import annotations
__all__ = ['NasExperiment']
import atexit
import logging
import warnings
from pathlib import Path
from typing import Any, ClassVar, cast
from typing_extensions import Literal
import nni
from nni.experiment im... | 20,529 | 42.680851 | 134 | py |
nni | nni-master/nni/nas/experiment/config/__init__.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from .experiment import *
from .engine import *
from .format import *
| 144 | 19.714286 | 38 | py |
nni | nni-master/nni/nas/experiment/config/engine.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
__all__ = [
'ExecutionEngineConfig', 'TrainingServiceEngineConfig', 'CgoEngineConfig', 'SequentialEngineConfig',
]
import logging
from dataclasses import dataclass
from typing import Optional
from nni.experiment.config import ExperimentConf... | 2,827 | 36.706667 | 120 | py |
nni | nni-master/nni/nas/experiment/config/experiment.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import logging
import sys
from dataclasses import dataclass
from pathlib import Path
from typing import Any, Dict, Optional, TYPE_CHECKING, Union, List
from typing_extensions import Literal
from nni.experiment.config import utils, ExperimentConf... | 9,113 | 44.118812 | 123 | py |
nni | nni-master/nni/nas/experiment/config/format.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from dataclasses import dataclass
from typing import Optional, List
from .utils import NamedSubclassConfigBase
__all__ = [
'ModelFormatConfig', 'GraphModelFormatConfig',
'SimplifiedModelFormatConfig', 'RawModelFormatConfig',
]
@datac... | 1,090 | 26.974359 | 85 | py |
nni | nni-master/nni/nas/experiment/config/utils.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from __future__ import annotations
__all__ = ['NamedSubclassConfigBase']
from typing import Type
from nni.experiment.config.base import ConfigBase
class NamedSubclassConfigBase(ConfigBase):
"""Base class for configs with ``name`` to spec... | 1,580 | 32.638298 | 118 | py |
nni | nni-master/nni/nas/hub/__init__.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from nni.common.framework import shortcut_framework
shortcut_framework(__name__)
del shortcut_framework
| 180 | 19.111111 | 51 | py |
nni | nni-master/nni/nas/hub/tensorflow.py | 0 | 0 | 0 | py | |
nni | nni-master/nni/nas/hub/pytorch/__init__.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from .mobilenetv3 import MobileNetV3Space
from .nasbench101 import NasBench101
from .nasbench201 import NasBench201
from .nasnet import NDS, NASNet, ENAS, AmoebaNet, PNAS, DARTS
from .proxylessnas import ProxylessNAS
from .shufflenet import Shuff... | 383 | 33.909091 | 61 | py |
nni | nni-master/nni/nas/hub/pytorch/autoformer.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from __future__ import annotations
__all__ = [
'AutoFormer', 'RelativePositionSelfAttention', 'RelativePosition2D',
]
from typing import Tuple, cast, Any, Dict
import torch
import torch.nn as nn
import torch.nn.functional as F
import nni
... | 26,009 | 36.051282 | 134 | py |
nni | nni-master/nni/nas/hub/pytorch/mobilenetv3.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from functools import partial
from typing import Tuple, Optional, Callable, Union, List, Type, cast
from typing_extensions import Literal
import torch
from torch import nn
import nni
from nni.nas.nn.pytorch import ModelSpace, Repeat, LayerChoic... | 25,303 | 37.281392 | 137 | py |
nni | nni-master/nni/nas/hub/pytorch/nasbench101.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import math
import torch
import torch.nn as nn
from nni.nas.nn.pytorch import ModelSpace
from .modules.nasbench101 import NasBench101Cell
__all__ = ['NasBench101']
def truncated_normal_(tensor: torch.Tensor, mean: float = 0, std: float = 1)... | 4,939 | 34.285714 | 139 | py |
nni | nni-master/nni/nas/hub/pytorch/nasbench201.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from typing import Callable, Dict
import torch
import torch.nn as nn
from nni.nas.nn.pytorch import ModelSpace
from .modules.nasbench201 import NasBench201Cell
__all__ = ['NasBench201']
OPS_WITH_STRIDE = {
'none': lambda C_in, C_out, st... | 7,571 | 33.733945 | 122 | py |
nni | nni-master/nni/nas/hub/pytorch/nasnet.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
# type: ignore
"""File containing NASNet-series search space.
The implementation is based on NDS.
It's called ``nasnet.py`` simply because NASNet is the first to propose such structure.
"""
from functools import partial
from typing import Tupl... | 36,888 | 39.14037 | 140 | py |
nni | nni-master/nni/nas/hub/pytorch/proxylessnas.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import math
from typing import Optional, Callable, List, Tuple, Iterator, Union, cast, overload
import torch
from torch import nn
from nni.mutable import MutableExpression
from nni.nas.nn.pytorch import ModelSpace, LayerChoice, Repeat, MutableCo... | 21,018 | 35.875439 | 132 | py |
nni | nni-master/nni/nas/hub/pytorch/shufflenet.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from typing import Union, cast
import torch
import torch.nn as nn
import nni
from nni.mutable import MutableExpression
from nni.nas.nn.pytorch import LayerChoice, ModelSpace, MutableConv2d, MutableBatchNorm2d
from .utils.pretrained import load_... | 12,509 | 41.40678 | 138 | py |
nni | nni-master/nni/nas/hub/pytorch/modules/__init__.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
"""Famous building blocks of search spaces."""
from .autoactivation import *
from .nasbench101 import *
from .nasbench201 import *
| 206 | 22 | 46 | py |
nni | nni-master/nni/nas/hub/pytorch/modules/autoactivation.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from __future__ import annotations
import inspect
import sys
from typing import Iterable
from packaging.version import Version
import torch
import torch.nn as nn
from nni.mutable import label_scope
from nni.nas.nn.pytorch import LayerChoice, P... | 7,921 | 25.763514 | 124 | py |
nni | nni-master/nni/nas/hub/pytorch/modules/nasbench101.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
__all__ = ['NasBench101Cell']
import logging
from collections import OrderedDict
from typing import Callable, List, Optional, Union, Dict, Tuple, Callable, Iterable, Any, cast
import numpy as np
import torch
import torch.nn as nn
from nni.muta... | 21,729 | 42.89899 | 138 | py |
nni | nni-master/nni/nas/hub/pytorch/modules/nasbench201.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
__all__ = ['NasBench201Cell']
from collections import OrderedDict
from typing import Callable, List, Dict, Union, Optional
import torch
import torch.nn as nn
from nni.mutable import label_scope
from nni.nas.nn.pytorch import LayerChoice, Mutab... | 3,637 | 39.876404 | 133 | py |
nni | nni-master/nni/nas/hub/pytorch/utils/__init__.py | 0 | 0 | 0 | py | |
nni | nni-master/nni/nas/hub/pytorch/utils/nn.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
"""Miscellaneous neural network utilities."""
from torch import nn
def drop_path(x, drop_prob: float = 0., training: bool = False, scale_by_keep: bool = True):
"""Drop paths (Stochastic Depth) per sample (when applied in main path of resid... | 1,551 | 32.73913 | 102 | py |
nni | nni-master/nni/nas/hub/pytorch/utils/pretrained.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
"""
Weights available in this file are processed with scripts in https://github.com/ultmaster/spacehub-conversion,
and uploaded with :func:`nni.common.blob_utils.upload_file`.
"""
import os
from nni.common.blob_utils import NNI_BLOB, nni_cache_... | 2,644 | 43.083333 | 110 | py |
nni | nni-master/nni/nas/nn/__init__.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
"""Neural network blocks or layers.
Named ``nn`` following PyTorch convention.
"""
from nni.common.framework import shortcut_framework
shortcut_framework(__name__)
del shortcut_framework
| 265 | 18 | 51 | py |
nni | nni-master/nni/nas/nn/pytorch/__init__.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from .base import *
from .choice import *
from .repeat import *
from .cell import *
from .layers import *
| 180 | 19.111111 | 38 | py |
nni | nni-master/nni/nas/nn/pytorch/base.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
# Can't have annotations on because PyTorch JIT doesn't support it.
# from __future__ import annotations
__all__ = [
'recursive_freeze', 'MutableModule', 'ModelSpace', 'ParametrizedModule'
]
import copy
import itertools
import inspect
impor... | 29,651 | 43.656627 | 135 | py |
nni | nni-master/nni/nas/nn/pytorch/cell.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import copy
import logging
import warnings
from typing import Callable, Dict, List, Union, Optional, Tuple, Sequence, Union, cast
try:
from typing import Literal
except ImportError:
from typing_extensions import Literal
import torch
impo... | 17,724 | 44.448718 | 136 | py |
nni | nni-master/nni/nas/nn/pytorch/choice.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
# Can't have annotations on because PyTorch JIT doesn't support it.
# from __future__ import annotations
import functools
import warnings
from typing import (Any, Iterator, List, Optional, Dict, Union, Tuple, cast)
from typing_extensions import ... | 14,943 | 37.122449 | 137 | py |
nni | nni-master/nni/nas/nn/pytorch/layers.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
# FIXME: The dynamic generation causes issues upon un-install of NNI or
# when NNI's been installed at a place with no write access.
# We should find a better way to do this.
# If you've seen lint errors like `"Sequential" is not a... | 5,077 | 34.51049 | 174 | py |
nni | nni-master/nni/nas/nn/pytorch/repeat.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import copy
import logging
import warnings
from contextlib import contextmanager
from typing import Callable, List, Union, Tuple, Optional, cast
import torch
import torch.nn as nn
from nni.mutable import Categorical, LabeledMutable, Mutable, Sa... | 10,995 | 38.985455 | 138 | py |
nni | nni-master/nni/nas/nn/tensorflow/api.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from __future__ import annotations
from tensorflow.keras import Layer
class LayerChoice(Layer):
# FIXME: This is only a draft to test multi-framework support, it's not unimplemented at all.
pass
| 280 | 22.416667 | 97 | py |