Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xe: conv_v2: enable Stream-K kernels #2345

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
28 changes: 18 additions & 10 deletions src/gpu/intel/jit/utils/utils.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright 2021-2024 Intel Corporation
* Copyright 2021-2025 Intel Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -1344,26 +1344,34 @@ void stringify_to_cpp_file(const std::string &file_name,
const std::string &var_name, const std::vector<std::string> &namespaces,
const std::vector<std::string> &lines);

template <typename T>
std::string serialize_to_hex(const T &t) {
inline std::string data_to_hex(const std::vector<uint8_t> &data) {
std::ostringstream oss;
serialized_data_t s;
s.append(t);
for (uint8_t d : s.get_data()) {
for (auto v : data) {
oss << std::uppercase << std::hex << std::setw(2) << std::setfill('0')
<< (int)d;
<< (int)v;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: into<int>(v)

This conversion is perfectly safe, the suggestion is largely to prevent additional noise when searching for conversion issues. On the other hand, all unsafe conversion should go through into<T> to enable runtime validation in debug builds.

}
return oss.str();
}

template <typename T>
void deserialize_from_hex(T &t, const std::string &s_hex) {
inline std::vector<uint8_t> hex_to_data(const std::string &s_hex) {
std::vector<uint8_t> data;
for (size_t i = 0; i < s_hex.size(); i += 2) {
data.push_back(static_cast<uint8_t>(
std::stoi(s_hex.substr(i, 2), nullptr, 16)));
}
auto s = serialized_t::from_data(std::move(data));
return data;
}

template <typename T>
std::string serialize_to_hex(const T &t) {
serialized_data_t s;
s.append(t);
return data_to_hex(s.get_data());
}

template <typename T>
void deserialize_from_hex(T &t, const std::string &s_hex) {
auto s = serialized_t::from_data(hex_to_data(s_hex));
deserializer_t d(s);
d.pop(t);
}
Expand Down
4 changes: 3 additions & 1 deletion src/gpu/intel/serialization.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright 2023-2024 Intel Corporation
* Copyright 2023-2025 Intel Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -239,6 +239,8 @@ struct deserializer_t {
}
}

bool empty() const { return idx >= s.get_data().size(); }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
bool empty() const { return idx >= s.get_data().size(); }
bool empty() const { return s.get_data().empty(); }


size_t idx;
const serialized_data_t &s;
};
Expand Down