Skip to content

Commit

Permalink
fix build err inbuild with minimal_build conjuncting disable_exceptio…
Browse files Browse the repository at this point in the history
…ns flags (#14524)

### Description
If we set flag 'disable_exceptions' to build ORT:


`onnxruntime/contrib_ops/cpu/quantization/qlinear_global_average_pool.cc.o`
woundn't generate such symbols which used by qlinear_pool.c
```
0000000000000000 W _ZN11onnxruntime7contrib27ComputeQLinearGlobalAvgPoolIaEENS_6common6StatusEPKT_fS4_PS4_fS4_lllbPNS_11concurrency10ThreadPoolE
0000000000000000 W _ZN11onnxruntime7contrib27ComputeQLinearGlobalAvgPoolIhEENS_6common6StatusEPKT_fS4_PS4_fS4_lllbPNS_11concurrency10ThreadPoolE
```
so we get a error of undefined symbols of
ComputeQLinearGlobalAvgPool<uin8_t> and
ComputeQLinearGlobalAvgPool<in8_t>......


### Motivation and Context
<!-- - Why is this change required? What problem does it solve?
- If it fixes an open issue, please link to the issue here. -->
  • Loading branch information
wejoncy authored Feb 3, 2023
1 parent 20b5a75 commit 78280bf
Showing 1 changed file with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,38 @@ Status ComputeQLinearGlobalAvgPool(
return Status::OK();
}

// GCC's unexplained behavior:
// GCC wouldn't generate corresponding symbols versus function instances below when "--disable-exceptions"
// and "--minimal-build" are combined on linux build.
// But this two symbols are required by qlinear_pool.cc.
// The other compilers wouldn't hit it and works fine, and we also didn't see it in the other platforms, such as Android.
// So we are doing explicit instantiation here for every compilers/platforms happy.
template Status ComputeQLinearGlobalAvgPool<int8_t>(
const int8_t* x,
float x_scale,
int8_t x_zero_point,
int8_t* y,
float y_scale,
int8_t y_zero_point,
int64_t N,
int64_t C,
int64_t image_size,
bool channels_last,
concurrency::ThreadPool* tp);

template Status ComputeQLinearGlobalAvgPool<uint8_t>(
const uint8_t* x,
float x_scale,
uint8_t x_zero_point,
uint8_t* y,
float y_scale,
uint8_t y_zero_point,
int64_t N,
int64_t C,
int64_t image_size,
bool channels_last,
concurrency::ThreadPool* tp);

Status QLinearGlobalAveragePool::Compute(OpKernelContext* context) const {
const auto tensor_x_scale = context->Input<Tensor>(1);
const auto tensor_x_zero_point = context->Input<Tensor>(2);
Expand Down

0 comments on commit 78280bf

Please sign in to comment.