README.md
1# Tensorflow C SavedModel API
2
3## Overview
4
5These are the new experimental C SavedModel APIs for loading and running
6SavedModels in a TF2-idiomatic fashion. See
7[RFC 207](https://github.com/tensorflow/community/pull/207) for additional
8context.
9
10The directory structure is as follows:
11
12```none
13saved_model/
14
15 public/
16
17 internal/
18
19 core/
20
21```
22
23## saved_model/public
24
25`saved_model/public` is intended to house *only the public headers* of the
26SavedModel C API.
27
28These headers:
29
301. declare opaque C types (like `TF_SavedModel`),
31
322. declare the functions that operate on these types (like `TF_LoadSavedModel`).
33
34Once they leave experimental, these APIs should be considered stable for use
35by external clients.
36
37These headers are in a separate directory to make it obvious to clients which
38headers they should depend on, and which headers are implementation details.
39Separating these public headers by directory also allow future programmatic
40checks to ensure that TF public headers only `#include` other public TF headers.
41
42## saved_model/internal
43
44`saved_model/internal` is the "glue" between the C API and the internal C++
45implementation.
46
47Its role is to:
48
491. implement the C API functions declared in `saved_model/public`
50
512. define the C API types declared in `saved_model/public`
52
53The files fulfilling 1. are named `*.cc` (eg: `concrete_function.cc`), while
54the files fulfilling 2. are `*type.h` (eg: `concrete_function_type.h`).
55
56The headers exposing the internal implementation of the opaque C types are only
57visible to other implementors of the C API. This is similar to how other
58TF C API implementations use `tf_status_internal.h` (to extract the underlying
59`tensorflow::Status`). All other targets in this directory are private.
60
61## saved_model/core
62
63`saved_model/core` contains pure C++ "Classes" underlying the C API types
64in `saved_model/public/`. These are implementation
65details subject to change, and have limited visibility to implementors only.
66This is the bottom-most layer of the `C++ -> C -> C++` sandwich.
67