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. 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
# Copyright (c) Facebook, Inc. and 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 Dict as DictType from typing import List, Union from gym.spaces import Dict as GymDict from gym.spaces import Space class...
CompilerGym-development
compiler_gym/spaces/dict.py
# Copyright (c) Facebook, Inc. and 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, Optional, Tuple, Union import numpy as np import compiler_gym from compiler_gym.spaces.scalar import Scalar from com...
CompilerGym-development
compiler_gym/spaces/reward.py
# Copyright (c) Facebook, Inc. and 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, Optional from gym.spaces import Space from compiler_gym.util.gym_type_hints import ActionType class ActionSpace(Sp...
CompilerGym-development
compiler_gym/spaces/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. from typing import Callable, Iterable, List, Optional from compiler_gym.errors import BenchmarkInitError, ServiceError from compiler_gym.spac...
CompilerGym-development
compiler_gym/spaces/runtime_reward.py
# Copyright (c) Facebook, Inc. and 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 package contains modules that can be used for preparing leaderboard submissions. We provide `leaderboards <https://github.com/facebook...
CompilerGym-development
compiler_gym/leaderboard/__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. """LLVM is a popular open source compiler used widely in industry and research. The :code:`llvm-ic-v0` environment exposes LLVM's optimizing pa...
CompilerGym-development
compiler_gym/leaderboard/llvm_instcount.py
# Protoxygen, from https://github.com/lisroach/Protoxygen ## # Doxygen filter for Google Protocol Buffers .proto files. # This script converts .proto files into C++ style ones # and prints the output to standard output. # # version 0.6-beta # # How to enable this filter in Doxygen: # 1. Generate Doxygen configuration...
CompilerGym-development
compiler_gym/third_party/proto2cpp.py
"""This module defines an API for processing LLVM-IR with inst2vec.""" import pickle from typing import List import numpy as np from compiler_gym.third_party.inst2vec import inst2vec_preprocess from compiler_gym.util.runfiles_path import runfiles_path _PICKLED_VOCABULARY = runfiles_path( "compiler_gym/third_part...
CompilerGym-development
compiler_gym/third_party/inst2vec/__init__.py
# NCC: Neural Code Comprehension # https://github.com/spcl/ncc # Copyright 2018 ETH Zurich # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted provided that the # following conditions are met: # 1. Redistributions of source code must retain the above...
CompilerGym-development
compiler_gym/third_party/inst2vec/rgx_utils.py
# NCC: Neural Code Comprehension # https://github.com/spcl/ncc # Copyright 2018 ETH Zurich # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted provided that the # following conditions are met: # 1. Redistributions of source code must retain the above...
CompilerGym-development
compiler_gym/third_party/inst2vec/inst2vec_preprocess.py
#!/usr/bin/env python3 # # This script compiles and links the sources for a cBench benchmark into a # single unoptimized LLVM module. # # Usage: # # $ make_cBench_llvm_module.py <in_dir> <outpath> [<cflag>...] # # This compiles the code from <in_dir> and generates an LLVM bitcode module at # the given <outpath>, us...
CompilerGym-development
compiler_gym/third_party/cbench/make_llvm_module.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. AUTOPHASE_FEATURE_NAMES = [ "BBNumArgsHi", "BBNumArgsLo", "onePred", "onePredOneSuc", "onePredTwoSuc", "oneSuccessor",...
CompilerGym-development
compiler_gym/third_party/autophase/__init__.py
# Copyright 2013 David Malcolm <dmalcolm@redhat.com> # Copyright 2013 Red Hat, Inc. # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (...
CompilerGym-development
compiler_gym/third_party/gccinvocation/gccinvocation.py
# Copyright (c) Facebook, Inc. and 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 paths to LLVM binaries and libraries.""" import io import logging import shutil import sys import tarfile from pathlib ...
CompilerGym-development
compiler_gym/third_party/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. """Constants for the InstCount feature space.""" # Generated using: # # $ bazel run //compiler_gym/third_party/llvm:PrintInstCountFeatureN...
CompilerGym-development
compiler_gym/third_party/llvm/instcount.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Test that the DeepDataFlow dataset contains the expected numbers of files.""" import pytest from compiler_gym.util.runfiles_path import run...
CompilerGym-development
compiler_gym/third_party/DeepDataFlow/file_count_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 validation errors.""" from typing import Any, Dict from pydantic import BaseModel class ValidationError(BaseModel): ...
CompilerGym-development
compiler_gym/errors/validation_errors.py
# Copyright (c) Facebook, Inc. and 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.errors.dataset_errors import BenchmarkInitError, DatasetInitError from compiler_gym.errors.download_errors import DownloadFai...
CompilerGym-development
compiler_gym/errors/__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 service related errors.""" class ServiceError(Exception): """Error raised from the service.""" class SessionNotF...
CompilerGym-development
compiler_gym/errors/service_errors.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. class DownloadFailed(IOError): """Error thrown if a download fails.""" class TooManyRequests(DownloadFailed): """Error thrown by HT...
CompilerGym-development
compiler_gym/errors/download_errors.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. class BenchmarkInitError(OSError, ValueError): """Base class for errors raised if a benchmark fails to initialize.""" class DatasetInit...
CompilerGym-development
compiler_gym/errors/dataset_errors.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Contains an implementation of the :class:`CompilerEnv<compiler_gym.envs.CompilerEnv>` interface as a gRPC client service.""" import logging ...
CompilerGym-development
compiler_gym/service/client_service_compiler_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. from compiler_gym.service.compilation_session import CompilationSession from compiler_gym.service.connection import ( CompilerGymServiceCon...
CompilerGym-development
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. """This module contains the logic for connecting to services.""" import logging import os import subprocess import sys from pathlib import Path...
CompilerGym-development
compiler_gym/service/connection.py
# Copyright (c) Facebook, Inc. and 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 pathlib import Path from typing import List, Optional, Tuple from compiler_gym.service.proto import ActionSpace, Benchmark from compiler_...
CompilerGym-development
compiler_gym/service/compilation_session.py
# Copyright (c) Facebook, Inc. and 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 filesystem cache for services.""" import os import random import shutil from datetime import datetime from pathlib imp...
CompilerGym-development
compiler_gym/service/service_cache.py
# Copyright (c) Facebook, Inc. and 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.service.proto.compiler_gym_service_pb2 import ( ActionSpace, AddBenchmarkReply, AddBenchmarkRequest, Benchmar...
CompilerGym-development
compiler_gym/service/proto/__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 contains converters to/from protobuf messages. For example <compiler_gym.servie.proto.ActionSpace>/<compiler_gym.servie.proto.O...
CompilerGym-development
compiler_gym/service/proto/py_converters.py
# Copyright (c) Facebook, Inc. and 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 Dict, Optional import numpy as np from compiler_gym.service.proto import Benchmark MAX_SIZE_IN_BYTES = 512...
CompilerGym-development
compiler_gym/service/runtime/benchmark_cache.py
# Copyright (c) Facebook, Inc. and 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.service.runtime.create_and_run_compiler_gym_service import ( create_and_run_compiler_gym_service, ) __all__ = [ "cr...
CompilerGym-development
compiler_gym/service/runtime/__init__.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 os import sys from concurrent import futures from multiproces...
CompilerGym-development
compiler_gym/service/runtime/create_and_run_compiler_gym_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 logging import traceback from contextlib import contextmanager from pathlib import Path from threading import Lock from typing import Di...
CompilerGym-development
compiler_gym/service/runtime/compiler_gym_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 compiler_gym.envs.loop_tool # noqa from compiler_gym import config from compiler_gym.envs.compiler_env import CompilerEnv from compiler...
CompilerGym-development
compiler_gym/envs/__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 the OpenAI gym interface for compilers.""" from abc import ABC, abstractmethod from typing import Iterable, List, Option...
CompilerGym-development
compiler_gym/envs/compiler_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. """Register the loop_tool environment and reward.""" from pathlib import Path from typing import Iterable from compiler_gym.datasets import Be...
CompilerGym-development
compiler_gym/envs/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. """Define the loop_tool environment.""" import logging import time from functools import reduce from pathlib import Path from typing import Opt...
CompilerGym-development
compiler_gym/envs/loop_tool/service/loop_tool_compilation_session.py
# Copyright (c) Facebook, Inc. and 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 class observation_spaces(Enum): Ir = "Ir" IrSha1 = "IrSha1" Bitcode = "Bitcode" BitcodeFile = "BitcodeF...
CompilerGym-development
compiler_gym/envs/llvm/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. """This module defines reward spaces used by the LLVM environment.""" from typing import List, Optional from compiler_gym.datasets import Benc...
CompilerGym-development
compiler_gym/envs/llvm/llvm_rewards.py
# Copyright (c) Facebook, Inc. and 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 subprocess import tempfile import urllib.parse from compiler_gym.datasets import Benchmark, BenchmarkInitError...
CompilerGym-development
compiler_gym/envs/llvm/benchmark_from_command_line.py
# Copyright (c) Facebook, Inc. and 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.spaces import ActionSpace from compiler_gym.util.gym_type_hints import ActionType class LlvmComman...
CompilerGym-development
compiler_gym/envs/llvm/llvm_command_line.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Register the LLVM environments.""" import sys from itertools import product from compiler_gym.envs.llvm.benchmark_from_command_line import ...
CompilerGym-development
compiler_gym/envs/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. """This module defines a utility function for computing LLVM observations.""" import subprocess from pathlib import Path from typing import Lis...
CompilerGym-development
compiler_gym/envs/llvm/compute_observation.py
# Copyright (c) Facebook, Inc. and 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 utility function for constructing LLVM benchmarks.""" import logging import os import random import subprocess import ...
CompilerGym-development
compiler_gym/envs/llvm/llvm_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. """Extensions to the ClientServiceCompilerEnv environment for LLVM.""" import logging import os import shlex import shutil import subprocess fr...
CompilerGym-development
compiler_gym/envs/llvm/llvm_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. """Utilities for LexedIRTuple derived observation space.""" import subprocess from pathlib import Path from tempfile import NamedTemporaryFile ...
CompilerGym-development
compiler_gym/envs/llvm/lexed_ir.py
# Copyright (c) Facebook, Inc. and 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 enum import io import logging import os import re import shutil import subprocess import sys import tarfile import tempfile from collect...
CompilerGym-development
compiler_gym/envs/llvm/datasets/cbench.py
# Copyright (c) Facebook, Inc. and 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 from concurrent.futures import as_completed from pathlib import Path from typing import Iterable from compiler_gym.datasets ...
CompilerGym-development
compiler_gym/envs/llvm/datasets/chstone.py
# Copyright (c) Facebook, Inc. and 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 from concurrent.futures import as_completed from pathlib import Path from compiler_gym.datasets import Benchmark, TarDataset...
CompilerGym-development
compiler_gym/envs/llvm/datasets/jotaibench.py
# Copyright (c) Facebook, Inc. and 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 subprocess import sys from concurrent.futures import as_completed from pathlib import Path from compiler_gym.d...
CompilerGym-development
compiler_gym/envs/llvm/datasets/poj104.py
# Copyright (c) Facebook, Inc. and 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 subprocess from pathlib import Path from typing import Iterable, List, Optional import numpy as np from compiler_gym.da...
CompilerGym-development
compiler_gym/envs/llvm/datasets/csmith.py
# Copyright (c) Facebook, Inc. and 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 Iterable, Optional from compiler_gym.datasets import Dataset, TarDatasetWithManifest fr...
CompilerGym-development
compiler_gym/envs/llvm/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 subprocess from pathlib import Path from typing import Iterable import numpy as np from compiler_gym.datasets import Benchmark, Datase...
CompilerGym-development
compiler_gym/envs/llvm/datasets/llvm_stress.py
# Copyright (c) Facebook, Inc. and 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 io import logging import os import shutil import subprocess import tarfile from pathlib import Path from threading import Lock from typi...
CompilerGym-development
compiler_gym/envs/llvm/datasets/clgen.py
# Copyright (c) Facebook, Inc. and 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 concurrent.futures import as_completed from pathlib import Path from typing import Optional from compiler_gy...
CompilerGym-development
compiler_gym/envs/llvm/datasets/anghabench.py
# Copyright (c) Facebook, Inc. and 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 demonstrates how to """ from pathlib import Path from compiler_gym.envs.gcc.gcc import Gcc, GccSpec, Option from compiler_gym.e...
CompilerGym-development
compiler_gym/envs/gcc/__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. """A CompilerGym environment for GCC.""" import codecs import json import pickle from pathlib import Path from typing import Any, Dict, List, O...
CompilerGym-development
compiler_gym/envs/gcc/gcc_env.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. """Query a GCC binary for version, optimization and param spaces. The goal of this file is to query the available s...
CompilerGym-development
compiler_gym/envs/gcc/gcc.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """Reward spaces for use in the GCC environments.""" from compiler_gym.spaces import Reward from compiler_gym.views.observation import Observat...
CompilerGym-development
compiler_gym/envs/gcc/gcc_rewards.py
# Copyright (c) Facebook, Inc. and 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 from compiler_gym.datasets import Benchmark, TarDatasetWithManifest from compil...
CompilerGym-development
compiler_gym/envs/gcc/datasets/chstone.py
# Copyright (c) Facebook, Inc. and 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 shutil import subprocess import tempfile from pathlib import Path from threading import Lock from typing import Iterable,...
CompilerGym-development
compiler_gym/envs/gcc/datasets/csmith.py
# Copyright (c) Facebook, Inc. and 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 pathlib import Path from typing import Iterable, List, Optional, Union from compiler_gym.datasets import ...
CompilerGym-development
compiler_gym/envs/gcc/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 sys from pathlib import Path from typing import Optional from compiler_gym.datasets import TarDatasetWithManifest # TODO(github.com/f...
CompilerGym-development
compiler_gym/envs/gcc/datasets/anghabench.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. """A CompilerGym service for GCC.""" import codecs import hashlib import json import logging import os import pickle...
CompilerGym-development
compiler_gym/envs/gcc/service/gcc_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. """Register the MLIR environments.""" from compiler_gym.envs.mlir.mlir_env import MlirEnv from compiler_gym.util.registration import register ...
CompilerGym-development
compiler_gym/envs/mlir/__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 pathlib import Path from typing import Iterable, List, Optional, Union import numpy as np from compiler_gym.datasets import Dataset fro...
CompilerGym-development
compiler_gym/envs/mlir/mlir_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. import logging from pathlib import Path from typing import Iterable, Optional from compiler_gym.datasets import Benchmark, BenchmarkSource, Da...
CompilerGym-development
compiler_gym/envs/mlir/datasets/matmul.py