Skip to content

Commit

Permalink
Merge branch 'main' into blob
Browse files Browse the repository at this point in the history
  • Loading branch information
wenbingl authored Nov 8, 2024
2 parents f214703 + 14f280a commit 7c854bd
Show file tree
Hide file tree
Showing 27 changed files with 2,061 additions and 3 deletions.
6 changes: 4 additions & 2 deletions shared/api/image_transforms.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,15 @@ inline OrtxStatus convert_to_rgb(const ortc::Tensor<uint8_t>& input, ortc::Tenso
}

struct Resize {
static const std::unordered_map<std::string, int> InterpolationMethods() {
return {
static const std::unordered_map<std::string, int>& InterpolationMethods() {
static std::unordered_map<std::string, int> methods = {
{"NEAREST", IMAGING_TRANSFORM_NEAREST},
{"LINEAR", IMAGING_TRANSFORM_BILINEAR},
{"CUBIC", IMAGING_TRANSFORM_BICUBIC},
{"LANCZOS", IMAGING_TRANSFORM_LANCZOS}
};

return methods;
}

OrtxStatus Compute(const ortc::Tensor<uint8_t>& input, ortc::Tensor<uint8_t>& output) {
Expand Down
106 changes: 106 additions & 0 deletions tools/ci_build/github/azure-pipeline/android_packaging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# packaging pipeline for onnxruntime-extensions Android AAR package

trigger: none

resources:
repositories:
- repository: 1esPipelines
type: git
name: 1ESPipelineTemplates/1ESPipelineTemplates
ref: refs/tags/release

extends:
template: v1/1ES.Official.PipelineTemplate.yml@1esPipelines
parameters:
pool:
name: "Azure Pipelines"
image: "macOS-13"
os: macOS
sdl:
sourceAnalysisPool:
name: onnxruntime-Win-CPU-2022
os: windows
stages:
- stage: Stage
jobs:
- job: AndroidPackaging
timeoutInMinutes: 150
variables:
buildConfig: Release
templateContext:
outputs:
- output: pipelineArtifact
path: '$(Build.ArtifactStagingDirectory)'
artifact: onnxruntime-extensions-android-aar
steps:
- task: UsePythonVersion@0
inputs:
disableDownloadFromRegistry: true
versionSpec: "3.12"
addToPath: true
architecture: "x64"
displayName: "Use Python 3.12"

- task: JavaToolInstaller@0
displayName: Use jdk 17
inputs:
versionSpec: "17"
jdkArchitectureOption: "x64"
jdkSourceOption: "PreInstalled"

- script: brew install coreutils ninja
displayName: Install coreutils and ninja

- template: tools/ci_build/github/azure-pipeline/templates/install-appcenter.yml@self

- script: |
python ./tools/gen_selectedops.py ./tools/android/package_ops.config
displayName: "Generate selected ops CMake file"
- bash: |
set -e -x
python ./tools/android/build_aar.py \
--output_dir $(Build.BinariesDirectory)/android_aar \
--config $(buildConfig) \
-- \
--one_cmake_extra_define OCOS_ENABLE_SELECTED_OPLIST=ON
VERSION=$(cat ./version.txt)
AAR_PATH="$(Build.BinariesDirectory)/android_aar/aar_out/$(buildConfig)/com/microsoft/onnxruntime/onnxruntime-extensions-android/${VERSION}/onnxruntime-extensions-android-${VERSION}.aar"
# Do not output ##vso[] commands with `set -x` or they may be parsed again and include a trailing quote.
set +x
echo "##vso[task.setvariable variable=ORT_EXTENSIONS_AAR_PATH]${AAR_PATH}"
displayName: Build onnxruntime-extensions AAR package
- template: tools/ci_build/github/azure-pipeline/templates/run-with-android-emulator-steps.yml@self
parameters:
steps:

- bash: |
set -e -x
cp -r $(Build.SourcesDirectory)/java/src/test/android $(Build.BinariesDirectory)/android_test
cd $(Build.BinariesDirectory)/android_test
./gradlew connectedDebugAndroidTest --no-daemon -DortExtensionsAarLocalPath="${ORT_EXTENSIONS_AAR_PATH}"
displayName: Build and run onnxruntime-extensions Android test with Android Emulator
- bash: |
set -e -x
AAR_DIR=$(dirname "${ORT_EXTENSIONS_AAR_PATH}")
ARTIFACTS_STAGING_DIR="$(Build.ArtifactStagingDirectory)"
cp ${ORT_EXTENSIONS_AAR_PATH} ${ARTIFACTS_STAGING_DIR}
cp ${AAR_DIR}/*-javadoc.jar ${ARTIFACTS_STAGING_DIR}
cp ${AAR_DIR}/*-sources.jar ${ARTIFACTS_STAGING_DIR}
cp ${AAR_DIR}/*.pom ${ARTIFACTS_STAGING_DIR}
displayName: "Assemble artifacts"
- template: tools/ci_build/github/azure-pipeline/templates/component-governance-component-detection-steps.yml@self
parameters :
condition : 'succeeded'
202 changes: 202 additions & 0 deletions tools/ci_build/github/azure-pipeline/java_packaging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
parameters:
- name: JavaPackagingandPublishing
displayName: Package and Publish Java Package
type: boolean
default: true

trigger: none

resources:
repositories:
- repository: 1esPipelines
type: git
name: 1ESPipelineTemplates/1ESPipelineTemplates
ref: refs/tags/release

extends:
template: v1/1ES.Official.PipelineTemplate.yml@1esPipelines
parameters:
sdl:
sourceAnalysisPool:
name: onnxruntime-Win-CPU-2022
os: windows
stages:
- stage: Java_Packaging_and_Publishing
jobs:
- job: Windows_CPU_Java_Packaging
pool:
name: onnxruntime-Win-CPU-2022
os: windows
workspace:
clean: all
templateContext:
outputs:
- output: pipelineArtifact
path: '$(Build.ArtifactStagingDirectory)/ai/onnxruntime/extensions/native'
artifact: WindowsBinaries

steps:
- task: PowerShell@2
displayName: 'Set version'
inputs:
targetType: 'inline'
script: |
$_ExtVersion=(cat version.txt)
echo "##vso[task.setvariable variable=OrtExtVersion;]$_ExtVersion"
workingDirectory: '$(Build.SourcesDirectory)'

- script: |
call .\build.bat -DOCOS_BUILD_JAVA=ON
displayName: build the extensions java package
- task: CopyFiles@2
displayName: 'Copy Java Files for Windows Arch to Artifact Staging Directory'
inputs:
SourceFolder: 'out\Windows\java\build\libs'
TargetFolder: '$(Build.ArtifactStagingDirectory)'

- script: |
cd $(Build.ArtifactStagingDirectory)
jar xvf onnxruntime-extensions-$(OrtExtVersion).jar
tree $(Build.ArtifactStagingDirectory) /f
displayName: Unpack JAR to sign DLL
- template: tools/ci_build/github/azure-pipeline/templates/win-esrp-dll.yml@self
parameters:
FolderPath: '$(Build.ArtifactStagingDirectory)/ai/onnxruntime/extensions/native/win-x64'
DisplayName: 'Sign DLL'
DoEsrp: 'true'

- template: tools/ci_build/github/azure-pipeline/templates/component-governance-component-detection-steps.yml@self
parameters :
condition : 'succeeded'

- task: mspremier.PostBuildCleanup.PostBuildCleanup-task.PostBuildCleanup@3
displayName: 'Clean Agent Directories'
condition: always()

- job: Linux_CPU_Java_Packaging
workspace:
clean: all
pool:
name: 'onnxruntime-Ubuntu2204-AMD-CPU'
os: 'linux'
templateContext:
outputs:
- output: pipelineArtifact
path: '$(Build.ArtifactStagingDirectory)/ai/onnxruntime/extensions/native'
artifact: LinuxBinaries

steps:
- task: PowerShell@2
displayName: 'Set version'
inputs:
targetType: 'inline'
script: |
$_ExtVersion=(cat version.txt)
echo "##vso[task.setvariable variable=OrtExtVersion;]$_ExtVersion"
workingDirectory: '$(Build.SourcesDirectory)'

- script: |
sh ./build.sh -DOCOS_BUILD_JAVA=ON
displayName: build the extensions java package
- task: CopyFiles@2
displayName: 'Copy Java Files for $(Agent.OS) Arch to Artifact Staging Directory'
inputs:
SourceFolder: 'out/$(Agent.OS)/RelWithDebInfo/java/build/libs'
TargetFolder: '$(Build.ArtifactStagingDirectory)'

- script: |
cd $(Build.ArtifactStagingDirectory)
echo $(OrtExtVersion)
jar xvf onnxruntime-extensions-$(OrtExtVersion).jar
# tree $(Build.ArtifactStagingDirectory) /f
displayName: Unpack JAR
- template: tools/ci_build/github/azure-pipeline/templates/component-governance-component-detection-steps.yml@self
parameters :
condition : 'succeeded'

- task: mspremier.PostBuildCleanup.PostBuildCleanup-task.PostBuildCleanup@3
displayName: 'Clean Agent Directories'
condition: always()

- job: MacOS_CPU_Java_Packaging
dependsOn:
- Windows_CPU_Java_Packaging
- Linux_CPU_Java_Packaging
workspace:
clean: all
pool:
name: "Azure Pipelines"
image: "macOS-13"
os: macOS
templateContext:
inputs:
- input: pipelineArtifact
artifactName: WindowsBinaries
targetPath: '$(Build.ArtifactStagingDirectory)/ai/onnxruntime/extensions/native'
- input: pipelineArtifact
artifactName: LinuxBinaries
targetPath: '$(Build.ArtifactStagingDirectory)/ai/onnxruntime/extensions/native'
outputs:
- output: pipelineArtifact
path: '$(Build.ArtifactStagingDirectory)/drop'
artifact: drop-onnxruntime-extensions-java-cpu

steps:
- task: PowerShell@2
displayName: 'Set version'
inputs:
targetType: 'inline'
script: |
$_ExtVersion=(cat version.txt)
echo "##vso[task.setvariable variable=OrtExtVersion;]$_ExtVersion"
workingDirectory: '$(Build.SourcesDirectory)'

- script: |
sh ./build.sh -DOCOS_BUILD_JAVA=ON
displayName: build the extensions java package
- task: CopyFiles@2
displayName: 'Copy Java Files for $(Agent.OS) Arch to Artifact Staging Directory'
inputs:
SourceFolder: 'out/$(Agent.OS)/RelWithDebInfo/java/build/libs'
TargetFolder: '$(Build.ArtifactStagingDirectory)'

- script: |
cd $(Build.ArtifactStagingDirectory)
echo $(OrtExtVersion)
jar xvf onnxruntime-extensions-$(OrtExtVersion).jar
brew install tree
tree $(Build.ArtifactStagingDirectory)
displayName: Unpack JAR to view contents
- script: |
brew install tree
tree $(Build.ArtifactStagingDirectory)
displayName: Print contents
- script: |
cd $(Build.ArtifactStagingDirectory)
rm onnxruntime-extensions-$(OrtExtVersion).jar
jar cmf0 META-INF/MANIFEST.MF onnxruntime-extensions-$(OrtExtVersion).jar *
displayName: Combine and pack JAR with Windows, Linux and MacOS Binaries
- script: |
cd $(Build.ArtifactStagingDirectory)
mkdir drop
cp onnxruntime-extensions-$(OrtExtVersion).jar drop/onnxruntime-extensions-$(OrtExtVersion).jar
cp onnxruntime-extensions-$(OrtExtVersion)-javadoc.jar drop/onnxruntime-extensions-$(OrtExtVersion)-javadoc.jar
cp onnxruntime-extensions-$(OrtExtVersion)-sources.jar drop/onnxruntime-extensions-$(OrtExtVersion)-sources.jar
cp META-INF/maven/com.microsoft.onnxruntime/onnxruntime-extensions/pom.xml drop/onnxruntime-extensions-$(OrtExtVersion).pom
displayName: Move files to a drop folder for publishing
- template: tools/ci_build/github/azure-pipeline//templates/component-governance-component-detection-steps.yml@self
parameters :
condition : 'succeeded'

- task: mspremier.PostBuildCleanup.PostBuildCleanup-task.PostBuildCleanup@3
displayName: 'Clean Agent Directories'
condition: always()
65 changes: 65 additions & 0 deletions tools/ci_build/github/azure-pipeline/nuget.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
parameters:
- name: DoCompliance
displayName: Run Compliance Tasks?
type: boolean
default: true

- name: DoEsrp
displayName: Run code sign tasks? Must be true if you are doing an OnnxRuntime extensions release.
type: boolean
default: true

- name: IsReleaseBuild
displayName: Is this a release build? Set it to true if you are doing an OnnxRuntime extensions release.
type: boolean
default: false

- name: IsDummyPackage
displayName: Is this a build of Microsoft.ML.OnnxRuntime.Extensions.Dummy package that has no operators?
type: boolean
default: false

- name: NugetVersionSuffix
displayName: Update nuget version suffix (e.g. alpha/beta/rc, only if publishing to nuget.org, otherwise leave as "none").
type: string
default: none

trigger: none

resources:
repositories:
- repository: 1esPipelines
type: git
name: 1ESPipelineTemplates/1ESPipelineTemplates
ref: refs/tags/release

extends:
template: v1/1ES.Official.PipelineTemplate.yml@1esPipelines
parameters:
sdl:
sourceAnalysisPool:
name: onnxruntime-Win-CPU-2022
os: windows
credscan:
enabled: false

stages:
- ${{ if eq(parameters.IsDummyPackage, false) }}:
- template: templates/build-package-for-nuget.yml@self
parameters:
DoCompliance: ${{ parameters.DoCompliance }}
DoEsrp: ${{ parameters.DoEsrp }}
IsReleaseBuild: ${{ parameters.IsReleaseBuild }}
NugetVersionSuffix: ${{ parameters.NugetVersionSuffix }}

- ${{ else }}:
- template: templates/build-package-for-nuget.yml@self
parameters:
DoCompliance: ${{ parameters.DoCompliance }}
DoEsrp: ${{ parameters.DoEsrp }}
IsReleaseBuild: ${{ parameters.IsReleaseBuild }}
NugetVersionSuffix: ${{ parameters.NugetVersionSuffix }}
IsDummyPackage: true
# set flags to do a build with no operators for the dummy package
OperatorSelectionFlags: ''
AdditionalBuildFlags: '--include_ops_by_config ./tools/ci_build/no_ops.config --skip_tests --cmake_extra_defines OCOS_ENABLE_CTEST=OFF'
Loading

0 comments on commit 7c854bd

Please sign in to comment.