Skip to content

change: add tflite to Neo-supported frameworks #1364

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/sagemaker/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@

LOGGER = logging.getLogger("sagemaker")

NEO_ALLOWED_FRAMEWORKS = set(["mxnet", "tensorflow", "keras", "pytorch", "onnx", "xgboost"])
NEO_ALLOWED_FRAMEWORKS = set(
["mxnet", "tensorflow", "keras", "pytorch", "onnx", "xgboost", "tflite"]
)

NEO_IMAGE_ACCOUNT = {
"us-west-1": "710691900526",
Expand Down
32 changes: 32 additions & 0 deletions tests/unit/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,22 @@ def test_compile_model_for_edge_device(sagemaker_session, tmpdir):
assert model._is_compiled_model is False


def test_compile_model_for_edge_device_tflite(sagemaker_session, tmpdir):
sagemaker_session.wait_for_compilation_job = Mock(
return_value=DESCRIBE_COMPILATION_JOB_RESPONSE
)
model = DummyFrameworkModel(sagemaker_session, source_dir=str(tmpdir))
model.compile(
target_instance_family="deeplens",
input_shape={"data": [1, 3, 1024, 1024]},
output_path="s3://output",
role="role",
framework="tflite",
job_name="tflite-compile-model",
)
assert model._is_compiled_model is False


def test_compile_model_for_cloud(sagemaker_session, tmpdir):
sagemaker_session.wait_for_compilation_job = Mock(
return_value=DESCRIBE_COMPILATION_JOB_RESPONSE
Expand All @@ -576,6 +592,22 @@ def test_compile_model_for_cloud(sagemaker_session, tmpdir):
assert model._is_compiled_model is True


def test_compile_model_for_cloud_tflite(sagemaker_session, tmpdir):
sagemaker_session.wait_for_compilation_job = Mock(
return_value=DESCRIBE_COMPILATION_JOB_RESPONSE
)
model = DummyFrameworkModel(sagemaker_session, source_dir=str(tmpdir))
model.compile(
target_instance_family="ml_c4",
input_shape={"data": [1, 3, 1024, 1024]},
output_path="s3://output",
role="role",
framework="tflite",
job_name="tflite-compile-model",
)
assert model._is_compiled_model is True


@patch("sagemaker.session.Session")
@patch("sagemaker.fw_utils.tar_and_upload_dir", MagicMock())
def test_compile_creates_session(session):
Expand Down