@@ -505,6 +505,8 @@ Result<Method> Method::load(
505
505
506
506
Error Method::init (executorch_flatbuffer::ExecutionPlan* s_plan) {
507
507
EXECUTORCH_SCOPE_PROF (" Method::init" );
508
+ internal::EventTracerProfileScope event_tracer_profile_scope =
509
+ internal::EventTracerProfileScope (event_tracer_, " Method::init" );
508
510
ET_CHECK_OR_RETURN_ERROR (
509
511
// Don't use !initialized() here because we also want to fail on the
510
512
// InitializationFailed state.
@@ -902,6 +904,8 @@ Error Method::execute_instruction() {
902
904
switch (instruction->instr_args_type ()) {
903
905
case executorch_flatbuffer::InstructionArguments::KernelCall: {
904
906
EXECUTORCH_SCOPE_PROF (" OPERATOR_CALL" );
907
+ internal::EventTracerProfileScope event_tracer_scope =
908
+ internal::EventTracerProfileScope (event_tracer_, " OPERATOR_CALL" );
905
909
// TODO(T147221312): Also expose the temp allocator and tensor resizer
906
910
// via the context.
907
911
KernelRuntimeContext context (event_tracer_);
@@ -934,6 +938,8 @@ Error Method::execute_instruction() {
934
938
} break ;
935
939
case executorch_flatbuffer::InstructionArguments::DelegateCall: {
936
940
EXECUTORCH_SCOPE_PROF (" DELEGATE_CALL" );
941
+ internal::EventTracerProfileScope event_tracer_profile_scope =
942
+ internal::EventTracerProfileScope (event_tracer_, " DELEGATE_CALL" );
937
943
auto delegate_idx =
938
944
instruction->instr_args_as_DelegateCall ()->delegate_index ();
939
945
ET_CHECK_OR_RETURN_ERROR (
@@ -959,6 +965,8 @@ Error Method::execute_instruction() {
959
965
} break ;
960
966
case executorch_flatbuffer::InstructionArguments::JumpFalseCall: {
961
967
EXECUTORCH_SCOPE_PROF (" JF_CALL" );
968
+ internal::EventTracerProfileScope event_tracer_profile_scope =
969
+ internal::EventTracerProfileScope (event_tracer_, " JF_CALL" );
962
970
auto jf_call = instruction->instr_args_as_JumpFalseCall ();
963
971
bool jf_result = parse_cond_value (values_[jf_call->cond_value_index ()]);
964
972
if (!jf_result) {
@@ -968,11 +976,15 @@ Error Method::execute_instruction() {
968
976
} break ;
969
977
case executorch_flatbuffer::InstructionArguments::MoveCall: {
970
978
EXECUTORCH_SCOPE_PROF (" MOVE_CALL" );
979
+ internal::EventTracerProfileScope event_tracer_profile_scope =
980
+ internal::EventTracerProfileScope (event_tracer_, " MOVE_CALL" );
971
981
auto move_call = instruction->instr_args_as_MoveCall ();
972
982
mutable_value (move_call->move_to ()) = get_value (move_call->move_from ());
973
983
} break ;
974
984
case executorch_flatbuffer::InstructionArguments::FreeCall: {
975
985
EXECUTORCH_SCOPE_PROF (" FREE_CALL" );
986
+ internal::EventTracerProfileScope event_tracer_profile_scope =
987
+ internal::EventTracerProfileScope (event_tracer_, " FREE_CALL" );
976
988
auto free_call = instruction->instr_args_as_FreeCall ();
977
989
auto t = values_[free_call->value_index ()].toTensor ();
978
990
internal::reset_data_ptr (t);
@@ -1000,7 +1012,14 @@ Error Method::experimental_step() {
1000
1012
EXECUTORCH_PROFILE_INSTRUCTION_SCOPE (
1001
1013
static_cast <int32_t >(step_state_.chain_idx ),
1002
1014
static_cast <uint32_t >(step_state_.instr_idx ));
1015
+ internal::EventTracerProfileInstructionScope event_tracer_instr_scope =
1016
+ internal::EventTracerProfileInstructionScope (
1017
+ event_tracer_,
1018
+ static_cast <int32_t >(step_state_.chain_idx ),
1019
+ static_cast <uint32_t >(step_state_.instr_idx ));
1003
1020
EXECUTORCH_SCOPE_PROF (" Method::step" );
1021
+ internal::EventTracerProfileScope event_tracer_profile_scope =
1022
+ internal::EventTracerProfileScope (event_tracer_, " Method::step" );
1004
1023
ET_CHECK_OR_RETURN_ERROR (
1005
1024
initialized (),
1006
1025
InvalidState,
@@ -1035,6 +1054,9 @@ Error Method::experimental_step() {
1035
1054
}
1036
1055
1037
1056
Error Method::execute () {
1057
+ internal::event_tracer_create_event_block (event_tracer_, " Execute" );
1058
+ internal::EventTracerProfileScope event_tracer_profile_scope =
1059
+ internal::EventTracerProfileScope (event_tracer_, " Method::execute" );
1038
1060
EXECUTORCH_SCOPE_PROF (" Method::execute" );
1039
1061
ET_CHECK_OR_RETURN_ERROR (
1040
1062
initialized (),
@@ -1059,6 +1081,11 @@ Error Method::execute() {
1059
1081
EXECUTORCH_PROFILE_INSTRUCTION_SCOPE (
1060
1082
static_cast <int32_t >(step_state_.chain_idx ),
1061
1083
static_cast <uint32_t >(step_state_.instr_idx ));
1084
+ internal::EventTracerProfileInstructionScope event_tracer_instr_scope =
1085
+ internal::EventTracerProfileInstructionScope (
1086
+ event_tracer_,
1087
+ static_cast <ChainID>(step_state_.chain_idx ),
1088
+ static_cast <DebugHandle>(step_state_.instr_idx ));
1062
1089
auto status = execute_instruction ();
1063
1090
if (status != Error::Ok) {
1064
1091
return status;
0 commit comments