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.
import random
import warnings
import gym
import numpy as np
import pytest
import torch
from flaky import flaky
from ray.rllib.agents.ppo impor... | CompilerGym-development | tests/mlir/rllib_ppo_smoke_test.py |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the LICENSE file
# in the root directory of this source tree.
#
# tests/**/__init__.py files are needed for pytest Python path resolution. See:
# https://docs.pytest.org/en/latest/explanation/pythonpath.ht... | CompilerGym-development | tests/mlir/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.
"""Tests for the matmul dataset."""
import re
from copy import deepcopy
from itertools import islice
from pathlib import Path
import gym
impor... | CompilerGym-development | tests/mlir/datasets/matmul_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.
"""Utilities for random testing."""
import random
from time import time
from typing import List, Tuple
from compiler_gym.envs import CompilerE... | CompilerGym-development | tests/pytest_plugins/random_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.
#
# tests/**/__init__.py files are needed for pytest Python path resolution. See:
# https://docs.pytest.org/en/latest/explanation/pythonpath.ht... | CompilerGym-development | tests/pytest_plugins/__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.
"""Pytest fixtures for the LLVM CompilerGym environments."""
import os
from pathlib import Path
from typing import Iterable, List
import gym
i... | CompilerGym-development | tests/pytest_plugins/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.
"""Pytest fixtures for CompilerGym tests."""
import os
import sys
import tempfile
from pathlib import Path
from typing import List
import dock... | CompilerGym-development | tests/pytest_plugins/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.
"""Pytest fixtures for the GCC CompilerGym environments."""
import subprocess
from functools import lru_cache
from typing import Iterable
imp... | CompilerGym-development | tests/pytest_plugins/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.
"""Pytest fixtures for the MLIR CompilerGym environments."""
from pathlib import Path
from typing import Iterable
import gym
import pytest
fr... | CompilerGym-development | tests/pytest_plugins/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.
#
# tests/**/__init__.py files are needed for pytest Python path resolution. See:
# https://docs.pytest.org/en/latest/explanation/pythonpath.ht... | CompilerGym-development | tests/third_party/__init__.py |
# Adapted from David Malcolm's gcc invocation library.
#
# 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 Softwar... | CompilerGym-development | tests/third_party/gccinvocation/gccinvocation_test.py |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the LICENSE file
# in the root directory of this source tree.
#
# tests/**/__init__.py files are needed for pytest Python path resolution. See:
# https://docs.pytest.org/en/latest/explanation/pythonpath.ht... | CompilerGym-development | tests/third_party/gccinvocation/__init__.py |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""Unit tests for compiler_gym/service/service_cache.py."""
from compiler_gym.service.service_cache import ServiceCache
from tests.test_main im... | CompilerGym-development | tests/service/service_cache_test.py |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""Unit tests for //compiler_gym/service:connection."""
import gym
import pytest
import compiler_gym.envs # noqa Register LLVM environments.
... | CompilerGym-development | tests/service/connection_test.py |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the LICENSE file
# in the root directory of this source tree.
#
# tests/**/__init__.py files are needed for pytest Python path resolution. See:
# https://docs.pytest.org/en/latest/explanation/pythonpath.ht... | CompilerGym-development | tests/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.
"""Unit tests for //compiler_gym:validate."""
from collections.abc import Collection, Mapping
import google.protobuf.any_pb2 as any_pb2
import... | CompilerGym-development | tests/service/proto/py_converters_test.py |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the LICENSE file
# in the root directory of this source tree.
#
# tests/**/__init__.py files are needed for pytest Python path resolution. See:
# https://docs.pytest.org/en/latest/explanation/pythonpath.ht... | CompilerGym-development | tests/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.
#
# tests/**/__init__.py files are needed for pytest Python path resolution. See:
# https://docs.pytest.org/en/latest/explanation/pythonpath.ht... | CompilerGym-development | tests/service/runtime/__init__.py |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""Unit tests for //compiler_gym/service/runtime:benchmark_cache."""
import pytest
from compiler_gym.service.proto import Benchmark, File
fro... | CompilerGym-development | tests/service/runtime/benchmark_cache_test.py |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the LICENSE file
# in the root directory of this source tree.
#
# tests/**/__init__.py files are needed for pytest Python path resolution. See:
# https://docs.pytest.org/en/latest/explanation/pythonpath.ht... | CompilerGym-development | tests/views/__init__.py |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""Unit tests for //compiler_gym/views."""
import pytest
from compiler_gym.views import RewardView
from tests.test_main import main
class Mo... | CompilerGym-development | tests/views/reward_test.py |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""Unit tests for //compiler_gym/views."""
import numpy as np
import pytest
from compiler_gym.errors import ServiceError
from compiler_gym.ser... | CompilerGym-development | tests/views/observation_test.py |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""Evaluate tabular_q policy for leaderboard."""
import os
import sys
from typing import Dict
from absl import app, flags
from compiler_gym.e... | CompilerGym-development | leaderboard/llvm_instcount/tabular_q/tabular_q_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.
"""Tests for //leaderboard/llvm_instcount/tabular_q_eval."""
import pytest
from absl import flags
from compiler_gym.leaderboard.llvm_instcount... | CompilerGym-development | leaderboard/llvm_instcount/tabular_q/tabular_q_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.
"""An implementation of a random search policy for the LLVM codesize task.
The search is the same as the included compiler_gym.bin.random_sear... | CompilerGym-development | leaderboard/llvm_instcount/random_search/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.
"""Tests for //leaderboard/llvm_instcount/random_search."""
import pytest
from leaderboard.llvm_instcount.random_search.random_search import (... | CompilerGym-development | leaderboard/llvm_instcount/random_search/random_search_test.py |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""Tests for //leaderboard/llvm_instcount/e_greedy."""
import sys
from concurrent.futures import ThreadPoolExecutor
import pytest
from absl im... | CompilerGym-development | leaderboard/llvm_instcount/e_greedy/e_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.
"""ϵ-greedy policy for LLVM codesize."""
import logging
import random
from concurrent.futures import ThreadPoolExecutor, as_completed
from typi... | CompilerGym-development | leaderboard/llvm_instcount/e_greedy/e_greedy.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 script to auto-populate RST files from the CompilerGym header files.
Usage:
$ python generate_cc_rst.py
"""... | CompilerGym-development | docs/generate_cc_rst.py |
# Copyright (c) Facebook, Inc. and 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 file for the Sphinx documentation builder.
# -- Path setup --------------------------------------------------------------
#... | CompilerGym-development | docs/source/conf.py |
# Copyright (c) Facebook, Inc. and 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 API and web frontend.
This exposes an API with two operations:
1. /api/v4/describe
Describe the CompilerGym inte... | CompilerGym-development | www/www.py |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""Unit tests for //compiler_gym/bin:random_walk."""
import re
from absl.flags import FLAGS
from random_walk import run_random_walk
import co... | CompilerGym-development | examples/random_walk_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 explore
def test_run_explore_smoke_test(capsys):
explore.main(
[
"explore",
"--env=llvm-ic-v0",
... | CompilerGym-development | examples/explore_test.py |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""Tests for //compiler_gym/bin:actor_critic."""
import sys
from absl import flags
from actor_critic import main
from compiler_gym.util.captu... | CompilerGym-development | examples/actor_critic_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.
"""Simple compiler gym tabular q learning example.
Usage: python tabular_q.py --benchmark=<benchmark>
Using selected features from Autophase ... | CompilerGym-development | examples/tabular_q.py |
# Copyright (c) Facebook, Inc. and 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 PT compiler gym actor-critic RL example.
Usage: python actor_critic.py
Use --help to list the configurable options.
The objective ... | CompilerGym-development | examples/actor_critic.py |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""Unit tests for //compiler_gym/bin:brute_force."""
import tempfile
from pathlib import Path
import gym
from brute_force import run_brute_for... | CompilerGym-development | examples/brute_force_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.
"""Sweep the inner loop size of CUDA loop nests."""
import logging
from itertools import product
from pathlib import Path
from typing import Li... | CompilerGym-development | examples/loop_tool_sweep.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 distutils.util
import setuptools
with open("../VERSION") as f:
version = f.read().strip()
with open("req... | CompilerGym-development | examples/setup.py |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""Tests for //compiler_gym/bin:tabular_q."""
from absl import flags
from tabular_q import main
from compiler_gym.util.capture_output import c... | CompilerGym-development | examples/tabular_q_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.
"""Run a parallelized brute force of an action space.
This script enumerates all possible combinations of actions up to a finite
length and ev... | CompilerGym-development | examples/brute_force.py |
# Copyright (c) Facebook, Inc. and 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 runs microbenchmarks of CompilerGym environment operations.
To collect new measurements, run one of the following commands:
... | CompilerGym-development | examples/op_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.
"""Run a parallelized exhaustive search of an action space.
All possible combinations of actions up to a finite limit are
evaluated, but parti... | CompilerGym-development | examples/explore.py |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""Perform a random walk of the action space of a CompilerGym environment.
Example usage:
# Run a random walk on cBench example program u... | CompilerGym-development | examples/random_walk.py |
# Copyright (c) Facebook, Inc. and 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 unrolling CompilerGym service example."""
import subprocess
from pathlib import Path
import gym
import numpy as np
import pyt... | CompilerGym-development | examples/example_unrolling_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 unrolling CompilerGym service example."""
import os
import subprocess
import sys
from getpass import getuser
from pathlib impo... | CompilerGym-development | examples/example_unrolling_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.
"""Smoke test for examples/example_unrolling_service/example_without_bazel.py"""
from example_unrolling_service.example_without_bazel import ma... | CompilerGym-development | examples/example_unrolling_service/example_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."""
import os
import subprocess
from pathlib import Path
from typing import I... | CompilerGym-development | examples/example_unrolling_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 script demonstrates how the Python example service without needing
to use the bazel build system.
Prerequisite:
# In the repo's IN... | CompilerGym-development | examples/example_unrolling_service/example_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_unrolling_service/example.py |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
def extract_statistics_from_ir(ir: str):
stats = {"control_flow": 0, "arithmetic": 0, "memory": 0}
for line in ir.splitlines():
... | CompilerGym-development | examples/example_unrolling_service/service_py/utils.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
import os
import shutil
import subprocess
from pathli... | CompilerGym-development | examples/example_unrolling_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.
"""Tests for the unrolling CompilerGym service example."""
import subprocess
from pathlib import Path
import gym
import numpy as np
import pyt... | CompilerGym-development | examples/loop_optimizations_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 loop optimizations environment example."""
import os
import subprocess
import sys
from getpass import getuser
from pathlib imp... | CompilerGym-development | examples/loop_optimizations_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.
"""Smoke test for examples/loop_optimizations_service/example_without_bazel.py"""
from flaky import flaky
from loop_optimizations_service.examp... | CompilerGym-development | examples/loop_optimizations_service/example_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 registers the Loop Optimizations CompilerGym environment """
import os
import subprocess
from pathlib import Path
from typing im... | CompilerGym-development | examples/loop_optimizations_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 script uses the loop optimizations service without needing
to use the bazel build system.
Prerequisite:
# In the repo's INSTALL.md... | CompilerGym-development | examples/loop_optimizations_service/example_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.
import compiler_gym
import examples.loop_optimizations_service as loop_optimizations_service # noqa Register environments.
with compiler_gym.... | CompilerGym-development | examples/loop_optimizations_service/example.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
import os
import shutil
import subprocess
from pathlib... | CompilerGym-development | examples/loop_optimizations_service/service_py/loops_opt_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
from enum import Enum
from pathlib import Path
from threading import Lock
from typing import Union
import numpy as np
from llvm... | CompilerGym-development | examples/llvm_autotuning/optimization_target.py |
# Copyright (c) Facebook, Inc. and 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_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.
import json
import logging
from pathlib import Path
from typing import Dict, Iterable, List
import gym
import pandas as pd
import yaml
from ll... | CompilerGym-development | examples/llvm_autotuning/experiment.py |
# Copyright (c) Facebook, Inc. and 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 llvm_autotuning.experiment import Experiment
from omegaconf import DictConfig, OmegaConf
from pydantic ... | CompilerGym-development | examples/llvm_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 logging
from compiler_gym.wrappers import CompilerEnvWrapper
logger = logging.getLogger(__name__)
# TODO(github.com/facebookresearch... | CompilerGym-development | examples/llvm_autotuning/just_keep_going_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 sys
from pathlib import Path
from typing import List
import pandas as pd
from llvm_autotuning.experiment import Experiment
from pydanti... | CompilerGym-development | examples/llvm_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.
from itertools import islice
from typing import Iterable, List, Union
from pydantic import BaseModel, Field, root_validator, validator
from c... | CompilerGym-development | examples/llvm_autotuning/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.
"""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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.