python_code stringlengths 0 4.04M | repo_name stringlengths 7 58 | file_path stringlengths 5 147 |
|---|---|---|
# 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.
"""Integration tests for the LLVM autotuners."""
from llvm_autotuning.autotuners import Autotuner
import compiler_gym
def test_autotune():
... | CompilerGym-development | examples/llvm_autotuning/autotuners/random_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.
"""Integration tests for the LLVM autotuners."""
import pytest
from llvm_autotuning.autotuners import Autotuner
import compiler_gym
@pytest.... | CompilerGym-development | examples/llvm_autotuning/autotuners/opentuner_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 time import time
def greedy(env, search_time_seconds: int, **kwargs) -> None:
"""A greedy search policy.
At each step, the poli... | CompilerGym-development | examples/llvm_autotuning/autotuners/greedy.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.
"""This modules defines a class for describing LLVM autotuners."""
import tempfile
from pathlib import Path
from typing import Any, Dict
from ... | CompilerGym-development | examples/llvm_autotuning/autotuners/__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.
from tempfile import TemporaryDirectory
from llvm_autotuning.optimization_target import OptimizationTarget
from compiler_gym.envs import Comp... | CompilerGym-development | examples/llvm_autotuning/autotuners/random_.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 functools import lru_cache
from time import time
from typing import Tuple
import nevergrad as ng
from llvm_autotuning.optimization_target... | CompilerGym-development | examples/llvm_autotuning/autotuners/nevergrad_.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.
"""Integration tests for the LLVM autotuners."""
from llvm_autotuning.autotuners import Autotuner
import compiler_gym
def test_autotune():
... | CompilerGym-development | examples/llvm_autotuning/autotuners/nevergrad_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 random
import subprocess
import tempfile
import warnings
from pathlib import Path
import numpy as np
from llvm_autotuning.optimization_... | CompilerGym-development | examples/llvm_autotuning/autotuners/opentuner_.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.
"""Integration tests for the LLVM autotuners."""
import pytest
from llvm_autotuning.autotuners import Autotuner
import compiler_gym
@pytest.... | CompilerGym-development | examples/llvm_autotuning/autotuners/greedy_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 subprocess
import sys
from pathlib import Path
def test_llvm_autotuner_integration_test(tmp_path: Path):
subprocess.check_call(
... | CompilerGym-development | examples/llvm_autotuning/tests/integration_test.py |
CompilerGym-development | examples/gcc_autotuning/__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.
"""Autotuning script for GCC command line options."""
import random
from itertools import islice, product
from multiprocessing import Lock
from... | CompilerGym-development | examples/gcc_autotuning/tune.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 pathlib import Path
from typing import List
import pandas as pd
from llvm_autotuning.experiment import Experiment
fr... | CompilerGym-development | examples/gcc_autotuning/info.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 subprocess
import sys
from functools import lru_cache
from pathlib import Path
from typing import Iterable
import docker
import pytest
... | CompilerGym-development | examples/gcc_autotuning/tune_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 example CompilerGym service."""
import socket
import subprocess
from pathlib import Path
from time import sleep
import gym
im... | CompilerGym-development | examples/example_compiler_gym_service/env_tests.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 example CompilerGym service."""
import os
import socket
import subprocess
import sys
from getpass import getuser
from pathlib ... | CompilerGym-development | examples/example_compiler_gym_service/env_without_bazel_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.
"""This module defines and registers the example gym environments."""
from pathlib import Path
from typing import Iterable
from compiler_gym.d... | CompilerGym-development | examples/example_compiler_gym_service/__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.
"""Smoke test for examples/example_compiler_gym_service/demo_without_bazel.py"""
from example_compiler_gym_service.demo_without_bazel import ma... | CompilerGym-development | examples/example_compiler_gym_service/demo_without_bazel_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.
"""This script demonstrates how the Python example service without needing
to use the bazel build system. Usage:
$ python example_compiler... | CompilerGym-development | examples/example_compiler_gym_service/demo_without_bazel.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.
"""This script demonstrates how the example services defined in this directory
can be used as gym environments. Usage:
$ bazel run -c opt ... | CompilerGym-development | examples/example_compiler_gym_service/demo.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.
"""An example CompilerGym service in python."""
import logging
from pathlib import Path
from typing import Optional,... | CompilerGym-development | examples/example_compiler_gym_service/service_py/example_service.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 pickle
import sqlite3
import zlib
import dgl
import numpy as np
import torch
from dgl.data import DGLDataset
class CompilerGymDataset... | CompilerGym-development | examples/gnn_cost_model/compiler_gym_dataset.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 examples/gnn_cost_model/train_cost_model_test.py"""
import sys
import pytest
from absl import flags
from compiler_gym.util.captu... | CompilerGym-development | examples/gnn_cost_model/train_test.py |
CompilerGym-development | examples/gnn_cost_model/__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.
import dgl
import numpy as np
import torch
import torch.nn as nn
class GNNEncoder(nn.Module):
def __init__(
self,
node_vo... | CompilerGym-development | examples/gnn_cost_model/model.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.
"""
This module trains a cost model with a GNN on a LLVM-IR transition database
predicting some output reward (the default is instruction count... | CompilerGym-development | examples/gnn_cost_model/train.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.
| CompilerGym-development | examples/llvm_rl/__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.
import sys
from pathlib import Path
from typing import List
from llvm_rl.model import Model
def main(argv):
paths = argv[1:] or ["~/logs... | CompilerGym-development | examples/llvm_rl/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.
"""Environment wrappers to closer replicate the MLSys'20 Autophase paper."""
from typing import List
import gym
import numpy as np
from compi... | CompilerGym-development | examples/llvm_rl/wrappers.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
import hydra
from hydra.core.hydra_config import HydraConfig
from llvm_rl.model import Model
from omegaconf import DictCo... | CompilerGym-development | examples/llvm_rl/train.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 re
import sys
from pathlib import Path
from typing import List
import humanize
import pandas as pd
from llvm_rl.model import Model
from... | CompilerGym-development | examples/llvm_rl/info.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 pytest
from llvm_rl import wrappers
import compiler_gym
@pytest.fixture(scope="function")
def env():
with comp... | CompilerGym-development | examples/llvm_rl/tests/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.
from llvm_rl.model.testing import Testing
from omegaconf import OmegaConf
import compiler_gym
def test_testing_config():
cfg = Testing(
... | CompilerGym-development | examples/llvm_rl/tests/testing_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 llvm_rl.model.environment import Environment
def test_basic_environment_config():
model = Environment(id="llvm-ic-v0", max_episode_s... | CompilerGym-development | examples/llvm_rl/tests/environment_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 llvm_rl.model.training import Training
from omegaconf import OmegaConf
def test_parse_yaml():
cfg = Training(
**OmegaConf.cr... | CompilerGym-development | examples/llvm_rl/tests/training_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 llvm_rl.model.validation import Validation
from omegaconf import OmegaConf
import compiler_gym
from compiler_gym.datasets import Benchmar... | CompilerGym-development | examples/llvm_rl/tests/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.
import pytest
from llvm_rl.model.training import Benchmarks
from omegaconf import OmegaConf
from pydantic import ValidationError
import compil... | CompilerGym-development | examples/llvm_rl/tests/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.
import json
import os
import sys
import warnings
from pathlib import Path
from llvm_rl.model.model import Model
from omegaconf import OmegaCon... | CompilerGym-development | examples/llvm_rl/tests/training_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.
import logging
from typing import List
import numpy as np
from pydantic import BaseModel, validator
from ray.rllib.agents.dqn import ApexTrain... | CompilerGym-development | examples/llvm_rl/model/inference_result.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 .model import Model
__all__ = [
"Model",
]
| CompilerGym-development | examples/llvm_rl/model/__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.
import json
import logging
import warnings
from datetime import datetime
from pathlib import Path
from typing import Any, Dict, Iterable, List,... | CompilerGym-development | examples/llvm_rl/model/model.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 warnings
from typing import Any, Dict
import numpy as np
from omegaconf import DictConfig, ListConfig
from pydantic import BaseModel, F... | CompilerGym-development | examples/llvm_rl/model/agent.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 typing import Any, Dict, List, Optional
from llvm_autotuning.just_keep_going_env import JustKeepGoingEnv
from llvm_rl.wrappers import * ... | CompilerGym-development | examples/llvm_rl/model/environment.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 logging
from itertools import islice
from typing import Iterable, List
import numpy as np
from pydantic import BaseModel, Field, valida... | CompilerGym-development | examples/llvm_rl/model/testing.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 itertools import islice
from typing import Iterable, List, Union
from pydantic import BaseModel, Field, root_validator, validator
from c... | CompilerGym-development | examples/llvm_rl/model/benchmarks.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 typing import Iterable, List
from pydantic import BaseModel, Field, validator
from compiler_gym.datasets import Benchmark
from compiler_... | CompilerGym-development | examples/llvm_rl/model/training.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 typing import Iterable, List
from pydantic import BaseModel, Field, validator
from compiler_gym.datasets import Benchmark
from compiler_... | CompilerGym-development | examples/llvm_rl/model/validation.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.
"""Estimate the immediate reward of different actions using random trials.
This script estimates the immediate reward that running a specific ... | CompilerGym-development | examples/sensitivity_analysis/action_sensitivity_analysis.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.
"""End-to-end test of //compiler_gym/bin:action_sensitivity_analysis."""
import tempfile
from pathlib import Path
from absl.flags import FLAG... | CompilerGym-development | examples/sensitivity_analysis/action_sensitivity_analysis_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.
"""Evaluate logs generated by sensitivity analysis.
Usage:
$ bazel run -c opt //compiler_gym/bin:sensitivity_analysis_eval -- \
-... | CompilerGym-development | examples/sensitivity_analysis/sensitivity_analysis_eval.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.
"""Estimate the cumulative reward of random episodes on benchmarks.
This script estimates the cumulative reward for a random episode on a benc... | CompilerGym-development | examples/sensitivity_analysis/benchmark_sensitivity_analysis.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.
"""End-to-end test of //compiler_gym/bin:benchmark_sensitivity_analysis."""
import tempfile
from pathlib import Path
from absl.flags import F... | CompilerGym-development | examples/sensitivity_analysis/benchmark_sensitivity_analysis_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.
"""Smoke test for //benchmarks:parallelization_load_test."""
from pathlib import Path
from absl import flags
from benchmarks.parallelization_... | CompilerGym-development | benchmarks/parallelization_load_test_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.
"""A load test for measuring parallelization scalability.
This benchmark runs random episodes with varying numbers of parallel threads and
pro... | CompilerGym-development | benchmarks/parallelization_load_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.
"""Microbenchmarks for CompilerGym environments.
To run these benchmarks an optimized build using bazel:
$ bazel test -c opt --test_outpu... | CompilerGym-development | benchmarks/bench_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.
#
# Based on the 'util/collect_env.py' script from PyTorch.
# <https://github.com/pytorch/pytorch>
#
# From PyTorch:
#
# Copyright (c) 2016- ... | CompilerGym-development | build_tools/collect_env.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.
"""Configuration for building an action space from a list of LLVM passes."""
from common import Pass
# A set of headers that must be included ... | CompilerGym-development | build_tools/llvm/legacy_pass_manager/config.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 typing import NamedTuple, Optional
class Pass(NamedTuple):
"""The declaration of an LLVM pass."""
# The name of the pass, e.g. ... | CompilerGym-development | build_tools/llvm/legacy_pass_manager/common.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.
"""Filter the list of LLVM passes to use as an action space.
This scripts reads a list of passes from stdin and for each, calls
config.include... | CompilerGym-development | build_tools/llvm/legacy_pass_manager/filter_action_space.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.
"""Generate specifications for the LLVM service capabilities.
Usage: make_specs.py <service_binary> <output_path>.
"""
import signal
# TODO: ... | CompilerGym-development | build_tools/llvm/legacy_pass_manager/make_specs.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.
"""Build generated files from a list of passes.
This script reads from stdin a list of passes and generates files so that these
passes can be ... | CompilerGym-development | build_tools/llvm/legacy_pass_manager/make_action_space_genfiles.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.
"""Extract a list of passes form the LLVM source tree.
Usage:
$ python extract_passes_from_llvm_source_tree.py /path/to/llvm-project/llvm... | CompilerGym-development | build_tools/llvm/legacy_pass_manager/extract_passes_from_llvm_source_tree.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.
"""This module defines the validation result tuple."""
import itertools
import re
from collections import Counter
from typing import Iterable, ... | CompilerGym-development | compiler_gym/validation_result.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.errors
# Deprecated since v0.2.4.
# This type is for backwards compatibility that will be removed in a future release.
# ... | CompilerGym-development | compiler_gym/validation_error.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 sys
from argparse import ArgumentParser
def make_config(argv):
parser = ArgumentParser()
parser.add_arg... | CompilerGym-development | compiler_gym/make_config.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.
"""CompilerGym is a set of compiler optimization environments for reinforcement learning.
After importing this module, the :class:`CompilerGym... | CompilerGym-development | compiler_gym/__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.
"""Simple parallelized random search."""
import json
import os
from multiprocessing import cpu_count
from pathlib import Path
from threading im... | CompilerGym-development | compiler_gym/random_search.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.
"""Validate environment states."""
import random
from concurrent.futures import as_completed
from typing import Callable, Iterable, Optional
f... | CompilerGym-development | compiler_gym/validate.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.
"""This module defines a class to represent a compiler environment state."""
import csv
import re
import sys
from io import StringIO
from typin... | CompilerGym-development | compiler_gym/compiler_env_state.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.
"""This module implements a wrapper that logs state transitions to an sqlite
database.
"""
import logging
import pickle
import sqlite3
import z... | CompilerGym-development | compiler_gym/wrappers/sqlite_logger.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.
"""This module implements fork wrappers."""
from typing import List
from compiler_gym.envs import CompilerEnv
from compiler_gym.wrappers impor... | CompilerGym-development | compiler_gym/wrappers/fork.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 itertools import cycle
from typing import Callable, Iterable, Optional, Union
import numpy as np
from compiler_gym.datasets import Bench... | CompilerGym-development | compiler_gym/wrappers/datasets.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.
"""The :code:`compiler_gym.wrappers` module provides a set of classes that can
be used to transform an environment in a modular way.
For examp... | CompilerGym-development | compiler_gym/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.
import warnings
from abc import ABC, abstractmethod
from collections.abc import Iterable as IterableType
from typing import Any, Iterable, List... | CompilerGym-development | compiler_gym/wrappers/core.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 collections.abc import Iterable as IterableType
from typing import Dict, Iterable, List, Optional, Union
from gym import Space
from comp... | CompilerGym-development | compiler_gym/wrappers/commandline.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.
"""Wrapper classes for the LLVM environments."""
from typing import Callable, Iterable
import numpy as np
from compiler_gym.envs.llvm import ... | CompilerGym-development | compiler_gym/wrappers/llvm.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 typing import Iterable, Optional
from compiler_gym.envs import CompilerEnv
from compiler_gym.util.gym_type_hints import ActionType
from c... | CompilerGym-development | compiler_gym/wrappers/time_limit.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 collections.abc import Mapping
from copy import deepcopy
from math import factorial
from numbers import Integral
from typing import Iterab... | CompilerGym-development | compiler_gym/wrappers/mlir.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.
"""This module implements a wrapper that counts calls to operations.
"""
from typing import Dict
from compiler_gym.envs import CompilerEnv
fro... | CompilerGym-development | compiler_gym/wrappers/counter.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 typing import List
from compiler_gym.envs import CompilerEnv
from compiler_gym.util.gym_type_hints import ActionType
from compiler_gym.wr... | CompilerGym-development | compiler_gym/wrappers/validation.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 typing import List
import gym
from gym.envs.registration import register as gym_register
# A list of gym environment names defined by Co... | CompilerGym-development | compiler_gym/util/registration.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 enum import Enum
from typing import Any, Dict, List, Optional, Tuple, TypeVar, Union
# A JSON dictionary.
JsonDictType = Dict[str, Any]
... | CompilerGym-development | compiler_gym/util/gym_type_hints.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 logging as logging_
import sys
from typing import Optional
def init_logging(level: int = logging_.INFO, logger: Optional[logging_.Logg... | CompilerGym-development | compiler_gym/util/logging.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 collections import deque
from typing import Iterable
def truncate(
string: str,
max_line_len: int = 60,
max_lines: int = 1,
... | CompilerGym-development | compiler_gym/util/truncate.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 csv
from io import StringIO
from typing import Any, Iterable, Optional
from tabulate import tabulate as tabulate_lib
def tabulate(
... | CompilerGym-development | compiler_gym/util/tabulate.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 concurrent.futures import ThreadPoolExecutor
from multiprocessing import cpu_count
from threading import Lock
_executor_lock = Lock()
_ex... | CompilerGym-development | compiler_gym/util/thread_pool.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.
"""Module for resolving a runfiles path."""
import os
from datetime import datetime
from getpass import getuser
from pathlib import Path
from t... | CompilerGym-development | compiler_gym/util/runfiles_path.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 time import time
from typing import Callable, Optional
from absl.logging import skip_log_prefix
def humanize_duration(seconds: float) -... | CompilerGym-development | compiler_gym/util/timer.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 hashlib
import logging
from time import sleep
from typing import List, Optional, Union
import fasteners
import requests
import compile... | CompilerGym-development | compiler_gym/util/download.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.
"""Utilities for working with the filesystem."""
import os
import tempfile
from contextlib import contextmanager
from pathlib import Path
from ... | CompilerGym-development | compiler_gym/util/filesystem.py |
CompilerGym-development | compiler_gym/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.
"""This module defines utilities for minimizing trajectories.
A trajectory is the sequence of actions applied to an environment. The goal of
t... | CompilerGym-development | compiler_gym/util/minimize_trajectory.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.
"""A context manager to set a temporary working directory."""
import os
import tempfile
from contextlib import contextmanager
from pathlib impo... | CompilerGym-development | compiler_gym/util/temporary_working_directory.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.
"""Utilities for parallelization / threading / concurrency."""
from itertools import tee
from threading import Lock
from typing import Any, Ite... | CompilerGym-development | compiler_gym/util/parallelization.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 numbers import Integral
from typing import List
import numpy as np
def convert_number_to_permutation(
n: Integral, permutation_size... | CompilerGym-development | compiler_gym/util/permutation.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 shlex
import sys
from typing import Any, Iterable
class ShellFormatCodes:
"""Shell escape codes for pretty-printing."""
PURPL... | CompilerGym-development | compiler_gym/util/shell_format.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
def geometric_mean(array_like):
"""Zero-length-safe geometric mean."""
values = np.asarray(array_like)
if not ... | CompilerGym-development | compiler_gym/util/statistics.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 subprocess
import sys
from contextlib import contextmanager
from signal import Signals
from subprocess import Popen as _Popen
from typi... | CompilerGym-development | compiler_gym/util/commands.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 logging
import multiprocessing
from collections import deque
from contextlib import contextmanager
from enum import Enum
from itertools ... | CompilerGym-development | compiler_gym/util/executor.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.
"""This module contains debugging helpers."""
import logging
import os
# Map for translating between COMPILER_GYM_DEBUG levels to python loggi... | CompilerGym-development | compiler_gym/util/debug_util.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.