Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 69 additions & 13 deletions backends/vulkan/runtime/VulkanBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,21 @@ class VulkanBackend final : public ::executorch::runtime::BackendInterface {

const size_t num_inputs = compute_graph->inputs().size();
bool should_propagate_resize = false;
#ifdef ET_EVENT_TRACER_ENABLED
runtime::EventTracer* event_tracer = context.event_tracer();
runtime::EventTracerEntry overall_event_tracer_entry =
event_tracer_start_profiling_delegate(
event_tracer,
"ETVK_EXECUTE",
/* delegate_debug_id = */ -1);
#endif // ET_EVENT_TRACER_ENABLED
#ifdef ET_EVENT_TRACER_ENABLED
runtime::EventTracerEntry copy_inputs_event_tracer_entry =
event_tracer_start_profiling_delegate(
event_tracer,
"ETVK_COPY_INPUTS",
/* delegate_debug_id = */ -1);
#endif // ET_EVENT_TRACER_ENABLED
for (size_t i = 0; i < num_inputs; i++) {
const ValueRef iref = compute_graph->inputs()[i].value;
if (compute_graph->val_is_tensor(iref)) {
Expand Down Expand Up @@ -669,13 +684,61 @@ class VulkanBackend final : public ::executorch::runtime::BackendInterface {
compute_graph->get_val_type(iref));
}
}
#ifdef ET_EVENT_TRACER_ENABLED
event_tracer_end_profiling_delegate(
event_tracer, copy_inputs_event_tracer_entry);
#endif // ET_EVENT_TRACER_ENABLED

if (should_propagate_resize || compute_graph->has_data_dependent_shapes()) {
#ifdef ET_EVENT_TRACER_ENABLED
runtime::EventTracerEntry resize_event_tracer_entry =
event_tracer_start_profiling_delegate(
event_tracer,
"ETVK_RESIZE",
/* delegate_debug_id = */ -1);
#endif // ET_EVENT_TRACER_ENABLED
compute_graph->propagate_resize();
#ifdef ET_EVENT_TRACER_ENABLED
event_tracer_end_profiling_delegate(
event_tracer, resize_event_tracer_entry);
#endif // ET_EVENT_TRACER_ENABLED
}

#ifdef ET_EVENT_TRACER_ENABLED
runtime::EventTracerEntry execute_event_tracer_entry =
event_tracer_start_profiling_delegate(
event_tracer,
"ETVK_COMPUTE_GRAPH_EXECUTE",
/* delegate_debug_id = */ -1);
#endif // ET_EVENT_TRACER_ENABLED
compute_graph->execute();
#ifdef ET_EVENT_TRACER_ENABLED
event_tracer_end_profiling_delegate(
event_tracer, execute_event_tracer_entry);
#endif // ET_EVENT_TRACER_ENABLED

#ifdef ET_EVENT_TRACER_ENABLED
compute_graph->context()->querypool().extract_results();
for (const auto& r :
compute_graph->context()->querypool().get_shader_timestamp_data()) {
std::string event_name = "{" + r.kernel_name +
", \"dispatch_id\": " + std::to_string(r.dispatch_id) + "}";
event_tracer_log_profiling_delegate(
event_tracer,
event_name.c_str(),
/* delegate_debug_id = */ -1,
r.start_time_ns,
r.end_time_ns);
}
#endif // ET_EVENT_TRACER_ENABLED

#ifdef ET_EVENT_TRACER_ENABLED
runtime::EventTracerEntry copy_outputs_event_tracer_entry =
event_tracer_start_profiling_delegate(
event_tracer,
"ETVK_COPY_OUTPUTS",
/* delegate_debug_id = */ -1);
#endif // ET_EVENT_TRACER_ENABLED
for (size_t i = 0; i < compute_graph->outputs().size(); i++) {
const size_t o = i + num_inputs;
const ValueRef oref = compute_graph->outputs()[i].value;
Expand All @@ -701,21 +764,14 @@ class VulkanBackend final : public ::executorch::runtime::BackendInterface {
compute_graph->get_val_type(oref));
}
}
#ifdef ET_EVENT_TRACER_ENABLED
event_tracer_end_profiling_delegate(
event_tracer, copy_outputs_event_tracer_entry);
#endif // ET_EVENT_TRACER_ENABLED

#ifdef ET_EVENT_TRACER_ENABLED
runtime::EventTracer* event_tracer = context.event_tracer();
compute_graph->context()->querypool().extract_results();
for (const auto& r :
compute_graph->context()->querypool().get_shader_timestamp_data()) {
std::string event_name = "{" + r.kernel_name +
", \"dispatch_id\": " + std::to_string(r.dispatch_id) + "}";
event_tracer_log_profiling_delegate(
event_tracer,
event_name.c_str(),
/* delegate_debug_id = */ -1,
r.start_time_ns,
r.end_time_ns);
}
event_tracer_end_profiling_delegate(
event_tracer, overall_event_tracer_entry);
#endif // ET_EVENT_TRACER_ENABLED

return Error::Ok;
Expand Down
19 changes: 1 addition & 18 deletions backends/vulkan/runtime/graph/ops/impl/Q8taConv2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,24 +401,7 @@ void q8ta_conv2d_general(
}

void q8ta_conv2d(ComputeGraph& graph, const std::vector<ValueRef>& args) {
// Index into args to extract values needed for dispatch decision
const ValueRef packed_int8_input = args.at(0);
const ValueRef kernel_size = args.at(9);
const ValueRef groups = args.at(13);

const int32_t groups_val = graph.get_int(groups);
const int64_t IC = graph.size_at<int64_t>(-3, packed_int8_input);

const int64_t K_h = graph.get_int_list(kernel_size)->at(0);
const int64_t K_w = graph.get_int_list(kernel_size)->at(1);

// Use im2col path when: non-grouped, input channels multiple of 4, small
// kernel
if (groups_val == 1 && IC % 4 == 0 && K_h <= 3 && K_w <= 3) {
q8ta_conv2d_im2col(graph, args);
} else {
q8ta_conv2d_general(graph, args);
}
q8ta_conv2d_general(graph, args);
}

REGISTER_OPERATORS {
Expand Down
Loading