Skip to content

Commit

Permalink
Add UT for Azure Ops during packaging (#502)
Browse files Browse the repository at this point in the history
* set before-test

* test cmd

* clean in yml

* restore toml

* add ut for triton endpoints

* reset working path

* rename suffix

* install ort

* pip install

* make env

* add extra env

* make executable

* set dir for linux

* add switch

* set env default

* skip tests

* simplify env

* clean env for official

---------

Co-authored-by: Randy Shuai <rashuai@microsoft.com>
Co-authored-by: Wenbing Li <10278425+wenbingl@users.noreply.github.com>
  • Loading branch information
3 people authored Aug 3, 2023
1 parent 922b7cc commit 9e7f8e5
Show file tree
Hide file tree
Showing 19 changed files with 331 additions and 39 deletions.
12 changes: 5 additions & 7 deletions .pipelines/OneBranch.Official.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,10 @@ parameters: # parameters are shown up in ADO UI in a build queue time
type: boolean
default: false

- name: BuildAzureOp
displayName: 'Build and test AzureEP ops'
- name: ExtraEnv
displayName: 'Extra env variable set to CIBW_ENVIRONMENT'
type: string
values:
- '0'
- '1'
default: '0'
default: 'None=None'

variables:
CDP_DEFINITION_BUILD_COUNT: $[counter('', 0)]
Expand All @@ -35,7 +32,7 @@ variables:
CIBW_BUILD: cp3{8,9,10,11}-*amd64
CIBW_ARCHS: AMD64
DEBIAN_FRONTEND: noninteractive
CIBW_ENVIRONMENT: "OCOS_ENABLE_AZURE=${{ parameters.BuildAzureOp }}"
CIBW_ENVIRONMENT: "${{ parameters.ExtraEnv }}"

resources:
repositories:
Expand Down Expand Up @@ -107,6 +104,7 @@ extends:
python -m pip install --upgrade pip
python -m pip install cibuildwheel numpy
python -m cibuildwheel --platform windows --archs AMD64 --output-dir $(REPOROOT)\out
tools\install_deps.bat uninstall
displayName: Build wheels
- task: SDLNativeRules@3
inputs:
Expand Down
12 changes: 5 additions & 7 deletions .pipelines/OneBranch.PullRequest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,10 @@ parameters: # parameters are shown up in ADO UI in a build queue time
type: boolean
default: false

- name: BuildAzureOp
displayName: 'Build and test AzureEP ops'
- name: ExtraEnv
displayName: 'Extra env variable set to CIBW_ENVIRONMENT'
type: string
values:
- '0'
- '1'
default: '0'
default: 'None=None'

variables:
CDP_DEFINITION_BUILD_COUNT: $[counter('', 0)]
Expand All @@ -36,7 +33,7 @@ variables:
CIBW_ARCHS: AMD64
CIBW_BUILD_VERBOSITY: 1
DEBIAN_FRONTEND: noninteractive
CIBW_ENVIRONMENT: "OCOS_ENABLE_AZURE=${{ parameters.BuildAzureOp }}"
CIBW_ENVIRONMENT: "${{ parameters.ExtraEnv }}"

resources:
repositories:
Expand Down Expand Up @@ -108,6 +105,7 @@ extends:
python -m pip install --upgrade pip
python -m pip install cibuildwheel numpy
python -m cibuildwheel --platform windows --archs AMD64 --output-dir $(REPOROOT)\out
tools\install_deps.bat uninstall
displayName: Build wheels
- task: SDLNativeRules@3
inputs:
Expand Down
11 changes: 4 additions & 7 deletions .pipelines/wheels_linux.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
parameters:
- name: BuildAzureOp
displayName: 'Build and test AzureEP ops'
- name: ExtraEnv
displayName: 'Extra env variable set to CIBW_ENVIRONMENT'
type: string
values:
- '0'
- '1'
default: '0'
default: 'None=None'

jobs:
- job: linux
timeoutInMinutes: 180
pool: {name: 'Azure-Pipelines-EO-Ubuntu-2004-aiinfra'}
variables:
CIBW_BUILD: "cp3{8,9,10,11}-*"
CIBW_ENVIRONMENT: "OCOS_ENABLE_AZURE=${{ parameters.BuildAzureOp }}"
CIBW_ENVIRONMENT: "${{ parameters.ExtraEnv }}"

steps:
- task: UsePythonVersion@0
Expand Down
6 changes: 0 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -379,12 +379,6 @@ if(OCOS_ENABLE_BLINGFIRE)
endif()

if(OCOS_ENABLE_AZURE)

if ($ENV{TEST_AZURE_INVOKERS_AS_CPU_OP} MATCHES "ON")
message(STATUS "Azure inovkers will be testable as cpu ops")
add_compile_definitions(TEST_AZURE_INVOKERS_AS_CPU_OP)
endif()

# Azure endpoint invokers
include(triton)
file(GLOB TARGET_SRC_AZURE "operators/azure/*.cc" "operators/azure/*.h*")
Expand Down
2 changes: 1 addition & 1 deletion includes/custom_op_lite.h
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ struct Variadic : public TensorBase {
tensor = std::make_unique<Custom::Tensor<int64_t>>(api, ctx, ith_input, true);
break;
case ONNX_TENSOR_ELEMENT_DATA_TYPE_STRING:
tensor = std::make_unique<Custom::Tensor<std::string_view>>(api, ctx, ith_input, true);
tensor = std::make_unique<Custom::Tensor<std::string>>(api, ctx, ith_input, true);
break;
default:
ORTX_CXX_API_THROW("unknow input type", ORT_RUNTIME_EXCEPTION);
Expand Down
20 changes: 10 additions & 10 deletions operators/azure/azure_invokers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -343,11 +343,15 @@ void AzureTritonInvoker::Compute(const ortc::Variadic& inputs, ortc::Variadic& o
triton_input_vec.emplace_back(triton_input);

triton_inputs.push_back(triton_input);
// todo - test string
const float* data_raw = reinterpret_cast<const float*>(inputs[ith_input]->DataRaw());
size_t size_in_bytes = inputs[ith_input]->SizeInBytes();
err = triton_input->AppendRaw(reinterpret_cast<const uint8_t*>(data_raw), size_in_bytes);
CHECK_TRITON_ERR(err, "failed to append raw data to input");
if ("BYTES" == triton_data_type) {
const auto* string_tensor = reinterpret_cast<const ortc::Tensor<std::string>*>(inputs[ith_input].get());
triton_input->AppendFromString(string_tensor->Data());
} else {
const float* data_raw = reinterpret_cast<const float*>(inputs[ith_input]->DataRaw());
size_t size_in_bytes = inputs[ith_input]->SizeInBytes();
err = triton_input->AppendRaw(reinterpret_cast<const uint8_t*>(data_raw), size_in_bytes);
CHECK_TRITON_ERR(err, "failed to append raw data to input");
}
}

for (size_t ith_output = 0; ith_output < output_names_.size(); ++ith_output) {
Expand Down Expand Up @@ -411,15 +415,11 @@ const std::vector<const OrtCustomOp*>& AzureInvokerLoader() {
static OrtOpLoader op_loader(CustomAzureStruct("AzureAudioInvoker", AzureAudioInvoker),
CustomAzureStruct("AzureTritonInvoker", AzureTritonInvoker),
CustomAzureStruct("AzureAudioInvoker", AzureAudioInvoker),
CustomAzureStruct("AzureTextInvoker", AzureTextInvoker)

#ifdef TEST_AZURE_INVOKERS_AS_CPU_OP
,
CustomAzureStruct("AzureTextInvoker", AzureTextInvoker),
CustomCpuStruct("AzureAudioInvoker", AzureAudioInvoker),
CustomCpuStruct("AzureTritonInvoker", AzureTritonInvoker),
CustomCpuStruct("AzureAudioInvoker", AzureAudioInvoker),
CustomCpuStruct("AzureTextInvoker", AzureTextInvoker)
#endif
);
return op_loader.GetCustomOps();
}
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ line-length = 120
[[tool.cibuildwheel.overrides]]
select = "*-manylinux*x86_64*"
before-all = "./tools/install_deps.sh many64"
test-command = "{project}/tools/test_cibuildwheel.sh {project}"

[[tool.cibuildwheel.overrides]]
select = "*-manylinux*i686*"
Expand All @@ -23,4 +24,4 @@ before-all = "./tools/install_deps.sh musl"
[[tool.cibuildwheel.overrides]]
select = "*win*"
before-build = "tools\\install_deps.bat install"
after-build = "tools\\install_deps.bat uninstall"
test-command = "{project}\\tools\\test_cibuildwheel.bat {project}"
Binary file added test/data/azure/openai_audio.onnx
Binary file not shown.
Binary file added test/data/azure/openai_chat.onnx
Binary file not shown.
17 changes: 17 additions & 0 deletions test/data/azure/openai_embedding.onnx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
:�
�

auth_token
text embeddingembedding_invoker"AzureTextInvoker*4
model_uri"$https://api.openai.com/v1/embeddings�*
verbose�:ai.onnx.contribgraphZ!

auth_token

���������Z
text

���������b
embedding

���������B
Binary file added test/data/azure/test16.wav
Binary file not shown.
24 changes: 24 additions & 0 deletions test/data/azure/triton_addf.onnx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
:�
�

auth_token
X
YZtriton_invoker"AzureTritonInvoker*

model_name"addf�*G
model_uri"7https://endpoint-5095584.westus2.inference.ml.azure.com�*
model_version"1�*
verbose"1�:ai.onnx.contribgraphZ!

auth_token

���������Z
X

���������Z
Y

���������b
Z

���������B
Expand Down
24 changes: 24 additions & 0 deletions test/data/azure/triton_addf8.onnx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
:�
�

auth_token
X
YZtriton_invoker"AzureTritonInvoker*

model_name"addf8�*G
model_uri"7https://endpoint-3586177.westus2.inference.ml.azure.com�*
model_version"1�*
verbose"1�:ai.onnx.contribgraphZ!

auth_token

���������Z
X
 
���������Z
Y
 
���������b
Z
 
���������B
Expand Down
24 changes: 24 additions & 0 deletions test/data/azure/triton_addi4.onnx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
:�
�

auth_token
X
YZtriton_invoker"AzureTritonInvoker*

model_name"addi4�*G
model_uri"7https://endpoint-9231153.westus2.inference.ml.azure.com�*
model_version"1�*
verbose"1�:ai.onnx.contribgraphZ!

auth_token

���������Z
X

���������Z
Y

���������b
Z

���������B
Expand Down
24 changes: 24 additions & 0 deletions test/data/azure/triton_and.onnx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
:�
�

auth_token
X
YZtriton_invoker"AzureTritonInvoker*

model_name"and�*G
model_uri"7https://endpoint-5911162.westus2.inference.ml.azure.com�*
model_version"1�*
verbose"1�:ai.onnx.contribgraphZ!

auth_token

���������Z
X
 
���������Z
Y
 
���������b
Z
 
���������B
Expand Down
23 changes: 23 additions & 0 deletions test/data/azure/triton_str.onnx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
:�
�

auth_token
str_instr_out1str_out2triton_invoker"AzureTritonInvoker*

model_name"str�*G
model_uri"7https://endpoint-7270363.westus2.inference.ml.azure.com�*
model_version"1�*
verbose"1�:ai.onnx.contribgraphZ!

auth_token

���������Z
str_in

���������b
str_out1

���������b
str_out2

���������B
Expand Down
Loading

0 comments on commit 9e7f8e5

Please sign in to comment.