-
Notifications
You must be signed in to change notification settings - Fork 203
Initialize Objective-C bindings #709
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
skyline75489
merged 68 commits into
microsoft:main
from
skyline75489:jialli/objc-bindings
Dec 12, 2024
Merged
Changes from 50 commits
Commits
Show all changes
68 commits
Select commit
Hold shift + click to select a range
b339911
Init objc bindings
skyline75489 718e8d1
Merge branch 'main' into jialli/objc-bindings
skyline75489 1e14fa7
More objc
skyline75489 683daf5
Fix
skyline75489 e77fb60
OGASpan
skyline75489 ad1c9e8
More objc bindings
skyline75489 83d1273
license header
skyline75489 d635d63
Update
skyline75489 f4772b6
Merge branch 'main' into jialli/objc-bindings
skyline75489 6099236
Update folder structure
skyline75489 fda89e8
format
skyline75489 844e7d5
Rm podspec for now
skyline75489 891ec8c
header
skyline75489 a4af1b5
more header
skyline75489 fef5a1a
catch
skyline75489 cda7411
Lint
skyline75489 edd86f6
Lint
skyline75489 2eeb42c
Lint
skyline75489 27d5494
Lint
skyline75489 b904daf
Merge branch 'main' into jialli/objc-bindings
skyline75489 616c1c5
Merge branch 'main' into jialli/objc-bindings
skyline75489 0da29a6
Merge branch 'main' into jialli/objc-bindings
skyline75489 808398a
save
skyline75489 ab6b20f
Merge branch 'main' into jialli/objc-bindings
skyline75489 cda2e39
Update interface
skyline75489 01c0416
init pipeline
skyline75489 2fd95d5
Merge branch 'main' into jialli/objc-bindings
skyline75489 318cce1
cocoapods pipeline
skyline75489 d501750
tools and YAMLs
skyline75489 bb44854
[skip ci] assemble pod
skyline75489 65d8240
[skip ci] podspec templat
skyline75489 d17fa47
[skip ci] fix pod file copying
skyline75489 5ff6fb9
[skip ci] yml
skyline75489 8939e46
[skip ci] fix pipeline
skyline75489 242dd2a
nuget authenticate
skyline75489 732415c
[skip ci] pod lint
skyline75489 15f503d
[skip ci] pod testing infra
skyline75489 dee8bd2
[skip ci] Init objc testing
skyline75489 b3c4868
Fix
skyline75489 6e3c975
Update
skyline75489 6af7c27
getoutput
skyline75489 f759b1a
UPdate
skyline75489 6206498
script
skyline75489 6b6a839
[skip ci] model test
skyline75489 cf227f9
[skip ci] beam search
skyline75489 fed0ba1
[skip ci] fix tests
skyline75489 0156a16
Update
skyline75489 8133c36
reviews
skyline75489 565aad1
reviews
skyline75489 c4f389c
update
skyline75489 5b1e1ef
getOutput
skyline75489 c9c31e3
reviews
skyline75489 8d41739
review
skyline75489 7b068e8
clang-format
skyline75489 9ac3518
Merge branch 'main' into jialli/objc-bindings
skyline75489 094fb41
reviews
skyline75489 191bfe4
Merge branch 'main' into jialli/objc-bindings
skyline75489 48e4e11
sync main
skyline75489 0db23bf
skip macos tests
skyline75489 1afacc9
comments
skyline75489 d232230
clang-format
skyline75489 bd116dc
clang format
skyline75489 9ffb63e
Update src/objectivec/include/ort_genai_objc.h
skyline75489 1586fee
Update src/objectivec/include/ort_genai_objc.h
skyline75489 af3cb02
reviews
skyline75489 8a3146b
Reviews
skyline75489 2b15151
Update src/objectivec/include/ort_genai_objc.h
skyline75489 05ed250
Reviews
skyline75489 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
parameters: | ||
- name: ort_version | ||
displayName: 'OnnxRuntime version' | ||
type: string | ||
default: '1.18.0' | ||
|
||
- name: build_config | ||
displayName: 'Build Configuration' | ||
type: string | ||
default: 'Release' | ||
values: | ||
- 'Debug' | ||
- 'RelWithDebInfo' | ||
- 'Release' | ||
- 'MinSizeRel' | ||
|
||
trigger: none | ||
stages: | ||
- template: stages/macos-ios-cocoapods-packaging-stage.yml | ||
parameters: | ||
ort_version: ${{ parameters.ort_version }} | ||
build_config: ${{ parameters.build_config }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
.pipelines/stages/jobs/macos-ios-cocoapods-packaging-job.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
parameters: | ||
- name: build_config | ||
type: string | ||
default: 'release' | ||
- name: ort_version | ||
type: string | ||
|
||
jobs: | ||
- job: macos_ios_cocoapods_packaging | ||
pool: | ||
vmImage: 'macOS-latest' | ||
variables: | ||
buildSettingsFile: "tools/ci_build/github/apple/default_full_apple_framework_build_settings.json" | ||
|
||
workspace: | ||
clean: all | ||
steps: | ||
- checkout: self | ||
clean: true | ||
submodules: none | ||
|
||
- template: steps/utils/set-genai-version.yml | ||
- template: steps/utils/set-cmake-build-type.yml | ||
parameters: | ||
build_config: ${{parameters.build_config}} | ||
|
||
|
||
- task: CmdLine@2 | ||
displayName: Build MacOS & iOS CocoaPods Packages | ||
inputs: | ||
script: | | ||
set -e -x | ||
python tools/ci_build/github/apple/build_and_assemble_apple_pods.py \ | ||
skyline75489 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
--build-dir "$(Build.BinariesDirectory)/apple_framework" \ | ||
--staging-dir "$(Build.BinariesDirectory)/staging" \ | ||
--pod-version "$(genai_version)" \ | ||
--test \ | ||
--variant Full \ | ||
--build-settings-file "${{ variables.buildSettingsFile }}" \ | ||
--ort-version ${{parameters.ort_version}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
parameters: | ||
- name: ort_version | ||
type: string | ||
|
||
- name: build_config | ||
type: string | ||
default: 'Release' | ||
|
||
stages: | ||
- stage: Build_MacOS_iOS_CocoaPods_Archive | ||
jobs: | ||
- template: jobs/macos-ios-cocoapods-packaging-job.yml | ||
parameters: | ||
ort_version: ${{ parameters.ort_version }} | ||
build_config: ${{ parameters.build_config }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
// wrapper for ORT C/C++ API headers | ||
skyline75489 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
#if defined(__clang__) | ||
#pragma clang diagnostic push | ||
// ignore clang documentation-related warnings | ||
// instead, we will rely on Doxygen warnings for the C/C++ API headers | ||
#pragma clang diagnostic ignored "-Wdocumentation" | ||
#endif // defined(__clang__) | ||
|
||
#import "ort_genai.h" | ||
skyline75489 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
#if defined(__clang__) | ||
#pragma clang diagnostic pop | ||
#endif // defined(__clang__) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
skyline75489 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// Licensed under the MIT License. | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
#include <exception> | ||
|
||
#import "cxx_api.h" | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
extern NSString* const kOgaErrorDomain; | ||
|
||
void OGASaveCodeAndDescriptionToError(int code, const char* description, NSError** error); | ||
void OGASaveCodeAndDescriptionToError(int code, NSString* description, NSError** error); | ||
void OGASaveExceptionToError(const std::exception& e, NSError** error); | ||
|
||
// helper macros to catch and handle C++ exceptions | ||
#define OGA_OBJC_API_IMPL_CATCH(error, failure_return_value) \ | ||
catch (const std::exception& e) { \ | ||
OGASaveExceptionToError(e, (error)); \ | ||
return (failure_return_value); \ | ||
} | ||
|
||
#define OGA_OBJC_API_IMPL_CATCH_RETURNING_BOOL(error) OGA_OBJC_API_IMPL_CATCH(error, NO) | ||
|
||
#define OGA_OBJC_API_IMPL_CATCH_RETURNING_NULLABLE(error) OGA_OBJC_API_IMPL_CATCH(error, nil) | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
#import "error_utils.h" | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
NSString* const kOgaErrorDomain = @"onnxruntime-genai"; | ||
|
||
void OGASaveCodeAndDescriptionToError(int code, const char* descriptionCstr, NSError** error) { | ||
if (!error) return; | ||
|
||
NSString* description = [NSString stringWithCString:descriptionCstr | ||
encoding:NSASCIIStringEncoding]; | ||
skyline75489 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
*error = [NSError errorWithDomain:kOgaErrorDomain | ||
code:code | ||
userInfo:@{NSLocalizedDescriptionKey : description}]; | ||
} | ||
|
||
void OGASaveCodeAndDescriptionToError(int code, NSString* description, NSError** error) { | ||
if (!error) return; | ||
|
||
*error = [NSError errorWithDomain:kOgaErrorDomain | ||
code:code | ||
userInfo:@{NSLocalizedDescriptionKey : description}]; | ||
} | ||
|
||
void OGASaveExceptionToError(const std::exception& e, NSError** error) { | ||
OGASaveCodeAndDescriptionToError(0x0A, e.what(), error); | ||
skyline75489 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
NS_ASSUME_NONNULL_END |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.