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/nas/oneshot/__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/oneshot/pytorch/__init__.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. from .differentiable import DartsLightningModule, GumbelDartsLightningModule from .sampling import EnasLightningModule, RandomSamplingLightningModule
224
36.5
76
py
nni
nni-master/nni/nas/oneshot/pytorch/_dataloader.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. from __future__ import annotations from typing import Any, Optional from pytorch_lightning.utilities.combined_loader import ( CombinedLoader, _CombinationMode, _SUPPORTED_MODES, _Sequential, _ModeIterator, _tree_flatten ) _SUPPORTED_MO...
789
28.259259
88
py
nni
nni-master/nni/nas/oneshot/pytorch/_dataloader_legacy.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. # pylint: skip-file # type: ignore from __future__ import annotations from typing import Any from pytorch_lightning.trainer.supporters import CombinedLoader, CombinedLoaderIterator __all__ = ['ConcatLoader'] class ConcatLoader(CombinedLoade...
2,766
32.337349
94
py
nni
nni-master/nni/nas/oneshot/pytorch/base_lightning.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. from __future__ import annotations import warnings from typing import Any, Iterable, List, cast, TYPE_CHECKING import torch.optim as optim import torch.nn as nn from torch.optim import Optimizer import nni.nas.nn.pytorch as nas_nn from nni.nas...
18,404
41.213303
136
py
nni
nni-master/nni/nas/oneshot/pytorch/differentiable.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. """Differentiable one-shot implementation.""" from __future__ import annotations import logging import pytorch_lightning as pl import torch import torch.nn as nn import torch.optim as optim from .base_lightning import BaseOneShotLightningModu...
8,050
38.465686
128
py
nni
nni-master/nni/nas/oneshot/pytorch/profiler.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. """Guide the one-shot strategy to sample architecture within a target latency. This module converts the profiling results returned by profiler to something that one-shot strategies can understand. For example, a loss or some penalty to the rewar...
8,574
35.334746
132
py
nni
nni-master/nni/nas/oneshot/pytorch/sampling.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. """Sampling-based one-shot implementation.""" from __future__ import annotations import warnings import logging from typing import Any, Callable, TYPE_CHECKING import pytorch_lightning as pl import torch from nni.mutable import Sample from nni...
10,845
39.470149
145
py
nni
nni-master/nni/nas/oneshot/pytorch/strategy.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. """Strategy integration of one-shot. This file is put here simply because it relies on "pytorch". For consistency, please consider importing strategies from ``nni.nas.strategy``. For example, ``nni.nas.strategy.DartsStrategy`` (this requires pyt...
44,947
45.578238
150
py
nni
nni-master/nni/nas/oneshot/pytorch/supermodule/__init__.py
0
0
0
py
nni
nni-master/nni/nas/oneshot/pytorch/supermodule/_expression_utils.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. """Utilities to process the value choice compositions, in the way that is most convenient to one-shot algorithms.""" from __future__ import annotations import operator from typing import Any, TypeVar, List, cast, Mapping, Sequence, Optional, It...
9,011
37.348936
134
py
nni
nni-master/nni/nas/oneshot/pytorch/supermodule/_operation_utils.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. """Thie file handles "slice" commonly used in mixed-operation. The ``slice_type`` we support here, is "slice" or "list of slice". The reason is that sometimes (e.g., in multi-head attention), the tensor slice could be from multiple parts. This t...
10,875
35.993197
105
py
nni
nni-master/nni/nas/oneshot/pytorch/supermodule/_singlepathnas.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. # pylint: skip-file # type: ignore """This file is an incomplete implementation of `Single-path NAS <https://arxiv.org/abs/1904.02877>`__. These are merely some components of the algorithm. The complete support is an undergoing work item. Keep ...
11,832
43.992395
131
py
nni
nni-master/nni/nas/oneshot/pytorch/supermodule/base.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. from __future__ import annotations from typing import Any import torch.nn as nn from nni.nas.nn.pytorch import MutableModule __all__ = ['BaseSuperNetModule'] class BaseSuperNetModule(MutableModule): """ Mutated module in super-net. ...
3,551
36
137
py
nni
nni-master/nni/nas/oneshot/pytorch/supermodule/differentiable.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. from __future__ import annotations import functools import logging import warnings from typing import Any, Dict, Sequence, List, Tuple, cast import torch import torch.nn as nn import torch.nn.functional as F from nni.mutable import MutableExp...
21,787
42.059289
135
py
nni
nni-master/nni/nas/oneshot/pytorch/supermodule/operation.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. """ Operations that support weight sharing at a fine-grained level, which is commonly known as super-kernel (as in channel search), or weight entanglement. """ from __future__ import annotations import inspect import warnings from typing import...
33,748
41.081047
132
py
nni
nni-master/nni/nas/oneshot/pytorch/supermodule/proxyless.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. """Implementation of ProxylessNAS: a hyrbid approach between differentiable and sampling. The support remains limited. Known limitations include: - No support for multiple arguments in forward. - No support for mixed-operation (value choice). - ...
18,405
41.804651
122
py
nni
nni-master/nni/nas/oneshot/pytorch/supermodule/sampling.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. # type: ignore from __future__ import annotations import copy import functools import random from typing import Any, List, Dict, Sequence, cast import torch import torch.nn as nn from nni.mutable import MutableExpression, label_scope, Mutable...
16,958
41.081886
125
py
nni
nni-master/nni/nas/profiler/__init__.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. from .profiler import Profiler, ExpressionProfiler
125
24.2
50
py
nni
nni-master/nni/nas/profiler/profiler.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. from __future__ import annotations from nni.mutable import Sample from nni.mutable.symbol import SymbolicExpression from nni.nas.space import BaseModelSpace class Profiler: """Profiler is a class that profiles the performance of a model wi...
1,664
36
103
py
nni
nni-master/nni/nas/profiler/tensorflow.py
0
0
0
py
nni
nni-master/nni/nas/profiler/pytorch/flops.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. from __future__ import annotations __all__ = [ 'FlopsParamsCounterConfig', 'FlopsParamsProfiler', 'FlopsProfiler', 'NumParamsProfiler', 'count_flops_params', 'register_flops_formula' ] import logging from dataclasses import dataclass, f...
17,826
37.754348
139
py
nni
nni-master/nni/nas/profiler/pytorch/nn_meter.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. from __future__ import annotations import functools import logging import tempfile from typing import Any, Iterable import torch from torch import nn from nn_meter import load_latency_predictor, nnMeterPredictor from nni.mutable import Mutable,...
11,534
44.77381
127
py
nni
nni-master/nni/nas/profiler/pytorch/utils/__init__.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. from .misc import * from .shape import * from .shape_formula import *
144
19.714286
38
py
nni
nni-master/nni/nas/profiler/pytorch/utils/_attrs.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. from __future__ import annotations from typing import Any, Type, TypeVar, Tuple from torch import nn from nni.mutable import Mutable, MutableExpression from nni.nas.nn.pytorch import ParametrizedModule T = TypeVar('T') tuple_1_t = Tuple[T] tup...
2,332
27.802469
92
py
nni
nni-master/nni/nas/profiler/pytorch/utils/_expression.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. from __future__ import annotations import logging import traceback from typing import Any from nni.mutable import MutableExpression, Categorical, Numerical _logger = logging.getLogger(__name__) def conclude_assumptions(values: list[int | flo...
6,669
38.467456
124
py
nni
nni-master/nni/nas/profiler/pytorch/utils/misc.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. from __future__ import annotations __all__ = ['concat_name', 'standardize_arguments', 'is_leaf_module', 'profiler_leaf_module', 'argument_in_spec'] from typing import Any, Callable, TypeVar, Type from torch import nn from nni.nas.nn.pytorch im...
3,028
29.908163
112
py
nni
nni-master/nni/nas/profiler/pytorch/utils/shape.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. from __future__ import annotations __all__ = [ 'shape_inference', 'ShapeTensor', 'MutableShape', 'submodule_input_output_shapes', 'extract_shape_info' ] import functools import logging import traceback from typing import Union, Tuple, Calla...
26,281
39.371736
136
py
nni
nni-master/nni/nas/profiler/pytorch/utils/shape_formula.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. from __future__ import annotations __all__ = ['register_shape_inference_formula', 'find_shape_inference_formula'] import logging import warnings from typing import Callable, Type, Tuple, Any, cast import torch from torch import nn import nni....
17,312
42.067164
142
py
nni
nni-master/nni/nas/space/__init__.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. from .frozen import * from .graph import * from .metrics import * from .mutator import * from .metrics import * from .space import *
207
19.8
38
py
nni
nni-master/nni/nas/space/frozen.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. __all__ = ['current_model', 'model_context'] import copy from typing import Optional from nni.mutable import frozen_context, Sample def current_model() -> Optional[Sample]: """Get the current model sample in :func:`model_context`. The...
1,438
33.261905
104
py
nni
nni-master/nni/nas/space/graph.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. # pylint: skip-file # type: ignore """ GraphModelSpace representation for engines based on graph. """ from __future__ import annotations __all__ = [ 'GraphModelSpace', 'Graph', 'Node', 'Edge', 'IllegalGraphError', ] import json from typin...
30,640
37.737042
140
py
nni
nni-master/nni/nas/space/graph_op.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. """ Operations used in graph-based engine. """ from typing import (Any, Dict, List, Optional, cast) from nni.common.framework import get_default_framework __all__ = ['Operation', 'Cell', 'PyTorchOperation', 'TensorFlowOperation'] def _conve...
9,031
34.699605
130
py
nni
nni-master/nni/nas/space/metrics.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. from __future__ import annotations __all__ = ['Metrics'] from typing import Any, Sequence, cast from nni.typehint import TrialMetric class Metrics: """ Data structure that manages the metric data (e.g., loss, accuracy, etc.). NO...
2,654
30.607143
121
py
nni
nni-master/nni/nas/space/mutator.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. from __future__ import annotations from contextlib import contextmanager from typing import Any, Callable, Iterable, List, Optional, TYPE_CHECKING, Iterator from numpy.random import RandomState from nni.mutable import ( LabeledMutable, Mut...
15,388
38.560411
126
py
nni
nni-master/nni/nas/space/space.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. from __future__ import annotations """Space definitions that are friendly to NAS executions. All model spaces should inherit :class:`BaseModelSpace`, which then divides into two categories. 1. :class:`ExecutableModelSpace`, which will be the (...
20,505
43.969298
132
py
nni
nni-master/nni/nas/space/pytorch/__init__.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. """ Space definitions related to PyTorch. Mostly graph-related stuff. """ from .graph import PytorchGraphModelSpace
192
16.545455
41
py
nni
nni-master/nni/nas/space/pytorch/codegen.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. __all__ = ['model_to_pytorch_script'] import logging import re from typing import Dict, List, Tuple, Any, cast from nni.common.device import Device, GPUDevice from nni.nas.space.graph import IllegalGraphError, Edge, Graph, Node, GraphModelSpace...
9,003
37.314894
140
py
nni
nni-master/nni/nas/space/pytorch/graph.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. from __future__ import annotations __all__ = ['PytorchGraphModelSpace'] import logging from typing import Any, TYPE_CHECKING import torch from nni.nas.evaluator import Evaluator from nni.nas.space import GraphModelSpace, Mutator from nni.nas....
5,324
38.444444
134
py
nni
nni-master/nni/nas/space/pytorch/mutator.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. """Convert MutableModules into mutators on graph model space.""" from __future__ import annotations from typing import Any, List, Tuple, Dict, Iterable, cast from nni.mutable import MutableExpression, Categorical, frozen_context, label_scope f...
12,494
43.308511
131
py
nni
nni-master/nni/nas/space/pytorch/op_def.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. from __future__ import annotations from typing import (Any, Dict, List) import torch import torch.nn.functional as nn_functional from nni.nas.space.graph_op import PyTorchOperation mem_format = [ 'torch.contiguous_format', # 0 '...
22,234
39.500911
135
py
nni
nni-master/nni/nas/space/pytorch/converter/__init__.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. from .graph_gen import GraphConverter, GraphConverterWithShape
137
26.6
62
py
nni
nni-master/nni/nas/space/pytorch/converter/graph_gen.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. import re import torch from nni.nas.space.graph import Graph, GraphModelSpace, Node, Cell, Operation from nni.nas.nn.pytorch import InputChoice, MutationAnchor, LayerChoice, MutableModule, Repeat from nni.nas.utils import get_init_parameters_or...
42,487
50.688564
140
py
nni
nni-master/nni/nas/space/pytorch/converter/op_types.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. from enum import Enum # except the special case which can not treat as a basic module from pytorch MODULE_EXCEPT_LIST = ['Sequential'] class OpTypeName(str, Enum): """ op type to its type name str """ Attr = 'Attr' Constant...
540
22.521739
76
py
nni
nni-master/nni/nas/space/pytorch/converter/utils.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. from typing import Optional from typing_extensions import TypeGuard from nni.nas.space.graph import Cell, GraphModelSpace, Graph, Node, Edge def build_full_name(prefix, name, seq=None): if isinstance(name, list): name = '__'.join(...
9,519
35.899225
133
py
nni
nni-master/nni/nas/space/pytorch/converter/visualize.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. import graphviz def convert_to_visualize(graph_ir, vgraph): for name, graph in graph_ir.items(): if name == '_evaluator': continue with vgraph.subgraph(name='cluster'+name) as subgraph: subgraph.attr(...
1,896
41.155556
124
py
nni
nni-master/nni/nas/space/tensorflow/__init__.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. """ Space definitions related to Tensorflow. Mostly graph-related stuff. """ from .graph import TensorflowGraphModelSpace
198
17.090909
44
py
nni
nni-master/nni/nas/space/tensorflow/graph.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. from __future__ import annotations __all__ = ['TensorflowGraphModelSpace'] import logging from typing import ClassVar from nni.nas.space import GraphModelSpace _logger = logging.getLogger(__name__) class TensorflowGraphModelSpace(GraphModel...
648
26.041667
124
py
nni
nni-master/nni/nas/space/tensorflow/op_def.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. from nni.nas.space.graph_op import TensorFlowOperation class Conv2D(TensorFlowOperation): def __init__(self, type_name, parameters, _internal, attributes=None): if 'padding' not in parameters: parameters['padding'] = 'sa...
383
31
74
py
nni
nni-master/nni/nas/strategy/__init__.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. from .base import Strategy from .bruteforce import Random, GridSearch from .evolution import RegularizedEvolution from .hpo import TPEStrategy, TPE from .rl import PolicyBasedRL from .oneshot import DARTS, Proxyless, GumbelDARTS, ENAS, RandomOneS...
324
31.5
71
py
nni
nni-master/nni/nas/strategy/_rl_impl.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. # This file might cause import error for those who didn't install RL-related dependencies """The RL implementation for whoever wants to use RL to search for configurations in a space. The implementation should be agnostic to space types (HPO / ...
17,590
37.158351
131
py
nni
nni-master/nni/nas/strategy/base.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. from __future__ import annotations import logging import time from enum import Enum from typing import Iterator, cast from nni.nas.execution import ExecutionEngine from nni.nas.space import ExecutableModelSpace, ModelStatus from nni.typehint im...
10,607
38.143911
135
py
nni
nni-master/nni/nas/strategy/bruteforce.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. from __future__ import annotations __all__ = ['GridSearch', 'Random'] import logging import warnings from typing import Iterator, Any from numpy.random import RandomState from nni.mutable import Sample from nni.nas.space import ExecutableMode...
9,220
38.072034
138
py
nni
nni-master/nni/nas/strategy/evolution.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. from __future__ import annotations import collections import dataclasses import logging import warnings import copy from typing import Deque from numpy.random import RandomState from nni.mutable import Sample, MutableAnnotation from nni.nas.ex...
10,996
43.164659
127
py
nni
nni-master/nni/nas/strategy/hpo.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. """Wrappers of HPO tuners as NAS strategy.""" from __future__ import annotations __all__ = ['HPOTunerStrategy', 'TPE'] import logging import time import threading from typing import cast import nni from nni.nas.execution import ExecutionEngin...
5,085
35.855072
136
py
nni
nni-master/nni/nas/strategy/middleware.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. from __future__ import annotations __all__ = ['Chain', 'StrategyMiddleware', 'Filter', 'Deduplication', 'FailureHandler', 'MultipleEvaluation', 'MedianStop'] import copy import logging import warnings from collections import defaultdict, deque ...
40,088
45.615116
135
py
nni
nni-master/nni/nas/strategy/oneshot.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. from .base import Strategy try: from nni.nas.oneshot.pytorch.strategy import ( # pylint: disable=unused-import DARTS, GumbelDARTS, Proxyless, ENAS, RandomOneShot ) except ImportError as import_err: _import_err = import_err ...
745
31.434783
83
py
nni
nni-master/nni/nas/strategy/rl.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. from __future__ import annotations import logging import warnings from typing import Optional, TYPE_CHECKING from nni.mutable import SampleValidationError from nni.nas.execution import ExecutionEngine from nni.nas.space import ExecutableModelSp...
10,716
44.799145
140
py
nni
nni-master/nni/nas/strategy/utils.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. from __future__ import annotations __all__ = ['DeduplicationHelper', 'DuplicationError', 'RetrySamplingHelper'] import logging from typing import Any, Type, TypeVar, Callable from nni.mutable import SampleValidationError _logger = logging.get...
3,636
30.626087
128
py
nni
nni-master/nni/nas/utils/__init__.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. from .misc import * from .serializer import * from ._legacy import *
144
17.125
38
py
nni
nni-master/nni/nas/utils/_legacy.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. import inspect import os import warnings from typing import Any, TypeVar, Type from nni.common.serializer import is_traceable, is_wrapped_with_trace, trace __all__ = ['get_init_parameters_or_fail', 'serialize', 'serialize_cls', 'basic_unit', ...
4,910
35.649254
123
py
nni
nni-master/nni/nas/utils/misc.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. import inspect import itertools import warnings from collections import defaultdict from contextlib import contextmanager from typing import Any, List, cast from pathlib import Path __all__ = [ 'original_state_dict_hooks', 'get_module_name',...
6,861
38.436782
133
py
nni
nni-master/nni/nas/utils/serializer.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. """This module does what `CheckpointIO <https://pytorch-lightning.readthedocs.io/en/stable/api/pytorch_lightning.plugins.io.CheckpointIO.html>`__ does in PyTorch-Lightning, but with a simpler implementation and a wider range of backend supports. ...
5,908
33.758824
129
py
nni
nni-master/nni/runtime/__init__.py
0
0
0
py
nni
nni-master/nni/runtime/common.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. _multi_phase = False def enable_multi_phase(): global _multi_phase _multi_phase = True def multi_phase_enabled(): return _multi_phase
222
17.583333
38
py
nni
nni-master/nni/runtime/config.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. import os from pathlib import Path import shutil import sys import nni def get_config_directory() -> Path: """ Get NNI config directory. Create it if not exist. """ if os.getenv('NNI_CONFIG_DIR') is not None: config_...
1,251
28.116279
82
py
nni
nni-master/nni/runtime/env_vars.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. import os from collections import namedtuple _trial_env_var_names = [ 'NNI_PLATFORM', 'NNI_EXP_ID', 'NNI_TRIAL_JOB_ID', 'NNI_SYS_DIR', 'NNI_OUTPUT_DIR', 'NNI_TRIAL_COMMAND_CHANNEL', 'NNI_TRIAL_SEQ_ID', 'MULTI_PHA...
884
22.918919
98
py
nni
nni-master/nni/runtime/log.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. """ NNI's logging system. For end users you only need to care about :func:`silence_stdout` and :func:`enable_global_logging`. Following stuffs are for NNI contributors. The logging system is initialized on importing ``nni``. By design it should...
10,856
30.932353
116
py
nni
nni-master/nni/runtime/msg_dispatcher.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. import logging from collections import defaultdict from nni import NoMoreTrialError from nni.assessor import AssessResult from .common import multi_phase_enabled from .env_vars import dispatcher_env_vars from .msg_dispatcher_base import MsgDisp...
10,060
38.14786
124
py
nni
nni-master/nni/runtime/msg_dispatcher_base.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. import threading import logging from queue import Queue, Empty from .env_vars import dispatcher_env_vars from ..common import load from ..recoverable import Recoverable from .tuner_command_channel import CommandType, TunerCommandChannel _logge...
9,997
38.517787
131
py
nni
nni-master/nni/runtime/command_channel/__init__.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license.
73
23.666667
38
py
nni
nni-master/nni/runtime/command_channel/base.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. from __future__ import annotations from typing import Any Command = Any # TODO class CommandChannel: def send(self, command: Command) -> None: raise NotImplementedError() def receive(self) -> Command | None: raise Not...
339
20.25
45
py
nni
nni-master/nni/runtime/command_channel/http.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. from __future__ import annotations import logging import requests from .base import Command, CommandChannel _logger = logging.getLogger(__name__) class HttpChannel(CommandChannel): """ A simple command channel based on HTTP. Che...
1,030
26.131579
98
py
nni
nni-master/nni/runtime/command_channel/websocket/__init__.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. from .channel import WsChannelClient
111
21.4
38
py
nni
nni-master/nni/runtime/command_channel/websocket/channel.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. from __future__ import annotations import logging import time from ..base import Command, CommandChannel from .connection import WsConnection _logger = logging.getLogger(__name__) class WsChannelClient(CommandChannel): def __init__(self, ...
3,602
31.754545
78
py
nni
nni-master/nni/runtime/command_channel/websocket/connection.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. """ Synchronized and object-oriented WebSocket class. WebSocket guarantees that messages will not be divided at API level. """ from __future__ import annotations __all__ = ['WsConnection'] import asyncio import logging from threading import L...
4,714
31.743056
100
py
nni
nni-master/nni/runtime/default_config/builtin_algorithms.yml
assessors: - builtinName: Medianstop classArgsValidator: nni.algorithms.hpo.medianstop_assessor.MedianstopClassArgsValidator className: nni.algorithms.hpo.medianstop_assessor.MedianstopAssessor source: nni - builtinName: Curvefitting classArgsValidator: nni.algorithms.hpo.curvefitting_assessor.CurvefittingClass...
3,467
37.533333
96
yml
nni
nni-master/nni/runtime/default_config/registered_algorithms.yml
{}
3
1
2
yml
nni
nni-master/nni/runtime/trial_command_channel/__init__.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. __all__ = [ 'ParameterRecord', 'TrialCommandChannel', 'get_default_trial_command_channel', 'set_default_trial_command_channel', ] from typing import Optional from .base import ParameterRecord, TrialCommandChannel _channel: Optional...
2,694
32.271605
112
py
nni
nni-master/nni/runtime/trial_command_channel/base.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. from __future__ import annotations from typing_extensions import Literal from nni.typehint import ParameterRecord, TrialMetric class TrialCommandChannel: """ Command channel used by trials to communicate with training service. One...
2,017
32.633333
97
py
nni
nni-master/nni/runtime/trial_command_channel/local_legacy.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. from __future__ import annotations import os import sys import time import subprocess from typing import cast from typing_extensions import Literal from nni.common import dump, load from nni.typehint import TrialMetric from .base import TrialCo...
3,741
36.79798
126
py
nni
nni-master/nni/runtime/trial_command_channel/standalone.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. from __future__ import annotations import logging import warnings import colorama from typing_extensions import Literal from nni.typehint import TrialMetric from .base import TrialCommandChannel, ParameterRecord _logger = logging.getLogger('n...
1,587
32.083333
126
py
nni
nni-master/nni/runtime/trial_command_channel/v3.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. from __future__ import annotations import logging from typing_extensions import Literal import nni from nni.runtime.command_channel.http import HttpChannel from nni.typehint import ParameterRecord, TrialMetric from .base import TrialCommandCha...
1,619
30.153846
86
py
nni
nni-master/nni/runtime/tuner_command_channel/__init__.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. """ Low level APIs for algorithms to communicate with NNI manager. """ from .command_type import CommandType, TunerIncomingCommand from .channel import TunerCommandChannel
247
23.8
62
py
nni
nni-master/nni/runtime/tuner_command_channel/channel.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. """ Low level APIs for algorithms to communicate with NNI manager. """ from __future__ import annotations __all__ = ['TunerCommandChannel'] import logging import os from collections import defaultdict from threading import Event from typing im...
12,826
41.614618
130
py
nni
nni-master/nni/runtime/tuner_command_channel/command_type.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. from enum import Enum from dataclasses import dataclass from typing import List, Optional, ClassVar from nni.typehint import TrialMetric, SearchSpace from nni.utils import MetricType class CommandType(Enum): # in Initialize = 'IN' R...
2,288
30.791667
98
py
nni
nni-master/nni/runtime/tuner_command_channel/legacy.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. __all__ = [ 'CommandType', 'LegacyCommandChannel', 'send', 'receive', '_set_in_file', '_set_out_file', '_get_out_file', ] import logging import os import threading from .command_type import CommandType _logger = log...
2,002
21.761364
70
py
nni
nni-master/nni/tools/__init__.py
0
0
0
py
nni
nni-master/nni/tools/gpu_tool/__init__.py
0
0
0
py
nni
nni-master/nni/tools/gpu_tool/gpu_metrics_collector.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. import json import os import subprocess import sys import time import traceback from xml.dom import minidom def main(argv): metrics_output_dir = os.environ['METRIC_OUTPUT_DIR'] cmd = 'nvidia-smi -q -x'.split() retry = 0 while ...
3,155
34.863636
110
py
nni
nni-master/nni/tools/jupyter_extension/__init__.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. from . import proxy load_jupyter_server_extension = proxy.setup _load_jupyter_server_extension = proxy.setup
184
22.125
44
py
nni
nni-master/nni/tools/jupyter_extension/management.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. import json from pathlib import Path import shutil import os from jupyter_core.paths import jupyter_config_dir, jupyter_data_dir def _get_jupyter_lab_version(): try: import jupyterlab return jupyterlab.__version__ except...
2,270
30.541667
93
py
nni
nni-master/nni/tools/jupyter_extension/proxy.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. import json from pathlib import Path import requests from tornado.web import RequestHandler def setup(server): base_url = server.web_app.settings['base_url'] url_pattern = base_url.rstrip('/') + '/nni/(.*)' server.web_app.add_handle...
1,525
31.468085
101
py
nni
nni-master/nni/tools/nni_manager_scripts/__init__.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. """ Collection of scripts used by NNI manager to do jobs that are hard for node.js. """
162
22.285714
79
py
nni
nni-master/nni/tools/nni_manager_scripts/check_trial_keeper_alive.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. import json from pathlib import Path import sys from typing import Any, NoReturn import psutil def main() -> None: pid_file = Path(sys.argv[1], 'trial_keeper.pid') try: pid = int(pid_file.read_text()) except Exception: ...
879
24.142857
89
py
nni
nni-master/nni/tools/nni_manager_scripts/collect_gpu_info.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. """ Collect GPU utilization metrics, and debug info if ``--detail`` is specified. Results are printed to stdout in JSON format. See `ts/nni_manager/common/gpu_scheduler/collect_info` for details. """ # pylint: disable=wildcard-import # pylint: ...
4,923
27.137143
103
py
nni
nni-master/nni/tools/nni_manager_scripts/collect_version_info.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. import json import sys import nni def main(): data = {} data['nniVersion'] = nni.__version__ data['nniPath'] = nni.__path__[0] # type: ignore data['pythonVersion'] = '{}.{}.{}-{}-{}'.format(*sys.version_info) data['pythonPa...
409
20.578947
70
py
nni
nni-master/nni/tools/nni_manager_scripts/create_trial_keeper_dir.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. """ Create the working directory for trial keeper and print its absolute path. By default the directory is "~/nni-experiments/EXP_ID/environments/ENV_ID/trial_keeper". If the directory already exists (e.g. resume), try "trial_keeper_1", then "tr...
983
26.333333
96
py
nni
nni-master/nni/tools/nni_manager_scripts/launch_trial_keeper.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. """ Launch trial keeper daemon and print some info in JSON format. Before running this script, you should: 1. Create the working directory with "create_trial_keeper_dir.py". 2. Create "launcher_config.json" in that directory. Example of "l...
3,202
30.097087
117
py
nni
nni-master/nni/tools/nnictl/__init__.py
0
0
0
py