Skip to content
This repository was archived by the owner on Jul 1, 2025. It is now read-only.
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion lib/Onnxifi/Base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,8 @@ onnxStatus Graph::setIOAndRun(uint32_t inputsCount,
// Create tensors for output placeholders
auto &externalIOBindings = ctx->getExternalIOBindings();
for (unsigned i = 0; i < outputsCount; ++i) {
const auto &outOnnxTensor = outputDescriptors[i];
auto &outOnnxTensor =
const_cast<onnxTensorDescriptorV1 &>(outputDescriptors[i]);
auto *outOnnxBuffer = reinterpret_cast<void *>(outOnnxTensor.buffer);
Placeholder *outPhPtr;

Expand Down Expand Up @@ -421,6 +422,14 @@ onnxStatus Graph::setIOAndRun(uint32_t inputsCount,
return ONNXIFI_STATUS_INVALID_SHAPE;
}

// Set quantized output scale/output. Do not support channelwise quantized
// output with multiple quantization parameters for now.
auto type = outPhPtr->getType();
if (outOnnxTensor.quantizationParams == 1 && type->isQuantizedType()) {
const_cast<float *>(outOnnxTensor.scales)[0] = type->getScale();
const_cast<int32_t *>(outOnnxTensor.biases)[0] = type->getOffset();
}

// Create a Glow tensor backed by the memory from the provided onnxifi
// tensor and bind it to the appropriate placeholder for the graph output.
Tensor outputTensor(outOnnxBuffer, outPhPtr->getType());
Expand Down