Skip to content

Commit

Permalink
Define cast_ordering as static constexpr array
Browse files Browse the repository at this point in the history
  • Loading branch information
adityagoel4512 committed Oct 18, 2023
1 parent 5d74f3a commit f1ac17d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions onnxruntime/core/optimizer/insert_cast_transformer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,11 @@ class RemoveDuplicateCastTransformer : public GraphTransformer {
}

private:
InlinedVector<std::string> cast_ordering{
static constexpr std::array<std::string_view, 13> cast_ordering{
"tensor(bool)", "tensor(uint8)", "tensor(uint16)", "tensor(uint32)", "tensor(uint64)", "tensor(int8)", "tensor(int16)",

Check warning on line 242 in onnxruntime/core/optimizer/insert_cast_transformer.cc

View workflow job for this annotation

GitHub Actions / Lint C++

[cpplint] reported by reviewdog 🐶 Lines should be <= 120 characters long [whitespace/line_length] [2] Raw Output: onnxruntime/core/optimizer/insert_cast_transformer.cc:242: Lines should be <= 120 characters long [whitespace/line_length] [2]
"tensor(int32)", "tensor(int64)", "tensor(bfloat16)", "tensor(float16)", "tensor(float)", "tensor(double)"};

inline bool LossOfPrecision(DataType src_type, DataType dst_type, const Node& node) const {
static bool LossOfPrecision(DataType src_type, DataType dst_type, const Node& node) {
// The comparison with "InsertedPrecisionFreeCast_" reflects cast nodes that are inserted by InsertCastTransformer.
// Such casts should not be considered as loss of precision - the inserted upcasts (f16 -> f32) and downcasts (f32 -> f16) are inserted to support kernels when on a CPU EP without F16 support.

Check warning on line 247 in onnxruntime/core/optimizer/insert_cast_transformer.cc

View workflow job for this annotation

GitHub Actions / Lint C++

[cpplint] reported by reviewdog 🐶 Lines should be <= 120 characters long [whitespace/line_length] [2] Raw Output: onnxruntime/core/optimizer/insert_cast_transformer.cc:247: Lines should be <= 120 characters long [whitespace/line_length] [2]
auto src_pos = std::find(cast_ordering.begin(), cast_ordering.end(), *src_type);
Expand Down

0 comments on commit f1ac17d

Please sign in to comment.