python_code stringlengths 0 4.04M | repo_name stringlengths 8 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.
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 |
# 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 contextlib
import sys
from io import StringIO
from typing import Iterator
class CapturedOutput:
def __init__(self):
self.s... | CompilerGym-development | compiler_gym/util/capture_output.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 functools
from typing import Any, Callable
def memoized_property(func: Callable[..., Any]) -> Callable[..., Any]:
"""A property de... | CompilerGym-development | compiler_gym/util/decorators.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 consistent way to interpret a user-specified environment from commandline flags."""
import sys
from contextlib import contextmanager
from ... | CompilerGym-development | compiler_gym/util/flags/env_from_flags.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 absl import flags
flags.DEFINE_integer("episode_length", 5, "The number of steps in each episode.")
| CompilerGym-development | compiler_gym/util/flags/episode_length.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 absl import flags
flags.DEFINE_string(
"output_dir",
None,
"The directory to read and write files to.",
)
| CompilerGym-development | compiler_gym/util/flags/output_dir.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 multiprocessing import cpu_count
from absl import flags
flags.DEFINE_integer("nproc", cpu_count(), "The number of parallel processes to ... | CompilerGym-development | compiler_gym/util/flags/nproc.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 absl import flags
flags.DEFINE_float("learning_rate", 0.008, "The learning rate for training.")
| CompilerGym-development | compiler_gym/util/flags/learning_rate.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 absl import flags
flags.DEFINE_integer("seed", 0xCC, "Random state initializer.")
| CompilerGym-development | compiler_gym/util/flags/seed.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 consistent way to interpret a user-specified benchmark from commandline flags."""
from pathlib import Path
from typing import Optional, Un... | CompilerGym-development | compiler_gym/util/flags/benchmark_from_flags.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 absl import flags
flags.DEFINE_integer("episodes", 2000, "The number of episodes to run.")
| CompilerGym-development | compiler_gym/util/flags/episodes.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 program can be used to query and run the CompilerGym services.
Listing available environments
------------------------------
List the... | CompilerGym-development | compiler_gym/bin/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.
"""Run a parallelized random search of an environment's action space.
.. code-block::
$ python -m compiler_gym.bin.random_search --env=<e... | CompilerGym-development | compiler_gym/bin/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.
Example usage:
.. code-block::
$ cat << EOF |
benchmark,reward,walltime,commandline
cbench-v1/cr... | CompilerGym-development | compiler_gym/bin/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.
# Note that the tutorial is extracted from the doc string with the repeated ^
# signs. So, please keep them as they are.
"""Run a CompilerGym e... | CompilerGym-development | compiler_gym/bin/manual_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.
"""Replay the best solution found from a random search.
.. code-block::
$ python -m compiler_gym.bin.random_replay --env=llvm-ic-v0 --out... | CompilerGym-development | compiler_gym/bin/random_replay.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 the logs of a random run."""
import json
from pathlib import Path
import humanize
import numpy as np
from absl import app, flags
... | CompilerGym-development | compiler_gym/bin/random_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.
from concurrent.futures import as_completed
from pathlib import Path
from typing import Callable, Iterable, List, NamedTuple, Optional, Union
... | CompilerGym-development | compiler_gym/datasets/benchmark.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 bz2
import gzip
import io
import logging
import shutil
import tarfile
from threading import Lock
from typing import Iterable, List, Opti... | CompilerGym-development | compiler_gym/datasets/tar_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.
import os
from collections import deque
from pathlib import Path
from typing import Dict, Iterable, List, Optional, Set, TypeVar
import numpy ... | CompilerGym-development | compiler_gym/datasets/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.
"""Manage datasets of benchmarks."""
from compiler_gym.datasets.benchmark import (
Benchmark,
BenchmarkInitError,
BenchmarkSource,
... | CompilerGym-development | compiler_gym/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.
import logging
import os
import re
import shutil
import warnings
from pathlib import Path
from typing import Dict, Iterable, Optional, Union
i... | CompilerGym-development | compiler_gym/datasets/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.
"""This module contains utility code for working with URIs."""
from typing import Dict, List, Union
from urllib.parse import ParseResult, parse... | CompilerGym-development | compiler_gym/datasets/uri.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
from pathlib import Path
from typing import Iterable, List
import numpy as np
from compiler_gym.datasets.dataset import Benchmark, ... | CompilerGym-development | compiler_gym/datasets/files_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.
from collections import Counter
from collections.abc import Collection
from typing import Optional, Tuple
import numpy as np
from gym.spaces ... | CompilerGym-development | compiler_gym/spaces/space_sequence.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 gym.spaces import Space
from gym.spaces import Tuple as GymTuple
class Tuple(GymTuple):
"""A tuple (i.e., p... | CompilerGym-development | compiler_gym/spaces/tuple.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
import numpy as np
from gym.spaces import Box as GymBox
class Box(GymBox):
"""A (possibly unbounde... | CompilerGym-development | compiler_gym/spaces/box.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 Optional, Tuple
import numpy as np
from gym.spaces import Space
from compiler_gym.spaces.common import issubdtype
from com... | CompilerGym-development | compiler_gym/spaces/sequence.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
from typing import Optional
import numpy as np
from gym.spaces import Space
from compiler_gym.spaces.common import issubdtype
... | CompilerGym-development | compiler_gym/spaces/scalar.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 as GymDiscrete
class Discrete(GymDiscrete):
"""A discrete space in :math:`{ 0, 1, \\dots, n-1 }`.
Wr... | CompilerGym-development | compiler_gym/spaces/discrete.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.action_space import ActionSpace
from compiler_gym.spaces.box import Box
from compiler_gym.spaces.commandline import Co... | CompilerGym-development | compiler_gym/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.
from typing import Iterable, List, NamedTuple
from compiler_gym.spaces.named_discrete import NamedDiscrete
class CommandlineFlag(NamedTuple)... | CompilerGym-development | compiler_gym/spaces/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.
from inspect import isclass
from numbers import Integral, Real
import numpy as np
def issubdtype(subtype, supertype):
if isclass(subtype... | CompilerGym-development | compiler_gym/spaces/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.
from numbers import Integral
import numpy as np
from compiler_gym.spaces.scalar import Scalar
from compiler_gym.spaces.sequence import Sequen... | CompilerGym-development | compiler_gym/spaces/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.
from collections import Counter
from collections.abc import Iterable as IterableType
from typing import Iterable, List, Union
from compiler_gy... | CompilerGym-development | compiler_gym/spaces/named_discrete.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.