Skip to content
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

[rel-1.8.1][Objective-C API] Cherry-pick Objective-C API updates #8197

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
[Objective-C API] Add support for documentation generation (#7999)
Adding support for generating API documentation with the Jazzy tool.
It's a manual process now, but we can eventually make it a part of the release pipeline.
  • Loading branch information
edgchen1 committed Jun 30, 2021
commit 3cd1c54c55e8171f461fe931430e7196c7a095a5
5 changes: 5 additions & 0 deletions objectivec/docs/docs.readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# ONNX Runtime Objective-C API

ONNX Runtime provides an Objective-C API.

It can be used from Objective-C/C++ or Swift with a bridging header.
13 changes: 13 additions & 0 deletions objectivec/docs/jazzy_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module: ONNX Runtime Objective-C API
author: ONNX Runtime Authors
author_url: https://www.onnxruntime.ai
github_url: https://github.com/microsoft/onnxruntime

objc: true
umbrella_header: ../include/onnxruntime.h
framework_root: ..

readme: ./docs.readme.md

hide_documentation_coverage: true
undocumented_text: ""
17 changes: 17 additions & 0 deletions objectivec/docs/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Objective-C API Documentation

The API should be documented with comments in the [public header files](../include).

## Documentation Generation

The [Jazzy](https://github.com/realm/jazzy) tool is used to generate documentation from the code.

For example, to generate documentation for a release version, from the repo root, run:

```bash
jazzy --config objectivec/docs/jazzy_config.yaml --output <output directory> --module-version $(cat VERSION_NUMBER)
```

The generated documentation website files will be in `<output directory>`.

[docs.readme.md](./docs.readme.md) contains content for the main page of the generated documentation website.
2 changes: 1 addition & 1 deletion objectivec/include/ort_coreml_execution_provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ BOOL ORTIsCoreMLExecutionProviderAvailable(void);
* decreasing priority.
*
* @param options The CoreML execution provider configuration options.
* @param[out] error Optional error information set if an error occurs.
* @param error Optional error information set if an error occurs.
* @return Whether the provider was enabled successfully.
*/
- (BOOL)appendCoreMLExecutionProviderWithOptions:(ORTCoreMLExecutionProviderOptions*)options
Expand Down
2 changes: 1 addition & 1 deletion objectivec/include/ort_env.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ NS_ASSUME_NONNULL_BEGIN
* Creates an ORT Environment.
*
* @param loggingLevel The environment logging level.
* @param[out] error Optional error information set if an error occurs.
* @param error Optional error information set if an error occurs.
* @return The instance, or nil if an error occurs.
*/
- (nullable instancetype)initWithLoggingLevel:(ORTLoggingLevel)loggingLevel
Expand Down
34 changes: 17 additions & 17 deletions objectivec/include/ort_session.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ NS_ASSUME_NONNULL_BEGIN
* @param env The ORT Environment instance.
* @param path The path to the ONNX model.
* @param sessionOptions Optional session configuration options.
* @param[out] error Optional error information set if an error occurs.
* @param error Optional error information set if an error occurs.
* @return The instance, or nil if an error occurs.
*/
- (nullable instancetype)initWithEnv:(ORTEnv*)env
Expand All @@ -40,7 +40,7 @@ NS_ASSUME_NONNULL_BEGIN
* @param inputs Dictionary of input names to input ORT values.
* @param outputs Dictionary of output names to output ORT values.
* @param runOptions Optional run configuration options.
* @param[out] error Optional error information set if an error occurs.
* @param error Optional error information set if an error occurs.
* @return Whether the model was run successfully.
*/
- (BOOL)runWithInputs:(NSDictionary<NSString*, ORTValue*>*)inputs
Expand All @@ -55,7 +55,7 @@ NS_ASSUME_NONNULL_BEGIN
* @param inputs Dictionary of input names to input ORT values.
* @param outputNames Set of output names.
* @param runOptions Optional run configuration options.
* @param[out] error Optional error information set if an error occurs.
* @param error Optional error information set if an error occurs.
* @return A dictionary of output names to output ORT values with the outputs
* requested in `outputNames`, or nil if an error occurs.
*/
Expand All @@ -67,23 +67,23 @@ NS_ASSUME_NONNULL_BEGIN
/**
* Gets the model's input names.
*
* @param[out] error Optional error information set if an error occurs.
* @param error Optional error information set if an error occurs.
* @return An array of input names, or nil if an error occurs.
*/
- (nullable NSArray<NSString*>*)inputNamesWithError:(NSError**)error;

/**
* Gets the model's overridable initializer names.
*
* @param[out] error Optional error information set if an error occurs.
* @param error Optional error information set if an error occurs.
* @return An array of overridable initializer names, or nil if an error occurs.
*/
- (nullable NSArray<NSString*>*)overridableInitializerNamesWithError:(NSError**)error;

/**
* Gets the model's output names.
*
* @param[out] error Optional error information set if an error occurs.
* @param error Optional error information set if an error occurs.
* @return An array of output names, or nil if an error occurs.
*/
- (nullable NSArray<NSString*>*)outputNamesWithError:(NSError**)error;
Expand All @@ -100,7 +100,7 @@ NS_ASSUME_NONNULL_BEGIN
/**
* Creates session configuration options.
*
* @param[out] error Optional error information set if an error occurs.
* @param error Optional error information set if an error occurs.
* @return The instance, or nil if an error occurs.
*/
- (nullable instancetype)initWithError:(NSError**)error NS_SWIFT_NAME(init());
Expand All @@ -110,7 +110,7 @@ NS_ASSUME_NONNULL_BEGIN
* A value of 0 means ORT will pick a default value.
*
* @param intraOpNumThreads The number of threads.
* @param[out] error Optional error information set if an error occurs.
* @param error Optional error information set if an error occurs.
* @return Whether the option was set successfully.
*/
- (BOOL)setIntraOpNumThreads:(int)intraOpNumThreads
Expand All @@ -120,7 +120,7 @@ NS_ASSUME_NONNULL_BEGIN
* Sets the graph optimization level.
*
* @param graphOptimizationLevel The graph optimization level.
* @param[out] error Optional error information set if an error occurs.
* @param error Optional error information set if an error occurs.
* @return Whether the option was set successfully.
*/
- (BOOL)setGraphOptimizationLevel:(ORTGraphOptimizationLevel)graphOptimizationLevel
Expand All @@ -130,7 +130,7 @@ NS_ASSUME_NONNULL_BEGIN
* Sets the path to which the optimized model file will be saved.
*
* @param optimizedModelFilePath The optimized model file path.
* @param[out] error Optional error information set if an error occurs.
* @param error Optional error information set if an error occurs.
* @return Whether the option was set successfully.
*/
- (BOOL)setOptimizedModelFilePath:(NSString*)optimizedModelFilePath
Expand All @@ -140,7 +140,7 @@ NS_ASSUME_NONNULL_BEGIN
* Sets the session log ID.
*
* @param logID The log ID.
* @param[out] error Optional error information set if an error occurs.
* @param error Optional error information set if an error occurs.
* @return Whether the option was set successfully.
*/
- (BOOL)setLogID:(NSString*)logID
Expand All @@ -150,7 +150,7 @@ NS_ASSUME_NONNULL_BEGIN
* Sets the session log severity level.
*
* @param loggingLevel The log severity level.
* @param[out] error Optional error information set if an error occurs.
* @param error Optional error information set if an error occurs.
* @return Whether the option was set successfully.
*/
- (BOOL)setLogSeverityLevel:(ORTLoggingLevel)loggingLevel
Expand All @@ -164,7 +164,7 @@ NS_ASSUME_NONNULL_BEGIN
*
* @param key The key.
* @param value The value.
* @param[out] error Optional error information set if an error occurs.
* @param error Optional error information set if an error occurs.
* @return Whether the option was set successfully.
*/
- (BOOL)addConfigEntryWithKey:(NSString*)key
Expand All @@ -183,7 +183,7 @@ NS_ASSUME_NONNULL_BEGIN
/**
* Creates run configuration options.
*
* @param[out] error Optional error information set if an error occurs.
* @param error Optional error information set if an error occurs.
* @return The instance, or nil if an error occurs.
*/
- (nullable instancetype)initWithError:(NSError**)error NS_SWIFT_NAME(init());
Expand All @@ -192,7 +192,7 @@ NS_ASSUME_NONNULL_BEGIN
* Sets the run log tag.
*
* @param logTag The log tag.
* @param[out] error Optional error information set if an error occurs.
* @param error Optional error information set if an error occurs.
* @return Whether the option was set successfully.
*/
- (BOOL)setLogTag:(NSString*)logTag
Expand All @@ -202,7 +202,7 @@ NS_ASSUME_NONNULL_BEGIN
* Sets the run log severity level.
*
* @param loggingLevel The log severity level.
* @param[out] error Optional error information set if an error occurs.
* @param error Optional error information set if an error occurs.
* @return Whether the option was set successfully.
*/
- (BOOL)setLogSeverityLevel:(ORTLoggingLevel)loggingLevel
Expand All @@ -216,7 +216,7 @@ NS_ASSUME_NONNULL_BEGIN
*
* @param key The key.
* @param value The value.
* @param[out] error Optional error information set if an error occurs.
* @param error Optional error information set if an error occurs.
* @return Whether the option was set successfully.
*/
- (BOOL)addConfigEntryWithKey:(NSString*)key
Expand Down
13 changes: 9 additions & 4 deletions objectivec/include/ort_value.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ NS_ASSUME_NONNULL_BEGIN
* @param tensorData The tensor data.
* @param elementType The tensor element data type.
* @param shape The tensor shape.
* @param[out] error Optional error information set if an error occurs.
* @param error Optional error information set if an error occurs.
* @return The instance, or nil if an error occurs.
*/
- (nullable instancetype)initWithTensorData:(NSMutableData*)tensorData
Expand All @@ -35,7 +35,7 @@ NS_ASSUME_NONNULL_BEGIN
/**
* Gets the type information.
*
* @param[out] error Optional error information set if an error occurs.
* @param error Optional error information set if an error occurs.
* @return The type information, or nil if an error occurs.
*/
- (nullable ORTValueTypeInfo*)typeInfoWithError:(NSError**)error;
Expand All @@ -44,7 +44,7 @@ NS_ASSUME_NONNULL_BEGIN
* Gets the tensor type and shape information.
* This assumes that the value is a tensor.
*
* @param[out] error Optional error information set if an error occurs.
* @param error Optional error information set if an error occurs.
* @return The tensor type and shape information, or nil if an error occurs.
*/
- (nullable ORTTensorTypeAndShapeInfo*)tensorTypeAndShapeInfoWithError:(NSError**)error;
Expand All @@ -53,7 +53,12 @@ NS_ASSUME_NONNULL_BEGIN
* Gets the tensor data.
* This assumes that the value is a tensor.
*
* @param[out] error Optional error information set if an error occurs.
* This returns the value's underlying data directly, not a copy of it.
* The memory's lifetime may be tied to this value, i.e., if it was allocated
* by ORT. On the other hand, the memory's lifetime is independent of the value
* if the value was created with user-provided data.
*
* @param error Optional error information set if an error occurs.
* @return The tensor data, or nil if an error occurs.
*/
- (nullable NSMutableData*)tensorDataWithError:(NSError**)error;
Expand Down