Skip to content

Commit

Permalink
LabelEncoder kernel creation improvement (microsoft#16516)
Browse files Browse the repository at this point in the history
  • Loading branch information
adityagoel4512 authored Jul 5, 2023
1 parent e252671 commit 9799d43
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions onnxruntime/core/providers/cpu/ml/label_encoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ class LabelEncoder_2 final : public OpKernel {
"(name: ", info.node().Name(), ") must have the same length. ",
"However, the number of key is ", num_keys, " and the number of ",
"values is ", num_values, ".");

_map.reserve(num_keys);
for (size_t i = 0; i < num_keys; ++i)
_map[keys[i]] = values[i];
_map.emplace(keys[i], values[i]);
}

Status Compute(OpKernelContext* context) const override {
Expand Down Expand Up @@ -98,7 +98,7 @@ class LabelEncoder_2 final : public OpKernel {
// A collection of key-value pairs. Each (a_key, a_value) pair
// means that the "a_key" in the input would be mapped to "a_value".
// If _map doesn't contain "a_key", we use _default_value as its output.
std::unordered_map<TKey, TValue> _map;
InlinedHashMap<TKey, TValue> _map;
TValue _default_value;
// ONNX attribute name to load keys.
std::string _key_field_name;
Expand Down

0 comments on commit 9799d43

Please sign in to comment.