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