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/test/training_service/config/nnictl_experiment/sklearn-classification-v2.yml | experimentName: default_test
searchSpaceFile: ../../../../examples/trials/sklearn/classification/search_space.json
trialCommand: python3 main.py
trialCodeDirectory: ../../../../examples/trials/sklearn/classification
trialGpuNumber: 0
trialConcurrency: 1
maxExperimentDuration: 15m
maxTrialNumber: 1
tuner:
name: TPE
tr... | 422 | 25.4375 | 85 | yml |
nni | nni-master/test/training_service/config/nnictl_experiment/sklearn-classification.yml | authorName: nni
experimentName: default_test
maxExecDuration: 5m
maxTrialNum: 4
trialConcurrency: 2
searchSpacePath: ../../../../examples/trials/sklearn/classification/search_space.json
tuner:
builtinTunerName: TPE
assessor:
builtinAssessorName: Medianstop
classArgs:
optimize_mode: maximize
trial:
codeDir:... | 502 | 19.958333 | 85 | yml |
nni | nni-master/test/training_service/config/sharedstorage_test/config_sharedstorage_remote_azureblob.yml | authorName: default
experimentName: example_mnist
trialConcurrency: 1
maxExecDuration: 1h
maxTrialNum: 1
trainingServicePlatform: remote
searchSpacePath: config_sharedstorage_search_space.json
#choice: true, false
useAnnotation: false
nniManagerIp: 127.0.0.1
tuner:
#choice: TPE, Random, Anneal, Evolution, BatchTuner,... | 1,356 | 32.097561 | 103 | yml |
nni | nni-master/test/training_service/config/sharedstorage_test/config_sharedstorage_remote_nfs.yml | authorName: default
experimentName: example_mnist
trialConcurrency: 1
maxExecDuration: 1h
maxTrialNum: 1
trainingServicePlatform: remote
searchSpacePath: config_sharedstorage_search_space.json
#choice: true, false
useAnnotation: false
nniManagerIp: 127.0.0.1
tuner:
#choice: TPE, Random, Anneal, Evolution, BatchTuner,... | 1,259 | 30.5 | 103 | yml |
nni | nni-master/test/training_service/config/sharedstorage_test/config_sharedstorage_trial.py | """
A deep MNIST classifier using convolutional layers.
This file is a modification of the official pytorch mnist example:
https://github.com/pytorch/examples/blob/master/mnist/main.py
"""
import os
import logging
import nni
logger = logging.getLogger('mnist_AutoML')
if __name__ == '__main__':
try:
logger.... | 717 | 27.72 | 85 | py |
nni | nni-master/test/training_service/config/tuners/anneal.yml | authorName: nni
experimentName: default_test
maxExecDuration: 5m
maxTrialNum: 2
trialConcurrency: 1
tuner:
builtinTunerName: Anneal
classArgs:
optimize_mode: maximize
assessor:
builtinAssessorName: Medianstop
classArgs:
optimize_mode: maximize
trial:
codeDir: ../../../../examples/trials/mnist-annotat... | 470 | 17.84 | 55 | yml |
nni | nni-master/test/training_service/config/tuners/batch.yml | authorName: nni
experimentName: default_test
maxExecDuration: 5m
maxTrialNum: 2
trialConcurrency: 1
searchSpacePath: search_space_batchtuner.json
tuner:
builtinTunerName: BatchTuner
assessor:
builtinAssessorName: Medianstop
classArgs:
optimize_mode: maximize
trial:
codeDir: ../../../../examples/trials/mnis... | 488 | 18.56 | 61 | yml |
nni | nni-master/test/training_service/config/tuners/bohb.yml | authorName: nni
experimentName: default_test
maxExecDuration: 5m
maxTrialNum: 2
trialConcurrency: 1
searchSpacePath: search_space_advisor.json
advisor:
builtinAdvisorName: BOHB
classArgs:
max_budget: 27
min_budget: 1
eta: 3
optimize_mode: maximize
trial:
codeDir: ../../../../examples/trials/mnist... | 461 | 16.769231 | 52 | yml |
nni | nni-master/test/training_service/config/tuners/evolution.yml | authorName: nni
experimentName: default_test
maxExecDuration: 5m
maxTrialNum: 2
trialConcurrency: 1
tuner:
builtinTunerName: Evolution
classArgs:
optimize_mode: maximize
assessor:
builtinAssessorName: Medianstop
classArgs:
optimize_mode: maximize
trial:
codeDir: ../../../../examples/trials/mnist-anno... | 473 | 17.96 | 55 | yml |
nni | nni-master/test/training_service/config/tuners/gp.yml | authorName: nni
experimentName: default_test
maxExecDuration: 5m
maxTrialNum: 2
trialConcurrency: 1
searchSpacePath: search_space.json
tuner:
builtinTunerName: GPTuner
classArgs:
optimize_mode: maximize
utility: 'ei'
kappa: 5.0
xi: 0.0
nu: 2.5
alpha: 1.0e-6
cold_start_num: 10
select... | 672 | 18.794118 | 49 | yml |
nni | nni-master/test/training_service/config/tuners/gridsearch.yml | authorName: nni
experimentName: default_test
maxExecDuration: 5m
maxTrialNum: 2
trialConcurrency: 1
searchSpacePath: search_space.json
tuner:
builtinTunerName: GridSearch
assessor:
builtinAssessorName: Medianstop
classArgs:
optimize_mode: maximize
trial:
codeDir: ../../../../examples/trials/mnist-tfv1
co... | 463 | 18.333333 | 49 | yml |
nni | nni-master/test/training_service/config/tuners/hyperband.yml | authorName: nni
experimentName: default_test
maxExecDuration: 5m
maxTrialNum: 2
trialConcurrency: 1
searchSpacePath: search_space_advisor.json
advisor:
builtinAdvisorName: Hyperband
classArgs:
optimize_mode: maximize
R: 60
eta: 3
exec_mode: parallelism
trial:
codeDir: ../../../../examples/trials/... | 466 | 16.961538 | 52 | yml |
nni | nni-master/test/training_service/config/tuners/metis.yml | authorName: nni
experimentName: default_test
maxExecDuration: 5m
maxTrialNum: 2
trialConcurrency: 1
searchSpacePath: search_space.json
tuner:
builtinTunerName: MetisTuner
classArgs:
optimize_mode: maximize
assessor:
builtinAssessorName: Medianstop
classArgs:
optimize_mode: maximize
trial:
codeDir: ..... | 504 | 18.423077 | 49 | yml |
nni | nni-master/test/training_service/config/tuners/random.yml | authorName: nni
experimentName: default_test
maxExecDuration: 5m
maxTrialNum: 2
trialConcurrency: 1
tuner:
builtinTunerName: Random
assessor:
builtinAssessorName: Medianstop
classArgs:
optimize_mode: maximize
trial:
codeDir: ../../../../examples/trials/mnist-annotation
command: python3 mnist.py --batch_n... | 429 | 17.695652 | 55 | yml |
nni | nni-master/test/training_service/config/tuners/smac.yml | authorName: nni
experimentName: default_test
maxExecDuration: 5m
maxTrialNum: 2
trialConcurrency: 1
tuner:
builtinTunerName: SMAC
classArgs:
optimize_mode: maximize
assessor:
builtinAssessorName: Medianstop
classArgs:
optimize_mode: maximize
trial:
codeDir: ../../../../examples/trials/mnist-annotatio... | 468 | 17.76 | 55 | yml |
nni | nni-master/test/training_service/config/tuners/tpe.yml | authorName: nni
experimentName: default_test
maxExecDuration: 5m
maxTrialNum: 2
trialConcurrency: 1
tuner:
builtinTunerName: TPE
classArgs:
optimize_mode: maximize
assessor:
builtinAssessorName: Medianstop
classArgs:
optimize_mode: maximize
trial:
codeDir: ../../../../examples/trials/mnist-annotation... | 467 | 17.72 | 55 | yml |
nni | nni-master/test/training_service/nnitest/__init__.py | 0 | 0 | 0 | py | |
nni | nni-master/test/training_service/nnitest/foreground.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import subprocess
import argparse
import time
import shlex
import signal
def test_foreground(args):
launch_command = 'nnictl create --config {} --foreground'.format(args.config)
print('nnictl foreground launch command: ', launch_command,... | 702 | 26.038462 | 81 | py |
nni | nni-master/test/training_service/nnitest/generate_ts_config.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import sys
import os
import glob
import argparse
from utils import get_yml_content, dump_yml_content
TRAINING_SERVICE_FILE = os.path.join('training_service', 'config', 'training_service.yml')
TRAINING_SERVICE_FILE_V2 = os.path.join('training_ser... | 12,032 | 57.985294 | 151 | py |
nni | nni-master/test/training_service/nnitest/naive_test.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import sys
import os.path as osp
import argparse
import json
import subprocess
import sys
import time
import traceback
from utils import is_experiment_done, get_experiment_id, get_nni_log_path, read_last_line, remove_files, setup_experiment, det... | 5,272 | 42.221311 | 159 | py |
nni | nni-master/test/training_service/nnitest/remote_docker.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import os
import argparse
from subprocess import check_output, check_call
import socket
import random
import re
def detect_port(port):
'''Detect if the port is used, return True if the port is used'''
socket_test = socket.socket(socket.A... | 3,199 | 36.647059 | 158 | py |
nni | nni-master/test/training_service/nnitest/run_tests.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import argparse
import datetime
import json
import os
import subprocess
import sys
import time
import yaml
import validators
from utils import (CLEAR, EXPERIMENT_URL, GREEN, RED, REST_ENDPOINT,
STATUS_URL, TRIAL_JOBS_URL, dee... | 14,387 | 41.568047 | 130 | py |
nni | nni-master/test/training_service/nnitest/test_quantize_model_speedup.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import os
import torch
import torch.nn.functional as F
from torchvision.models.vgg import vgg16
from torchvision import datasets, transforms
import unittest
from unittest import TestCase, main
from nni.compression.quantization import QATQuantize... | 7,998 | 35.525114 | 139 | py |
nni | nni-master/test/training_service/nnitest/utils.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import contextlib
import collections
import os
import socket
import sys
import subprocess
import requests
import time
import yaml
import shlex
import warnings
EXPERIMENT_DONE_SIGNAL = 'Experiment done'
GREEN = '\33[32m'
RED = '\33[31m'
CLEAR = ... | 6,507 | 33.433862 | 118 | py |
nni | nni-master/test/training_service/nnitest/validators.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import os.path as osp
from os import remove
import subprocess
import json
import requests
from nni.experiment import Experiment
from nni.tools.nnictl.updater import load_imported_data
from utils import METRICS_URL, GET_IMPORTED_DATA_URL
class I... | 5,518 | 47.412281 | 130 | py |
nni | nni-master/test/ut/__init__.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
"""
Unit test of NNI Python modules.
Test cases of each module should be placed at same path of their source files.
For example if `nni/tool/annotation` has one test case, it should be placed at `test/ut/tool/test_annotation.py`;
if it has multi... | 1,008 | 41.041667 | 113 | py |
nni | nni-master/test/ut/conftest.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
# NOTE: Don't remove this file. This file ensures that `../ut/__init__.py` is loaded first.
| 166 | 32.4 | 91 | py |
nni | nni-master/test/ut/experiment/test_config_base.py | from copy import deepcopy
from dataclasses import dataclass
from typing import Dict, List, Optional, Union
from nni.experiment.config.base import ConfigBase
from nni.experiment.config.utils import diff
# config classes
@dataclass(init=False)
class NestedChild(ConfigBase):
msg: str
int_field: int = 1
def... | 3,919 | 23.347826 | 62 | py |
nni | nni-master/test/ut/experiment/test_exp_config.py | import copy
import os.path
from pathlib import Path
from nni.experiment.config import ExperimentConfig
def expand_path(path):
return os.path.realpath(os.path.join(os.path.dirname(__file__), path))
## minimal config ##
minimal_json = {
'searchSpace': {'a': 1},
'trialCommand': 'python main.py',
'trial... | 3,111 | 25.827586 | 74 | py |
nni | nni-master/test/ut/experiment/test_experiment.py | import time
import sys
from pathlib import Path
from nni.experiment import Experiment
search_space = {
'C': {'_type': 'uniform', '_value': [0.1, 1]},
'kernel': {'_type': 'choice', '_value': ['linear', 'rbf', 'poly', 'sigmoid']},
'degree': {'_type': 'choice', '_value': [1, 2, 3, 4]},
'gamma': {'_type'... | 3,271 | 31.39604 | 100 | py |
nni | nni-master/test/ut/experiment/test_search_space.py | import json
from pathlib import Path
import yaml
from nni.experiment.config import ExperimentConfig, AlgorithmConfig, LocalConfig
## template ##
config = ExperimentConfig(
search_space_file = '',
trial_command = 'echo hello',
trial_concurrency = 1,
tuner = AlgorithmConfig(name='randomm'),
traini... | 1,433 | 26.056604 | 84 | py |
nni | nni-master/test/ut/experiment/test_ts_remote.py | import os.path
from pathlib import Path
from nni.experiment.config import ExperimentConfig, AlgorithmConfig, RemoteConfig, RemoteMachineConfig
## minimal config ##
minimal_json = {
'searchSpace': {'a': 1},
'trialCommand': 'python main.py',
'trialConcurrency': 2,
'tuner': {
'name': 'random',
... | 4,398 | 25.184524 | 102 | py |
nni | nni-master/test/ut/experiment/assets/config.yaml | experimentName: test case
searchSpaceFile: search_space.json
trialCommand: python main.py
trialCodeDirectory: ../assets
trialConcurrency: 2
trialGpuNumber: 1
maxExperimentDuration: 1.5h
maxTrialNumber: 10
maxTrialDuration: 60
nniManagerIp: 1.2.3.4
debug: true
logLevel: warning
tunerGpuIndices: 0
assessor:
name: ass... | 754 | 21.878788 | 71 | yaml |
nni | nni-master/test/ut/experiment/assets/ss.yaml | pool_type:
_type: choice
_value:
- max
- min
- avg
学习率: # test unicode
_type: loguniform
_value: [ 0.0000001, 0.1 ]
| 131 | 12.2 | 28 | yaml |
nni | nni-master/test/ut/experiment/assets/ss_yaml12.yaml | pool_type:
_type: choice
_value:
- max
- min
- avg
学习率: # test unicode
_type: loguniform
_value: [ 1e-7, 0.1 ] # test scientific notation
| 154 | 14.5 | 51 | yaml |
nni | nni-master/test/ut/experiment/assets/trial_sklearn.py | import nni
from sklearn import datasets
from sklearn.svm import SVC
from sklearn.metrics import accuracy_score
from sklearn.model_selection import train_test_split
iris = datasets.load_iris()
X_train, X_test, y_train, y_test = train_test_split(iris.data, iris.target, test_size=0.33)
params = nni.get_next_parameter(... | 453 | 25.705882 | 91 | py |
nni | nni-master/test/ut/nas/__init__.py | 0 | 0 | 0 | py | |
nni | nni-master/test/ut/nas/test_engine.py | import time
import pytest
import nni
from nni.nas.experiment import NasExperiment
from nni.nas.execution import ExecutionEngine, TrainingServiceExecutionEngine, SequentialExecutionEngine
from nni.nas.execution.event import ModelEventType
from nni.nas.evaluator import FunctionalEvaluator
from nni.nas.space import Base... | 3,542 | 32.424528 | 104 | py |
nni | nni-master/test/ut/nas/test_evaluator.py | import re
import sys
import pytest
import nni
import nni.trial
import torch
import pytorch_lightning
from nni.mutable import Categorical, Numerical, SampleValidationError
from nni.mutable.mutable import _mutable_equal
from nni.nas.evaluator import FunctionalEvaluator
from nni.nas.evaluator.pytorch import Classificati... | 8,343 | 33.479339 | 123 | py |
nni | nni-master/test/ut/nas/test_optional_dependency.py | """To test the cases of importing NAS without certain DL libraries installed."""
import argparse
import subprocess
import sys
import pytest
masked_packages = ['torch', 'torch_none', 'tensorflow', 'tianshou']
def import_related(mask_out):
import nni
nni.set_default_framework(mask_out)
import nni.nas
... | 1,614 | 27.839286 | 107 | py |
nni | nni-master/test/ut/nas/test_utils.py | import tempfile
import pytest
from pathlib import Path
import torch
from nni.nas.utils import *
@pytest.fixture
def tempdir():
with tempfile.TemporaryDirectory() as d:
yield Path(d)
def test_default_serializer():
assert isinstance(get_default_serializer(), TorchSerializer)
set_default_serializer... | 1,795 | 26.630769 | 65 | py |
nni | nni-master/test/ut/nas/experiment/__init__.py | 0 | 0 | 0 | py | |
nni | nni-master/test/ut/nas/experiment/test_config.py | import pytest
from nni.experiment.config import *
from nni.nas.experiment.config import *
def test_execution_engine_config():
assert isinstance(ExecutionEngineConfig(name='ts'), TrainingServiceEngineConfig)
assert isinstance(ExecutionEngineConfig(name='sequential'), SequentialEngineConfig)
assert Training... | 1,625 | 44.166667 | 113 | py |
nni | nni-master/test/ut/nas/experiment/test_experiment.py | import torch
from torch import nn
from torch.optim import SGD
from torch.utils.data import DataLoader, Dataset
import nni
from nni.nas.evaluator import FunctionalEvaluator
from nni.nas.evaluator.pytorch import Classification
from nni.nas.experiment import *
from nni.nas.experiment.config import *
from nni.nas.strategy... | 3,284 | 33.946809 | 80 | py |
nni | nni-master/test/ut/nas/nn/__init__.py | 0 | 0 | 0 | py | |
nni | nni-master/test/ut/nas/nn/models.py | from functools import partial
from typing import List, Tuple
import torch
import torch.nn as nn
import torch.nn.functional as F
import nni
from nni.nas.nn.pytorch import (
ModelSpace, Cell, ParametrizedModule, LayerChoice, InputChoice, MutableLinear,
MutableMultiheadAttention, MutableConv2d, MutableBatchNorm2... | 8,545 | 31.12782 | 105 | py |
nni | nni-master/test/ut/nas/nn/test_base.py | import copy
import pytest
import torch
import nni
from torch import nn
from nni.common.serializer import is_traceable
from nni.mutable import Categorical, ExpressionConstraint, ensure_frozen, frozen_context, label_scope, auto_label, SampleMissingError
from nni.mutable.mutable import _mutable_equal
from nni.nas.nn.pyt... | 17,401 | 29.211806 | 133 | py |
nni | nni-master/test/ut/nas/nn/test_cell.py | from typing import Type
import pytest
import torch
from nni.nas.space import ExecutableModelSpace, GraphModelSpace
from .models import (
CellSimple, CellDefaultArgs, CellCustomProcessor, CellLooseEnd, CellOpFactory
)
from .test_choice import space_format
@pytest.fixture
def skip_if_graph(space_format):
if... | 2,338 | 35.546875 | 114 | py |
nni | nni-master/test/ut/nas/nn/test_choice.py | import copy
import random
from types import ModuleType
from typing import Type
import pytest
import nni
import nni.nas.nn.pytorch.layers
import nni.nas.evaluator.pytorch.lightning as pl
import torch
import torch.nn.functional as F
from nni.mutable import Categorical, ensure_frozen, label_scope, SampleValidationError... | 24,930 | 34.820402 | 113 | py |
nni | nni-master/test/ut/nas/nn/test_hub_modules.py | from types import ModuleType
from typing import Type
import pytest
import torch
from torch import nn
from nni.mutable import ConstraintViolation
from nni.nas.hub.pytorch.modules import AutoActivation, NasBench101Cell, NasBench201Cell
from nni.nas.nn.pytorch import ModelSpace
from nni.nas.space import ExecutableModelS... | 3,117 | 35.255814 | 148 | py |
nni | nni-master/test/ut/nas/nn/test_repeat.py | from typing import Type
from types import ModuleType
import pytest
import torch
import torch.nn
from nni.mutable import Categorical
from nni.nas.space import ExecutableModelSpace, GraphModelSpace
from nni.nas.nn.pytorch import Repeat, ModelSpace, LayerChoice
from .test_choice import space_format, nn
class AddOne(to... | 5,959 | 34.47619 | 108 | py |
nni | nni-master/test/ut/nas/profiler/__init__.py | 0 | 0 | 0 | py | |
nni | nni-master/test/ut/nas/profiler/conftest.py | import pytest
from packaging.version import Version
from nni.mutable import frozen_context
@pytest.fixture(autouse=True)
def context():
with frozen_context():
yield
@pytest.fixture(autouse=True)
def skip_for_legacy_pytorch():
import torch
if Version(torch.__version__) < Version('1.11.0'):
... | 381 | 21.470588 | 66 | py |
nni | nni-master/test/ut/nas/profiler/test_flops.py | import pytest
import torch
from torch import nn
import nni
import nni.nas.nn.pytorch as nas_nn
from nni.mutable import Categorical
from nni.nas.profiler.pytorch.flops import FlopsParamsProfiler, FlopsProfiler, NumParamsProfiler, FlopsResult, register_flops_formula
from ut.nas.nn.models import MODELS
def test_conv(... | 6,024 | 35.077844 | 133 | py |
nni | nni-master/test/ut/nas/profiler/test_shape.py | import torch
import torch.nn.functional as F
from torch import nn
import pytest
import nni
import nni.nas.profiler.pytorch.utils.shape as _shape
from nni.mutable import MutableList, Categorical
from nni.nas.nn.pytorch import (
MutableLinear, MutableConv2d, MutableDropout, MutableMultiheadAttention,
ModelSpace,... | 24,812 | 35.382698 | 138 | py |
nni | nni-master/test/ut/nas/profiler/test_utils.py | import torch
from torch import nn
import nni
import nni.nas.nn.pytorch as nas_nn
from nni.mutable import Categorical, frozen_context
from nni.mutable.mutable import _mutable_equal
from nni.nas.profiler.pytorch.utils import _attrs, is_leaf_module, _expression
def test_is_leaf_module():
assert is_leaf_module(nn.Li... | 5,822 | 38.080537 | 152 | py |
nni | nni-master/test/ut/nas/space/__init__.py | 0 | 0 | 0 | py | |
nni | nni-master/test/ut/nas/space/test_executable_space.py | import sys
import pytest
import nni
from nni.mutable import *
from nni.mutable.mutable import _mutable_equal
from nni.nas.evaluator import FunctionalEvaluator, FrozenEvaluator
from nni.nas.space import *
@nni.trace
class MyModelSpace(BaseModelSpace):
def __init__(self):
self.a = Categorical([1, 2, 3], l... | 6,068 | 38.927632 | 145 | py |
nni | nni-master/test/ut/nas/space/test_graph.py | import json
from pathlib import Path
from nni.nas.space import GraphModelSpace
json_files = [
'mnist_tensorflow.json'
]
def test_model_load_dump():
for json_file in json_files:
path = Path(__file__).parent / json_file
_test_file(path)
def _test_file(json_path):
orig_ir = json.load(json... | 973 | 23.974359 | 61 | py |
nni | nni-master/test/ut/nas/space/test_metrics.py | import pytest
import nni
from nni.nas.space import Metrics
def test_metrics():
metrics = Metrics()
metrics.add_intermediate(0.6)
metrics.add_intermediate({'default': 0.7})
metrics.add_intermediate({'default': 0.8, 'accuracy': 0.9})
metrics.final = 1
assert metrics.intermediates == [0.6, 0.7, 0... | 1,211 | 30.894737 | 105 | py |
nni | nni-master/test/ut/nas/space/test_mutator.py | import json
from pathlib import Path
import pytest
from nni.common.framework import get_default_framework, set_default_framework
from nni.nas.space import StationaryMutator, Mutator, MutationSampler, GraphModelSpace, ModelStatus, MutatorSequence
from nni.nas.space.mutator import _RandomSampler
from nni.nas.space.graph... | 6,119 | 33.189944 | 116 | py |
nni | nni-master/test/ut/nas/strategy/__init__.py | 0 | 0 | 0 | py | |
nni | nni-master/test/ut/nas/strategy/test_middleware.py | import random
from collections import defaultdict, Counter
import pytest
from nni.mutable import SampleValidationError
from nni.nas.execution import SequentialExecutionEngine
from nni.nas.space import ModelStatus
from nni.nas.strategy import Random, RegularizedEvolution, PolicyBasedRL, GridSearch, Strategy
from nni.n... | 13,818 | 34.252551 | 107 | py |
nni | nni-master/test/ut/nas/strategy/test_sanity.py | from __future__ import annotations
import pytest
import nni
from nni.mutable import *
from nni.nas.evaluator import FunctionalEvaluator
from nni.nas.execution import SequentialExecutionEngine
from nni.nas.space import *
from nni.nas.strategy import GridSearch, Random, RegularizedEvolution, PolicyBasedRL
@nni.trace
c... | 10,975 | 39.955224 | 142 | py |
nni | nni-master/test/ut/nas/strategy/test_utils.py | import pytest
from nni.mutable import *
from nni.nas.strategy.utils import *
def test_dedup():
deduper = DeduplicationHelper()
assert deduper.dedup(1)
assert deduper.dedup(2)
assert not deduper.dedup(1)
assert deduper.dedup({'a': 1, 'b': {'c': 3, 'd': [2, 3, 4]}})
assert not deduper.dedup({'... | 1,474 | 25.818182 | 69 | py |
nni | nni-master/test/ut/sdk/__init__.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
| 73 | 23.666667 | 38 | py |
nni | nni-master/test/ut/sdk/test_assessor.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from io import BytesIO
import json
from unittest import TestCase, main
from nni.assessor import Assessor, AssessResult
from nni.runtime import msg_dispatcher_base as msg_dispatcher_base
from nni.runtime.msg_dispatcher import MsgDispatcher
from n... | 2,631 | 31.493827 | 129 | py |
nni | nni-master/test/ut/sdk/test_builtin_tuners.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import glob
import json
import logging
import os
import random
import shutil
import sys
from collections import deque
from unittest import TestCase, main
from nni.algorithms.hpo.batch_tuner import BatchTuner
from nni.algorithms.hpo.dngo_tuner im... | 19,899 | 46.268409 | 127 | py |
nni | nni-master/test/ut/sdk/test_curvefitting_assessor.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import numpy as np
import unittest
from nni.algorithms.hpo.curvefitting_assessor import CurvefittingAssessor
from nni.algorithms.hpo.curvefitting_assessor.model_factory import CurveModel
from nni.assessor import AssessResult
class TestCurveFitt... | 2,113 | 44.956522 | 173 | py |
nni | nni-master/test/ut/sdk/test_evolution_tuner.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
"""
test_evolution_tuner.py
"""
import numpy as np
from unittest import TestCase, main
from nni.utils import json2space, json2parameter
class EvolutionTunerTestCase(TestCase):
def test_json2space(self):
"""test for json2space
... | 1,860 | 30.542373 | 108 | py |
nni | nni-master/test/ut/sdk/test_graph_utils.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import sys
import os
import math
import uuid
import shutil
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from tensorboard.compat.proto.graph_pb2 import GraphDef
from google.protobuf import text_format
impor... | 10,450 | 34.307432 | 110 | py |
nni | nni-master/test/ut/sdk/test_hpo_dedup.py | import numpy as np
import nni
from nni.algorithms.hpo.random_tuner import suggest
from nni.common.hpo_utils import Deduplicator, deformat_parameters, format_search_space
seed = np.random.default_rng().integers(2 ** 31)
print(seed)
rng = np.random.default_rng(seed)
finite_space = {
'x': {'_type': 'choice', '_valu... | 2,110 | 27.146667 | 87 | py |
nni | nni-master/test/ut/sdk/test_hpo_formatting.py | from math import exp, log
from nni.common.hpo_utils import deformat_parameters, format_parameters, format_search_space
user_space = {
'pool': { '_type': 'choice', '_value': ['max', 'min', 'avg'] },
'kernel': { '_type': 'randint', '_value': [2, 8] },
'D': { # distribution
'_type': 'choice',
... | 7,187 | 37.438503 | 224 | py |
nni | nni-master/test/ut/sdk/test_hpo_validation.py | from nni.common.hpo_utils import validate_search_space
good = {
'choice': { '_type': 'choice', '_value': ['a', 'b'] },
'randint': { '_type': 'randint', '_value': [1, 10] },
'uniform': { '_type': 'uniform', '_value': [0, 1.0] },
'quniform': { '_type': 'quniform', '_value': [1, 10, 0.1] },
'logunifor... | 3,085 | 46.476923 | 80 | py |
nni | nni-master/test/ut/sdk/test_hyperopt_tuner.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
"""
test_hyperopt_tuner.py
"""
from unittest import TestCase, main
import hyperopt as hp
from nni.algorithms.hpo.hyperopt_tuner import json2space, json2parameter, json2vals, HyperoptTuner
class HyperoptTunerTestCase(TestCase):
def test_j... | 3,572 | 30.901786 | 98 | py |
nni | nni-master/test/ut/sdk/test_msg_dispatcher.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import json
from io import BytesIO
from unittest import TestCase, main
from nni.runtime import msg_dispatcher_base
from nni.runtime.msg_dispatcher import MsgDispatcher
from nni.runtime.tuner_command_channel.legacy import *
from nni.tuner import ... | 3,380 | 33.151515 | 104 | py |
nni | nni-master/test/ut/sdk/test_networkmorphism_tuner.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import json
from unittest import TestCase, main
from copy import deepcopy
import torch
from nni.algorithms.hpo.networkmorphism_tuner import NetworkMorphismTuner
from nni.algorithms.hpo.networkmorphism_tuner.graph import graph_to_json, json_to_gr... | 7,030 | 36.201058 | 87 | py |
nni | nni-master/test/ut/sdk/test_serializer.py | from collections import OrderedDict
import math
import os
import pickle
import subprocess
import sys
from pathlib import Path
import pytest
import nni
import torch
import torch.nn as nn
from torch.utils.data import DataLoader
from torchvision import transforms
from torchvision.datasets import MNIST
from nni.common.se... | 12,063 | 26.861432 | 102 | py |
nni | nni-master/test/ut/sdk/test_trial.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import nni
import nni.trial
from nni.runtime.trial_command_channel import get_default_trial_command_channel, set_default_trial_command_channel
import numpy as np
from unittest import TestCase, main
from .helper.trial_command_channel import Test... | 3,103 | 32.376344 | 114 | py |
nni | nni-master/test/ut/sdk/test_trial_command_channel.py | import pytest
import nni
from nni.trial import overwrite_intermediate_seq
from nni.runtime.trial_command_channel import (
TrialCommandChannel, set_default_trial_command_channel,
get_default_trial_command_channel
)
def test_standalone(caplog):
overwrite_intermediate_seq(0)
with pytest.warns(RuntimeWa... | 1,560 | 31.520833 | 77 | py |
nni | nni-master/test/ut/sdk/test_utils.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from unittest import TestCase, main
import nni
from nni.utils import split_index
class UtilsTestCase(TestCase):
def test_split_index_normal(self):
"""test for normal search space
"""
normal__params_with_index = {
... | 2,274 | 24.561798 | 55 | py |
nni | nni-master/test/ut/sdk/test_version.py | import pytest
import sys
from nni.common.version import version_dump, version_check
def test_version_dump():
dump_ver = version_dump()
assert len(dump_ver) >= 9
print(dump_ver)
def test_version_check():
version_check(version_dump(), raise_error=True)
version_check({'python': sys.version_info[:2... | 525 | 22.909091 | 69 | py |
nni | nni-master/test/ut/sdk/test_ws_channel.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import atexit
from dataclasses import dataclass
import importlib
import json
import os
from pathlib import Path
from subprocess import Popen, PIPE
import sys
import time
from nni.runtime.command_channel.websocket import WsChannelClient
# A help... | 2,217 | 24.494253 | 93 | py |
nni | nni-master/test/ut/sdk/helper/__init__.py | 0 | 0 | 0 | py | |
nni | nni-master/test/ut/sdk/helper/trial_command_channel.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from __future__ import annotations
import copy
from typing_extensions import Literal
from nni.runtime.trial_command_channel import TrialCommandChannel
from nni.typehint import TrialMetric, ParameterRecord
class TestHelperTrialCommandChannel(T... | 1,379 | 27.163265 | 89 | py |
nni | nni-master/test/ut/sdk/helper/websocket_server.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
"""
A WebSocket server runs on random port, accepting one single client.
It prints each message received from client to stdout,
and send each line read from stdin to the client.
"""
import asyncio
import sys
import aioconsole
import websockets... | 1,470 | 22.725806 | 70 | py |
nni | nni-master/test/ut/sdk/imported/_test_serializer_py38.py | import nni
def test_positional_only():
def foo(a, b, /, c):
pass
d = nni.trace(foo)(1, 2, c=3)
assert d.trace_args == [1, 2]
assert d.trace_kwargs == dict(c=3)
| 187 | 16.090909 | 38 | py |
nni | nni-master/test/ut/sdk/imported/model.py | import nni.retiarii.nn.pytorch as nn
from nni.retiarii import basic_unit
@basic_unit
class ImportTest(nn.Module):
def __init__(self, foo, bar):
super().__init__()
self.foo = nn.Linear(foo, 3)
self.bar = nn.Dropout(bar)
def __eq__(self, other):
return self.foo.in_features == ot... | 370 | 25.5 | 90 | py |
nni | nni-master/test/ut/sdk/models/pytorch_models/__init__.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
| 73 | 23.666667 | 38 | py |
nni | nni-master/test/ut/sdk/models/pytorch_models/mobilenet.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
#
# This file contains code adapted from AMC (https://github.com/mit-han-lab/amc)
# Copyright (c) 2018 MIT_Han_Lab
# Licensed under the MIT License
# https://github.com/mit-han-lab/amc/blob/master/LICENSE
import torch.nn as nn
import math
def c... | 2,728 | 29.662921 | 104 | py |
nni | nni-master/test/ut/sdk/models/pytorch_models/transformer.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import torch
import torch.nn as nn
import torch.nn.functional as F
import math
import copy
class PosEncoding(nn.Module):
def __init__(self, hidden_dim, max_seq_len=80):
super().__init__()
self.hidden_dim = hidden_dim
... | 6,981 | 35.554974 | 123 | py |
nni | nni-master/test/ut/sdk/mutable/test_frozen.py | import pytest
from nni.mutable import *
def _frozen_context_middle():
assert frozen_context.current() == {'a': 1, 'b': 2}
with frozen_context.bypass():
assert frozen_context.current() is None
def test_frozen_context():
with frozen_context({'a': 1, 'b': 2}):
_frozen_context_middle()
... | 2,858 | 34.296296 | 98 | py |
nni | nni-master/test/ut/sdk/mutable/test_label.py | import pytest
from nni.mutable import label_scope, auto_label
from nni.mutable.utils import reset_uid
def test_label_simple():
reset_uid('global')
with label_scope('param'):
label1 = auto_label()
label2 = auto_label()
with label_scope() as scope:
assert scope.activated
... | 4,585 | 26.793939 | 75 | py |
nni | nni-master/test/ut/sdk/mutable/test_mutable.py | import math
from collections import Counter
import numpy as np
import pytest
from nni.mutable import *
from nni.mutable.mutable import _dedup_labeled_mutables, _mutable_equal
def test_symbolic_execution():
a = Categorical([1, 2], label='a')
b = Categorical([3, 4], label='b')
c = Categorical([5, 6], labe... | 23,116 | 33.451565 | 120 | py |
nni | nni-master/test/ut/sdk/mutable/test_shortcut.py | from collections import Counter
import nni
from nni.mutable._notimplemented import randint, lognormal, qlognormal
def test_choice():
t = nni.choice('t', ['a', 'b', 'c'])
assert repr(t) == "Categorical(['a', 'b', 'c'], label='t')"
def test_randint():
t = randint('x', 1, 5)
assert repr(t) == "RandomInt... | 2,008 | 33.050847 | 103 | py |
nni | nni-master/test/ut/sdk/mutable/test_symbol.py | import pytest
from nni.mutable.symbol import Symbol, SymbolicExpression
def test_symbol_repr():
x, y = Symbol('x'), Symbol('y')
expr = x * x + y * 2
assert str(expr) == '(x * x) + (y * 2)'
assert list(expr.leaf_symbols()) == [x, x, y]
assert expr.evaluate({'x': 2, 'y': 3}) == 10
expr = x * x
... | 1,274 | 36.5 | 77 | py |
nni | nni-master/test/ut/tools/nnictl/test_common_utils.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from pathlib import Path
from subprocess import Popen, PIPE, STDOUT
import sys
from unittest import TestCase, main, skipIf
sys.path.append(str(Path(__file__).parent))
from mock.restful_server import init_response
from nni.tools.nnictl.command_u... | 1,415 | 30.466667 | 98 | py |
nni | nni-master/test/ut/tools/nnictl/test_config_utils.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from pathlib import Path
from unittest import TestCase, main
from nni.tools.nnictl.config_utils import Config, Experiments
HOME_PATH = str(Path(__file__).parent / "mock/nnictl_metadata")
class CommonUtilsTestCase(TestCase):
def test_update... | 887 | 34.52 | 112 | py |
nni | nni-master/test/ut/tools/nnictl/test_config_validation.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import glob
from unittest import TestCase, main
from schema import SchemaError
from nni.tools.nnictl.launcher_utils import validate_all_content
from nni.tools.nnictl.nnictl_utils import get_yml_content
from nni.tools.nnictl.common_utils import pr... | 1,231 | 37.5 | 104 | py |
nni | nni-master/test/ut/tools/nnictl/test_kill_command.py | import argparse
import multiprocessing
import os
import subprocess
import signal
import sys
import signal
import time
import pytest
from nni.tools.nnictl.command_utils import kill_command, _check_pid_running
# Windows sometimes fail with "Terminate batch job (Y/N)?"
pytestmark = pytest.mark.skipif(sys.platform == 'w... | 3,984 | 29.891473 | 113 | py |