This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ Example script for defining and using custom models in AutoGluon Tabular """ | |
| from autogluon.core.utils import infer_problem_type | |
| from autogluon.tabular import TabularDataset, TabularPredictor | |
| from autogluon.tabular.configs.hyperparameter_configs import get_hyperparameter_config | |
| from autogluon.core.data import LabelCleaner | |
| from autogluon.core.models import AbstractModel | |
| from skl2onnx import convert_sklearn, get_model_alias | |
| from skl2onnx.common._registration import get_shape_calculator, get_converter |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Benchmark inference time of pretrained AutoGluon Tabular models | |
| """ | |
| set -e | |
| DEV_BRANCH=reset-thread-2 | |
| git checkout master | |
| /opt/conda/envs/py38/bin/python3 example_dev_tabular.py --sample=1 | |
| /opt/conda/envs/py38/bin/python3 example_dev_tabular.py | |
| git checkout $DEV_BRANCH | |
| /opt/conda/envs/py38/bin/python3 example_dev_tabular.py --sample=1 | |
| /opt/conda/envs/py38/bin/python3 example_dev_tabular.py |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| ProgName=$(basename $0) | |
| instance_ids=i-05806fb95d65fffff | |
| region=us-west-2 | |
| sub_help(){ | |
| echo "Usage: $ProgName <subcommand> [options]\n" | |
| echo "Subcommands:" | |
| echo " start Start mldev instances" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| apt update | |
| apt install -y emacs-nox aptitude screen xcscope-el gdb nano || echo 0 && echo "Success" | |
| python3 -m pip install git-remote-codecommit opennmt-tf==1.25.1 | |
| cat << EOF > ~/.gdbinit | |
| set print thread-events off | |
| define hook-run | |
| catch throw | |
| end | |
| define hook-quit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| import time | |
| import math | |
| def burn_cpu(): | |
| a = np.random.rand(1024, 1024) | |
| b = np.random.rand(1024, 1024) | |
| tic = time.time() | |
| c = np.dot(a, b) | |
| toc = time.time() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import boto3, json | |
| question = """ | |
| How are you today? | |
| """ | |
| def main(): | |
| session = boto3.Session() | |
| bedrock = session.client(service_name='bedrock-runtime', region_name="us-west-2") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from typing import Any, Dict, List, Optional, Tuple, Type | |
| import torch | |
| import torch_xla.core.xla_model as xm | |
| import torch_xla.experimental.custom_kernel # Required to register custom ops. | |
| class PallasAttentionBackend: | |
| @torch.compile(backend="openxla") | |
| @staticmethod | |
| def copy_blocks( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import torch | |
| import torch_xla.core.xla_model as xm | |
| @torch.compile(backend="openxla") | |
| def toy_example(a, b): | |
| x = a / (torch.abs(a) + 1) | |
| if b.sum() < 0: | |
| b = b * -1 | |
| return x * b |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import time | |
| import torch | |
| import torch_xla.core.xla_model as xm | |
| N = 128 | |
| n_iters = 100 | |
| def main(): | |
| device = xm.xla_device() | |
| src = torch.arange(1, 2*N+1).reshape((2, N)).to(device=device) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import torch | |
| import os | |
| import depyf | |
| import torch_xla.core.xla_model as xm | |
| os.environ["NEURON_CC_FLAGS"]= " --model-type=transformer -O1 " | |
| os.environ["NEURON_COMPILE_CACHE_URL"] = os.path.join(os.getcwd(), "_compile_cache") | |
| @torch.compiler.allow_in_graph | |
| def write_to_kv_cache( |