python_code
stringlengths
0
4.04M
repo_name
stringlengths
7
58
file_path
stringlengths
5
147
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved # adapted from OFA: https://github.com/mit-han-lab/once-for-all import torch.nn as nn from .activations import * def make_divisible(v, divisor=8, min_value=1): """ forked from slim: https://github.com/tensorflow/models/blob/\ 0344...
AttentiveNAS-main
models/modules/nn_utils.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved # adapted from OFA: https://github.com/mit-han-lab/once-for-all from torch.autograd.function import Function import torch.nn.functional as F from torch.nn.parameter import Parameter import torch.nn as nn import torch from torch.nn.modules._function...
AttentiveNAS-main
models/modules/dynamic_ops.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved import torch import torch.nn as nn from .lr_scheduler import WarmupCosineLR, WarmupMultiStepLR, WarmupLinearDecayLR, ConstantLR def build_optimizer(args, model): """ Build an optimizer from config. """ no_wd_params, wd_params ...
AttentiveNAS-main
solver/build.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved import torch import math from bisect import bisect_right from typing import List class WarmupCosineLR(torch.optim.lr_scheduler._LRScheduler): def __init__(self, optimizer, max_iters, warmup_factor = 0.001, warm...
AttentiveNAS-main
solver/lr_scheduler.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved from .build import build_optimizer, build_lr_scheduler
AttentiveNAS-main
solver/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved import torch import torch.nn as nn import torch.nn.parallel import torch.backends.cudnn as cudnn import torch.distributed as dist import torch.optim import torch.multiprocessing as mp import torch.utils.data import torch.utils.data.distributed impo...
AttentiveNAS-main
evaluate/imagenet_eval.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved import torch import torch.nn as nn import torch.nn.parallel import torch.backends.cudnn as cudnn import torch.distributed as dist import torch.optim import torch.multiprocessing as mp import torch.utils.data import torch.utils.data.distributed imp...
AttentiveNAS-main
evaluate/attentive_nas_eval.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved import sys import atexit import os import random import copy def count_helper(v, flops, m): if flops not in m: m[flops] = {} if v not in m[flops]: m[flops][v] = 0 m[flops][v] += 1 def round_flops(flops, step): re...
AttentiveNAS-main
sampler/attentive_nas_sampler.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved """ Auto Augment Implementation adapted from timm: https://github.com/rwightman/pytorch-image-models """ import random import math from PIL import Image, ImageOps, ImageEnhance import PIL _PIL_VER = tuple([int(x) for x in PIL.__version__.split('...
AttentiveNAS-main
data/auto_augment_tf.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved from __future__ import print_function import torch import torchvision.transforms.functional as F from torchvision import datasets, transforms from torch.utils.data import Dataset import math import sys import random from PIL import Image from tor...
AttentiveNAS-main
data/data_loader.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
AttentiveNAS-main
data/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved import torch from PIL import Image import numpy as np import torchvision.transforms as transforms from .auto_augment_tf import ( auto_augment_policy, AutoAugment, ) IMAGENET_PIXEL_MEAN = [123.675, 116.280, 103.530] IMAGENET_PIXEL_STD = [...
AttentiveNAS-main
data/data_transform.py
# + import numpy as np def generate_synthetic_data( n,corr,class_balance, l_probs, l_groups): cardinality = len(class_balance) y_true = np.random.choice(cardinality, n, p=class_balance) def generate_correlated(num: int = 2): """Generate num correlated label columns.""" ls = [[...
dependency_model-main
utils.py
import cvxpy as cp import numpy as np import scipy as sp def learn_structure(L): N = float(np.shape(L)[0]) M = int(np.shape(L)[1]) sigma_O = (np.dot(L.T,L))/(N-1) - \ np.outer(np.mean(L,axis=0), np.mean(L,axis=0)) #bad code O = 1/2*(sigma_O+sigma_O.T) O_root = np.real(sp.linalg.sqrtm(...
dependency_model-main
learn_deps.py
#!/usr/bin/env python3 # # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import argparse import distutils.command.build import distutils.util import fnmatch import glob import io import os i...
CompilerGym-development
setup.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import compiler_gym from compiler_gym.envs import LlvmEnv from tests.test_main import main def test_compiler_gym_make(): """Test that com...
CompilerGym-development
tests/make_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Unit tests for //compiler_gym/envs.""" import gym import pytest from flaky import flaky from compiler_gym.envs import llvm from compiler_gy...
CompilerGym-development
tests/compiler_env_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Tests for the copy() and deepcopy() operators on ClientServiceCompilerEnv.""" from copy import copy, deepcopy import pytest from compiler_...
CompilerGym-development
tests/env_copy_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the LICENSE file # in the root directory of this source tree. # # tests/**/__init__.py files are needed for pytest Python path resolution. See: # https://docs.pytest.org/en/latest/explanation/pythonpath.ht...
CompilerGym-development
tests/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Unit tests for //compiler_gym:validate.""" import gym import pytest from compiler_gym import CompilerEnvState, validate_states from tests.t...
CompilerGym-development
tests/validate_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import pkg_resources import compiler_gym from compiler_gym.util.runfiles_path import runfiles_path from packaging import version from tests.py...
CompilerGym-development
tests/version_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Unit tests for //compiler_gym:compiler_env_state.""" import json from io import StringIO from pathlib import Path import pytest import requ...
CompilerGym-development
tests/compiler_env_state_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Unit tests for //compiler_gym/bin:random_search.""" import tempfile from pathlib import Path import gym from compiler_gym.random_search im...
CompilerGym-development
tests/random_search_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import os import sys from getpass import getuser from typing import List, Optional import pytest from compiler_gym.util import debug_util as ...
CompilerGym-development
tests/test_main.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Unit tests for //compiler_gym:validation_result.""" import json import pytest from compiler_gym import CompilerEnvState, ValidationError, ...
CompilerGym-development
tests/validation_result_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Unit tests for //compiler_gym/wrappers.""" from compiler_gym.envs.llvm import LlvmEnv from compiler_gym.wrappers import CommandlineWithTermi...
CompilerGym-development
tests/wrappers/commandline_wrappers_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Unit tests for compiler_gym.wrappers.llvm.""" import numpy as np import pytest from flaky import flaky from compiler_gym.envs.llvm import L...
CompilerGym-development
tests/wrappers/llvm_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Unit tests for //compiler_gym/wrappers.""" from compiler_gym.envs.llvm import LlvmEnv from compiler_gym.wrappers import Counter from tests.t...
CompilerGym-development
tests/wrappers/counter_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Unit tests for //compiler_gym/wrappers.""" from compiler_gym.envs.llvm import LlvmEnv from compiler_gym.wrappers import CycleOverBenchmarks,...
CompilerGym-development
tests/wrappers/time_limit_wrappers_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Unit tests for //compiler_gym/wrappers.""" import pytest from compiler_gym.envs.llvm import LlvmEnv from compiler_gym.wrappers import ( ...
CompilerGym-development
tests/wrappers/datasets_wrappers_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the LICENSE file # in the root directory of this source tree. # # tests/**/__init__.py files are needed for pytest Python path resolution. See: # https://docs.pytest.org/en/latest/explanation/pythonpath.ht...
CompilerGym-development
tests/wrappers/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Unit tests for //compiler_gym/wrappers.""" import pytest from pytest import warns from compiler_gym.datasets import Datasets from compiler_...
CompilerGym-development
tests/wrappers/core_wrappers_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Unit tests for //compiler_gym/wrappers.""" import pytest from compiler_gym.envs.llvm import LlvmEnv from compiler_gym.wrappers import Compi...
CompilerGym-development
tests/wrappers/sqlite_logger_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Unit tests for compiler_gym.wrappers.llvm.""" import pytest from compiler_gym.envs.llvm import LlvmEnv from compiler_gym.wrappers import Va...
CompilerGym-development
tests/wrappers/validation_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Unit tests for //compiler_gym/wrappers.""" from compiler_gym.envs.llvm import LlvmEnv from compiler_gym.wrappers import ForkOnStep from test...
CompilerGym-development
tests/wrappers/fork_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the LICENSE file # in the root directory of this source tree. # # tests/**/__init__.py files are needed for pytest Python path resolution. See: # https://docs.pytest.org/en/latest/explanation/pythonpath.ht...
CompilerGym-development
tests/loop_tool/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Integrations tests for the loop_tool CompilerGym environment.""" import loop_tool_py as lt import pytest from flaky import flaky import co...
CompilerGym-development
tests/loop_tool/actions_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Fuzz test for LlvmEnv.fork().""" import numpy as np import pytest from compiler_gym.envs import LlvmEnv from tests.test_main import main p...
CompilerGym-development
tests/fuzzing/llvm_fork_env_fuzz_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Integrations tests for the LLVM CompilerGym environments.""" from time import time import gym import numpy as np import pytest from compi...
CompilerGym-development
tests/fuzzing/llvm_random_actions_fuzz_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the LICENSE file # in the root directory of this source tree. # # tests/**/__init__.py files are needed for pytest Python path resolution. See: # https://docs.pytest.org/en/latest/explanation/pythonpath.ht...
CompilerGym-development
tests/fuzzing/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Fuzz test for LlvmEnv.action_space.to_string().""" import os import subprocess from pathlib import Path import pytest from compiler_gym.en...
CompilerGym-development
tests/fuzzing/llvm_commandline_opt_equivalence_fuzz_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Fuzz test for LlvmEnv.validate().""" import numpy as np import pytest from compiler_gym.envs import LlvmEnv from compiler_gym.errors import...
CompilerGym-development
tests/fuzzing/llvm_trajectory_replay_fuzz_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Tests for action space determinism.""" import hashlib import random import pytest from compiler_gym.envs import LlvmEnv from tests.pytest_...
CompilerGym-development
tests/fuzzing/llvm_deterministic_action_fuzz_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Fuzz test for LlvmEnv.validate().""" import random import pytest from compiler_gym.envs import LlvmEnv from tests.pytest_plugins.llvm impo...
CompilerGym-development
tests/fuzzing/llvm_cbench_validate_fuzz_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Fuzz test LLVM backend using llvm-stress.""" import pytest from compiler_gym.envs import LlvmEnv from compiler_gym.errors import BenchmarkI...
CompilerGym-development
tests/fuzzing/llvm_stress_fuzz_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Unit tests for //compiler_gym/util:capture_output.""" import sys from compiler_gym.util.capture_output import capture_output from tests.tes...
CompilerGym-development
tests/util/capture_output_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Unit tests for //compiler_gym/util:timer.""" import logging import os from compiler_gym.util import debug_util as dbg from tests.test_main ...
CompilerGym-development
tests/util/debug_util_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Unit tests for //compiler_gym/util:download.""" import pytest from compiler_gym.errors import DownloadFailed, TooManyRequests from compiler...
CompilerGym-development
tests/util/download_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Unit tests for compiler_gym/util/shell_format.py""" from compiler_gym.util import shell_format as fmt from tests.test_main import main def...
CompilerGym-development
tests/util/shell_format_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Unit tests for compiler_gym/util/locks.py""" from datetime import datetime from pathlib import Path from threading import Thread from flaky...
CompilerGym-development
tests/util/runfiles_path_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Unit tests for compiler_gym.util.executor.""" import sys from typing import Iterable import pytest from compiler_gym.util.executor import ...
CompilerGym-development
tests/util/executor_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Unit tests for //compiler_gym/util:timer.""" from time import sleep from compiler_gym.util import timer from tests.test_main import main ...
CompilerGym-development
tests/util/timer_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Unit tests for //compiler_gym/util:parallelization.""" from compiler_gym.util import parallelization from tests.test_main import main def ...
CompilerGym-development
tests/util/parallelization_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Unit tests for //compiler_gym/util:truncate.""" from compiler_gym.util.truncate import truncate, truncate_lines from tests.test_main import ...
CompilerGym-development
tests/util/truncate_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the LICENSE file # in the root directory of this source tree. # # tests/**/__init__.py files are needed for pytest Python path resolution. See: # https://docs.pytest.org/en/latest/explanation/pythonpath.ht...
CompilerGym-development
tests/util/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Unit tests for compiler_gym.util.commands.""" import subprocess import pytest from compiler_gym.util.commands import Popen, communicate fr...
CompilerGym-development
tests/util/commands_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Unit tests for //compiler_gym/util:filesystem.""" from pathlib import Path import pytest from compiler_gym.util import filesystem from tes...
CompilerGym-development
tests/util/filesystem_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Unit tests for //compiler_gym/util:temporary_working_directory.""" import os import tempfile from pathlib import Path from compiler_gym.uti...
CompilerGym-development
tests/util/temporary_working_directory_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Unit tests for //compiler_gym/util:statistics.""" from pytest import approx from compiler_gym.util.statistics import geometric_mean from te...
CompilerGym-development
tests/util/statistics_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Unit tests for //compiler_gym/util:minimize_trajectory.""" import logging import sys from typing import List import pytest from compiler_g...
CompilerGym-development
tests/util/minimize_trajectory_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import numpy as np import compiler_gym.util.permutation as permutation from tests.test_main import main def test_permutation_number_mapping(...
CompilerGym-development
tests/util/permutation_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Tests for //compiler_gym/bin:manual_env.""" import re import sys from difflib import unified_diff from io import StringIO from random import...
CompilerGym-development
tests/bin/manual_env_bin_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Unit tests for //compiler_gym/bin:validate.""" import tempfile from io import StringIO from pathlib import Path from typing import List imp...
CompilerGym-development
tests/bin/validate_bin_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the LICENSE file # in the root directory of this source tree. # # tests/**/__init__.py files are needed for pytest Python path resolution. See: # https://docs.pytest.org/en/latest/explanation/pythonpath.ht...
CompilerGym-development
tests/bin/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Unit tests for //compiler_gym/bin:service.""" import sys import gym import pytest from absl import flags import compiler_gym from compiler...
CompilerGym-development
tests/bin/service_bin_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Unit tests for compiler_gym.datasets.uri.""" from compiler_gym.datasets import BenchmarkUri from tests.test_main import main pytest_plugins...
CompilerGym-development
tests/datasets/uri_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Unit tests for //compiler_gym/datasets:files_dataset_test.""" import tempfile from pathlib import Path import numpy as np import pytest fr...
CompilerGym-development
tests/datasets/files_dataset_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the LICENSE file # in the root directory of this source tree. # # tests/**/__init__.py files are needed for pytest Python path resolution. See: # https://docs.pytest.org/en/latest/explanation/pythonpath.ht...
CompilerGym-development
tests/datasets/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Unit tests for //compiler_gym/datasets.""" from pathlib import Path import numpy as np import pytest from compiler_gym.datasets.datasets i...
CompilerGym-development
tests/datasets/datasets_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Unit tests for //compiler_gym/datasets.""" from pathlib import Path import pytest from compiler_gym.datasets.dataset import Dataset from c...
CompilerGym-development
tests/datasets/dataset_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Unit tests for //compiler_gym/datasets:benchmark.""" from pathlib import Path import pytest from compiler_gym.datasets import Benchmark, B...
CompilerGym-development
tests/datasets/benchmark_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Unit tests for //compiler_gym/spaces:scalar.""" from compiler_gym.spaces import Commandline, CommandlineFlag from tests.test_main import mai...
CompilerGym-development
tests/spaces/commandline_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from gym.spaces import Discrete from compiler_gym.spaces import Dict from tests.test_main import main def test_equal(): assert Dict({"a...
CompilerGym-development
tests/spaces/dict_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Unit tests for //compiler_gym/spaces:sequence.""" from copy import deepcopy import pytest from compiler_gym.spaces import Scalar, Sequence...
CompilerGym-development
tests/spaces/sequence_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from gym.spaces import Discrete from compiler_gym.spaces import Tuple from tests.test_main import main def test_equal(): assert Tuple([...
CompilerGym-development
tests/spaces/tuple_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Unit tests for compiler_gym/spaces/action_space.py.""" from compiler_gym.spaces import ActionSpace, Discrete, NamedDiscrete from tests.test_...
CompilerGym-development
tests/spaces/action_space_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the LICENSE file # in the root directory of this source tree. # # tests/**/__init__.py files are needed for pytest Python path resolution. See: # https://docs.pytest.org/en/latest/explanation/pythonpath.ht...
CompilerGym-development
tests/spaces/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Unit tests for //compiler_gym/spaces:named_discrete.""" import pytest from compiler_gym.spaces import NamedDiscrete from tests.test_main im...
CompilerGym-development
tests/spaces/named_discrete_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Unit tests for compiler_gym.spaces.Reward.""" from copy import deepcopy from compiler_gym.spaces import Reward from tests.test_main import ...
CompilerGym-development
tests/spaces/reward_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Unit tests for //compiler_gym/spaces:scalar.""" from copy import copy, deepcopy from compiler_gym.spaces import Scalar from tests.test_main...
CompilerGym-development
tests/spaces/scalar_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from compiler_gym.spaces import Box from tests.test_main import main def test_equal(): assert Box(low=0, high=1, name="test_box", shape=[...
CompilerGym-development
tests/spaces/box_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from compiler_gym.spaces import Discrete from tests.test_main import main def test_equal(): assert Discrete(2, name="test_discrete") == D...
CompilerGym-development
tests/spaces/discrete_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import pytest from compiler_gym.spaces import Permutation, Scalar from tests.test_main import main def test_invalid_scalar_range_dtype(): ...
CompilerGym-development
tests/spaces/permutation_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Integrations tests for the LLVM CompilerGym environments.""" from enum import Enum from io import StringIO from pathlib import Path from typ...
CompilerGym-development
tests/llvm/llvm_env_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Tests for LLVM benchmark handling.""" import pytest from compiler_gym.envs import llvm from compiler_gym.envs.llvm import LlvmEnv from comp...
CompilerGym-development
tests/llvm/invalid_ir_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Tests for LLVM benchmark handling.""" import re import subprocess import tempfile from pathlib import Path import gym import pytest from c...
CompilerGym-development
tests/llvm/custom_benchmarks_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Regression tests for LlvmEnv.validate().""" from io import StringIO import pytest from compiler_gym import CompilerEnvStateReader from com...
CompilerGym-development
tests/llvm/validation_regression_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Integrations tests for the LLVM CompilerGym environments.""" import gym import numpy as np import pytest import compiler_gym # noqa Regist...
CompilerGym-development
tests/llvm/service_connection_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Tests for LlvmEnv.episode_reward.""" from compiler_gym.envs import LlvmEnv from tests.test_main import main pytest_plugins = ["tests.pytest...
CompilerGym-development
tests/llvm/episode_reward_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Integrations tests for the LLVM CompilerGym environments.""" import os import sys from typing import Any, Dict, List, NamedTuple import gym...
CompilerGym-development
tests/llvm/observation_spaces_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Integrations tests for splitting and merging benchmarks.""" import random import pytest from compiler_gym.datasets import Benchmark from c...
CompilerGym-development
tests/llvm/split_merge_integration_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Integrations tests for the LLVM CompilerGym environments.""" from threading import Thread from typing import List import gym from flaky imp...
CompilerGym-development
tests/llvm/threading_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Tests for the LLVM environment action space.""" from compiler_gym.envs.llvm.llvm_env import LlvmEnv from tests.test_main import main pytest...
CompilerGym-development
tests/llvm/action_space_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Integrations tests for the LLVM CompilerGym environments.""" import multiprocessing as mp import sys from typing import List import gym imp...
CompilerGym-development
tests/llvm/multiprocessing_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Tests that module and source IDs are stripped in the LLVM modules.""" from compiler_gym.envs.llvm import LlvmEnv from tests.test_main import...
CompilerGym-development
tests/llvm/module_id_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Tests for the compute_observation() function.""" from pathlib import Path import networkx.algorithms.isomorphism import pytest from compil...
CompilerGym-development
tests/llvm/compute_observation_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Integrations tests for the LLVM CompilerGym environments.""" from compiler_gym.envs import CompilerEnv from tests.test_main import main pyt...
CompilerGym-development
tests/llvm/autophase_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Integrations tests for the LLVM CompilerGym environments.""" import numpy as np import pytest from compiler_gym.envs.llvm.llvm_env import L...
CompilerGym-development
tests/llvm/reward_spaces_test.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the LICENSE file # in the root directory of this source tree. # # tests/**/__init__.py files are needed for pytest Python path resolution. See: # https://docs.pytest.org/en/latest/explanation/pythonpath.ht...
CompilerGym-development
tests/llvm/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Integrations tests for the LLVM CompilerGym environments.""" import tempfile from pathlib import Path import gym import pytest from compil...
CompilerGym-development
tests/llvm/validate_test.py