-
Notifications
You must be signed in to change notification settings - Fork 607
[ET-VK][ez] Replace std::stringstream
with std::string
for Shader names
#2964
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,14 +75,15 @@ void add_binary_op_node( | |
const api::utils::ivec2 broadcast_params = | ||
create_broadcast_params(t_in1, t_in2); | ||
|
||
std::stringstream kernel_name; | ||
kernel_name << "binary_" << op_name; | ||
apply_memory_layout_suffix(kernel_name, t_out); | ||
apply_dtype_suffix(kernel_name, t_out); | ||
std::string kernel_name("binary_"); | ||
kernel_name.reserve(kShaderNameReserve); | ||
Comment on lines
+78
to
+79
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: you would be slightly better off reserving before writing |
||
kernel_name += op_name; | ||
add_memory_layout_suffix(kernel_name, t_out); | ||
add_dtype_suffix(kernel_name, t_out); | ||
|
||
graph.execute_nodes().emplace_back(new ExecuteNode( | ||
graph, | ||
VK_KERNEL_FROM_STR(kernel_name.str()), | ||
VK_KERNEL_FROM_STR(kernel_name), | ||
global_size, | ||
local_size, | ||
// Inputs and Outputs | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,15 +63,15 @@ void record_conv2d_prepack_weights_op( | |
const bool transposed) { | ||
api::PipelineBarrier pipeline_barrier{}; | ||
|
||
std::stringstream kernel_name; | ||
std::string kernel_name; | ||
if (transposed) { | ||
kernel_name << "conv_transpose2d"; | ||
kernel_name = "conv_transpose2d"; | ||
} else { | ||
kernel_name << "conv2d"; | ||
kernel_name = "conv2d"; | ||
} | ||
kernel_name << "_prepack_weights"; | ||
apply_dtype_suffix(kernel_name, v_dst); | ||
api::ShaderInfo shader = VK_KERNEL_FROM_STR(kernel_name.str()); | ||
kernel_name += "_prepack_weights"; | ||
add_dtype_suffix(kernel_name, v_dst); | ||
api::ShaderInfo shader = VK_KERNEL_FROM_STR(kernel_name); | ||
|
||
api::UniformParamsBuffer original_sizes_ubo( | ||
context, api::utils::make_ivec4(original_sizes, /*reverse = */ true)); | ||
|
@@ -100,13 +100,12 @@ void record_binary_op( | |
vTensor& v_in1, | ||
vTensor& v_in2, | ||
vTensor& v_dst) { | ||
std::stringstream kernel_name; | ||
kernel_name << "binary_" << op_name << "_nobroadcast__test"; | ||
apply_dtype_suffix(kernel_name, v_dst); | ||
std::string kernel_name = "binary_" + op_name + "_nobroadcast__test"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. building a string with |
||
add_dtype_suffix(kernel_name, v_dst); | ||
|
||
api::PipelineBarrier pipeline_barrier{}; | ||
context->submit_compute_job( | ||
VK_KERNEL_FROM_STR(kernel_name.str()), | ||
VK_KERNEL_FROM_STR(kernel_name), | ||
pipeline_barrier, | ||
v_dst.virtual_extents(), | ||
adaptive_work_group_size(v_dst.virtual_extents()), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,9 +49,8 @@ TEST_F(VulkanComputeAPITest, update_params_between_submit) { | |
std::vector<int64_t> sizes = {4, 4, 2}; | ||
vTensor a = CREATE_FLOAT_TEXTURE(sizes, /*allocate_memory = */ true); | ||
|
||
std::stringstream kernel_name; | ||
kernel_name << "fill_texture__test"; | ||
apply_dtype_suffix(kernel_name, a); | ||
std::string kernel_name("fill_texture__test"); | ||
add_dtype_suffix(kernel_name, a); | ||
Comment on lines
+52
to
+53
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto ditto |
||
|
||
struct Params final { | ||
api::utils::ivec3 size; | ||
|
@@ -70,7 +69,7 @@ TEST_F(VulkanComputeAPITest, update_params_between_submit) { | |
{ | ||
api::PipelineBarrier pipeline_barrier{}; | ||
api::context()->submit_compute_job( | ||
VK_KERNEL_FROM_STR(kernel_name.str()), | ||
VK_KERNEL_FROM_STR(kernel_name), | ||
pipeline_barrier, | ||
{4, 4, 4}, | ||
{4, 4, 4}, | ||
|
@@ -748,15 +747,14 @@ void run_from_gpu_test( | |
vTensor vten = | ||
vTensor(api::context(), sizes, api::kFloat, storage_type, memory_layout); | ||
|
||
std::stringstream kernel_name; | ||
kernel_name << "idx_fill_texture"; | ||
apply_memory_layout_suffix(kernel_name, vten); | ||
apply_dtype_suffix(kernel_name, vten); | ||
std::string kernel_name("idx_fill_texture"); | ||
add_memory_layout_suffix(kernel_name, vten); | ||
add_dtype_suffix(kernel_name, vten); | ||
Comment on lines
+750
to
+752
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto missing reserve; inline size is as little as 16 bytes with libstdc++ (which I don't know if we use). |
||
|
||
{ | ||
api::PipelineBarrier pipeline_barrier{}; | ||
api::context()->submit_compute_job( | ||
VK_KERNEL_FROM_STR(kernel_name.str()), | ||
VK_KERNEL_FROM_STR(kernel_name), | ||
pipeline_barrier, | ||
vten.virtual_extents(), | ||
{4, 4, 4}, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this path doesn't use reserve, so on platforms without SSO this implementation could be worse. (It looks like the string data fits in 16 bytes otherwise, in which case you're good on libstdc++ and libc++, but it would be easy to break that in the future.)