Skip to content

Commit

Permalink
minor
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudhan committed Oct 9, 2024
1 parent e3c6944 commit 9696972
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ namespace {
// removal is valid or not.
// 4. Due to rounding effect, we can be get the upperbound and lowerbound of min or max
// - Which one to use?
// - upperbound of min and lowerbound of max
// upperbound of min and lowerbound of max
// - Why?
// - We want the codomain to be unchanged.

// We want the codomain to be unchanged, so as long as the domain genreate a codomain that fill the integer value
// range will be fine.

// The quantization formula is y = saturate((x / y_scale) + y_zero_point)
// For (x / y_scale), it rounds to the nearest even. So the allowed quantize limits before saturate need to be taken
Expand All @@ -43,7 +43,7 @@ struct quantize_domain {
int64_t codomain_min = std::numeric_limits<T>::lowest();
int64_t biased = codomain_min - zp;
float before_round = float(biased) + 0.5; // move to upperbound

Check warning on line 45 in onnxruntime/core/providers/qnn/builder/qnn_node_group/conv_activation_fusion.cc

View workflow job for this annotation

GitHub Actions / Optional Lint C++

[cpplint] reported by reviewdog 🐶 Using deprecated casting style. Use static_cast<float>(...) instead [readability/casting] [4] Raw Output: onnxruntime/core/providers/qnn/builder/qnn_node_group/conv_activation_fusion.cc:45: Using deprecated casting style. Use static_cast<float>(...) instead [readability/casting] [4]
if (biased % 2 == 1) { // cannot be exact ?.5 because of rounding to even
if (biased % 2 == 1) { // cannot be exact ?.5 because of rounding to even
before_round = std::nextafterf(before_round, float(biased));

Check warning on line 47 in onnxruntime/core/providers/qnn/builder/qnn_node_group/conv_activation_fusion.cc

View workflow job for this annotation

GitHub Actions / Optional Lint C++

[cpplint] reported by reviewdog 🐶 Using deprecated casting style. Use static_cast<float>(...) instead [readability/casting] [4] Raw Output: onnxruntime/core/providers/qnn/builder/qnn_node_group/conv_activation_fusion.cc:47: Using deprecated casting style. Use static_cast<float>(...) instead [readability/casting] [4]
}
return before_round * scale;
Expand All @@ -53,14 +53,14 @@ struct quantize_domain {
int64_t codomain_max = std::numeric_limits<T>::max();
int64_t biased = codomain_max - zp;
float before_round = float(biased) - 0.5; // move to lowerbound

Check warning on line 55 in onnxruntime/core/providers/qnn/builder/qnn_node_group/conv_activation_fusion.cc

View workflow job for this annotation

GitHub Actions / Optional Lint C++

[cpplint] reported by reviewdog 🐶 Using deprecated casting style. Use static_cast<float>(...) instead [readability/casting] [4] Raw Output: onnxruntime/core/providers/qnn/builder/qnn_node_group/conv_activation_fusion.cc:55: Using deprecated casting style. Use static_cast<float>(...) instead [readability/casting] [4]
if (biased % 2 == 1) { // cannot be exact ?.5 because of rounding to even
if (biased % 2 == 1) { // cannot be exact ?.5 because of rounding to even
before_round = std::nextafterf(before_round, float(biased));

Check warning on line 57 in onnxruntime/core/providers/qnn/builder/qnn_node_group/conv_activation_fusion.cc

View workflow job for this annotation

GitHub Actions / Optional Lint C++

[cpplint] reported by reviewdog 🐶 Using deprecated casting style. Use static_cast<float>(...) instead [readability/casting] [4] Raw Output: onnxruntime/core/providers/qnn/builder/qnn_node_group/conv_activation_fusion.cc:57: Using deprecated casting style. Use static_cast<float>(...) instead [readability/casting] [4]
}
return before_round * scale;
}
};

}
} // namespace

// Gets the scale, zero-point, and zero-point type for a QuantizeLinear node that uses per-tensor quantization.
static bool GetQScalarScaleZeroPoint(const QnnModelWrapper& qnn_model_wrapper,
Expand Down Expand Up @@ -100,9 +100,9 @@ static bool GetQScalarScaleZeroPoint(const QnnModelWrapper& qnn_model_wrapper,

// Computes the floating point domain (min_, max_) from a QuantizeLinear node's scale/zero-point.
static bool GetQDomain(const QnnModelWrapper& qnn_model_wrapper,
const NodeUnit& q_node_unit,
/*out*/ float& min_,
/*out*/ float& max_) {
const NodeUnit& q_node_unit,

Check warning on line 103 in onnxruntime/core/providers/qnn/builder/qnn_node_group/conv_activation_fusion.cc

View workflow job for this annotation

GitHub Actions / Optional Lint C++

[cpplint] reported by reviewdog 🐶 Do not indent within a namespace. [whitespace/indent_namespace] [4] Raw Output: onnxruntime/core/providers/qnn/builder/qnn_node_group/conv_activation_fusion.cc:103: Do not indent within a namespace. [whitespace/indent_namespace] [4]
/*out*/ float& min_,

Check warning on line 104 in onnxruntime/core/providers/qnn/builder/qnn_node_group/conv_activation_fusion.cc

View workflow job for this annotation

GitHub Actions / Optional Lint C++

[cpplint] reported by reviewdog 🐶 Do not indent within a namespace. [whitespace/indent_namespace] [4] Raw Output: onnxruntime/core/providers/qnn/builder/qnn_node_group/conv_activation_fusion.cc:104: Do not indent within a namespace. [whitespace/indent_namespace] [4]
/*out*/ float& max_) {

Check warning on line 105 in onnxruntime/core/providers/qnn/builder/qnn_node_group/conv_activation_fusion.cc

View workflow job for this annotation

GitHub Actions / Optional Lint C++

[cpplint] reported by reviewdog 🐶 Do not indent within a namespace. [whitespace/indent_namespace] [4] Raw Output: onnxruntime/core/providers/qnn/builder/qnn_node_group/conv_activation_fusion.cc:105: Do not indent within a namespace. [whitespace/indent_namespace] [4]
int32_t zp_data_type = ONNX_NAMESPACE::TensorProto::DataType::TensorProto_DataType_UNDEFINED;
int32_t zero_point = 0;
float scale = 0.0f;
Expand Down

0 comments on commit 9696972

Please sign in to comment.