|
| 1 | +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"). You |
| 4 | +# may not use this file except in compliance with the License. A copy of |
| 5 | +# the License is located at |
| 6 | +# |
| 7 | +# http://aws.amazon.com/apache2.0/ |
| 8 | +# |
| 9 | +# or in the "license" file accompanying this file. This file is |
| 10 | +# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF |
| 11 | +# ANY KIND, either express or implied. See the License for the specific |
| 12 | +# language governing permissions and limitations under the License. |
| 13 | +from __future__ import absolute_import |
| 14 | + |
| 15 | +from sagemaker import image_uris |
| 16 | +from tests.unit.sagemaker.image_uris import expected_uris |
| 17 | + |
| 18 | +GRAVITON_ALGOS = ("tensorflow", "pytotch") |
| 19 | +GRAVITON_INSTANCE_TYPES = [ |
| 20 | + "ml.c6g.4xlarge", |
| 21 | + "ml.t4g.2xlarge", |
| 22 | + "ml.r6g.2xlarge", |
| 23 | + "ml.m6g.4xlarge", |
| 24 | +] |
| 25 | + |
| 26 | +ACCOUNTS = { |
| 27 | + "af-south-1": "626614931356", |
| 28 | + "ap-east-1": "871362719292", |
| 29 | + "ap-northeast-1": "763104351884", |
| 30 | + "ap-northeast-2": "763104351884", |
| 31 | + "ap-northeast-3": "364406365360", |
| 32 | + "ap-south-1": "763104351884", |
| 33 | + "ap-southeast-1": "763104351884", |
| 34 | + "ap-southeast-2": "763104351884", |
| 35 | + "ap-southeast-3": "907027046896", |
| 36 | + "ca-central-1": "763104351884", |
| 37 | + "cn-north-1": "727897471807", |
| 38 | + "cn-northwest-1": "727897471807", |
| 39 | + "eu-central-1": "763104351884", |
| 40 | + "eu-north-1": "763104351884", |
| 41 | + "eu-west-1": "763104351884", |
| 42 | + "eu-west-2": "763104351884", |
| 43 | + "eu-west-3": "763104351884", |
| 44 | + "eu-south-1": "692866216735", |
| 45 | + "me-south-1": "217643126080", |
| 46 | + "sa-east-1": "763104351884", |
| 47 | + "us-east-1": "763104351884", |
| 48 | + "us-east-2": "763104351884", |
| 49 | + "us-gov-west-1": "442386744353", |
| 50 | + "us-iso-east-1": "886529160074", |
| 51 | + "us-west-1": "763104351884", |
| 52 | + "us-west-2": "763104351884", |
| 53 | +} |
| 54 | + |
| 55 | +GRAVITON_REGIONS = ACCOUNTS.keys() |
| 56 | + |
| 57 | + |
| 58 | +def _test_graviton_framework_uris(framework, version): |
| 59 | + for region in GRAVITON_REGIONS: |
| 60 | + for instance_type in GRAVITON_INSTANCE_TYPES: |
| 61 | + uri = image_uris.retrieve( |
| 62 | + framework, region, instance_type=instance_type, version=version |
| 63 | + ) |
| 64 | + expected = _expected_graviton_framework_uri(framework, version, region=region) |
| 65 | + assert expected == uri |
| 66 | + |
| 67 | + |
| 68 | +def test_graviton_tensorflow(graviton_tensorflow_version): |
| 69 | + _test_graviton_framework_uris("tensorflow", graviton_tensorflow_version) |
| 70 | + |
| 71 | + |
| 72 | +def test_graviton_pytorch(graviton_pytorch_version): |
| 73 | + _test_graviton_framework_uris("pytorch", graviton_pytorch_version) |
| 74 | + |
| 75 | + |
| 76 | +def _expected_graviton_framework_uri(framework, version, region): |
| 77 | + return expected_uris.graviton_framework_uri( |
| 78 | + "{}-inference-graviton".format(framework), |
| 79 | + fw_version=version, |
| 80 | + py_version="py38", |
| 81 | + account=ACCOUNTS[region], |
| 82 | + region=region, |
| 83 | + ) |
0 commit comments