Skip to content

Commit

Permalink
Merge pull request #29 from Microsoft/RyanUnderhill-patch-1
Browse files Browse the repository at this point in the history
Update C_API.md
  • Loading branch information
RyanUnderhill authored Nov 27, 2018
2 parents 6982325 + 3761d2d commit 573a9ab
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions docs/C_API.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# C API

# Q: Why having a C API?
Q: Why not just live in C++ world? Why must C?
A: We want to distribute onnxruntime as a DLL, which can be used in .Net languages through [P/Invoke](https://docs.microsoft.com/en-us/cpp/dotnet/how-to-call-native-dlls-from-managed-code-using-pinvoke).
Then this is the only option we have.
# Q: Why have a C API?
Q: Why not just live in a C++ world? Why C?
A: We want to distribute the onnxruntime as a DLL, which can be used in .Net languages through [P/Invoke](https://docs.microsoft.com/en-us/cpp/dotnet/how-to-call-native-dlls-from-managed-code-using-pinvoke).
This is the only option we have.

Q: Is it only for .Net?
A: No. It is designed for
1. Creating language bindings for onnxruntime.e.g. C#, python, java, ...
2. Dynamic linking always has some benefits. For example, for solving diamond dependency problem.
A: No. It is designed for:
1. Creating language bindings for the onnxruntime. e.g. C#, python, java, ...
2. Dynamic linking has some benefits. For example, solving diamond dependency problems.

Q: Can I export C++ types and functions across DLL or "Shared Object" Library(.so) boundaries?
A: Well, you can, but it's not a good practice. And we won't do it in this project.
A: Well, you can, but it's not a good practice. We won't do it in this project.


## What's inside
Expand All @@ -26,14 +26,12 @@ A: Well, you can, but it's not a good practice. And we won't do it in this proje

## How to use it

Include [onnxruntime_c_api.h](include/onnxruntime/core/session/onnxruntime_c_api.h) in your source code.

Then,
1. Call ONNXRuntimeInitialize
2. Create Session: ONNXRuntimeCreateInferenceSession(env, model_uri, nullptr,...)
3. Create Tensor
1. Include [onnxruntime_c_api.h](include/onnxruntime/core/session/onnxruntime_c_api.h).
2. Call ONNXRuntimeInitialize
3. Create Session: ONNXRuntimeCreateInferenceSession(env, model_uri, nullptr,...)
4. Create Tensor
1) ONNXRuntimeCreateAllocatorInfo
2) ONNXRuntimeCreateTensorWithDataAsONNXValue
4. ONNXRuntimeRunInference
5. ONNXRuntimeRunInference


0 comments on commit 573a9ab

Please sign in to comment.