Build a `DescriptorPool` from the named file or URI. The file or URI must be available to the current TensorFlow environment. The file must contain a serialized `FileDescriptorSet`. See `GetDescriptorPool()` for more information.
| 44 | // The file must contain a serialized `FileDescriptorSet`. See |
| 45 | // `GetDescriptorPool()` for more information. |
| 46 | Status GetDescriptorPoolFromFile( |
| 47 | tensorflow::Env* env, const string& filename, |
| 48 | std::unique_ptr<protobuf::DescriptorPool>* owned_desc_pool) { |
| 49 | Status st = env->FileExists(filename); |
| 50 | if (!st.ok()) { |
| 51 | return st; |
| 52 | } |
| 53 | // Read and parse the FileDescriptorSet. |
| 54 | protobuf::FileDescriptorSet descs; |
| 55 | std::unique_ptr<ReadOnlyMemoryRegion> buf; |
| 56 | st = env->NewReadOnlyMemoryRegionFromFile(filename, &buf); |
| 57 | if (!st.ok()) { |
| 58 | return st; |
| 59 | } |
| 60 | if (!descs.ParseFromArray(buf->data(), buf->length())) { |
| 61 | return errors::InvalidArgument( |
| 62 | "descriptor_source contains invalid FileDescriptorSet: ", filename); |
| 63 | } |
| 64 | return CreatePoolFromSet(descs, owned_desc_pool); |
| 65 | } |
| 66 | |
| 67 | Status GetDescriptorPoolFromBinary( |
| 68 | const string& source, |
no test coverage detected