@@ -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 (
@@ -956,6 +962,8 @@ Error Method::execute_instruction() {
956
962
} break ;
957
963
case executorch_flatbuffer::InstructionArguments::JumpFalseCall: {
958
964
EXECUTORCH_SCOPE_PROF (" JF_CALL" );
965
+ internal::EventTracerProfileScope event_tracer_profile_scope =
966
+ internal::EventTracerProfileScope (event_tracer_, " JF_CALL" );
959
967
auto jf_call = instruction->instr_args_as_JumpFalseCall ();
960
968
bool jf_result = parse_cond_value (values_[jf_call->cond_value_index ()]);
961
969
if (!jf_result) {
@@ -965,11 +973,15 @@ Error Method::execute_instruction() {
965
973
} break ;
966
974
case executorch_flatbuffer::InstructionArguments::MoveCall: {
967
975
EXECUTORCH_SCOPE_PROF (" MOVE_CALL" );
976
+ internal::EventTracerProfileScope event_tracer_profile_scope =
977
+ internal::EventTracerProfileScope (event_tracer_, " MOVE_CALL" );
968
978
auto move_call = instruction->instr_args_as_MoveCall ();
969
979
mutable_value (move_call->move_to ()) = get_value (move_call->move_from ());
970
980
} break ;
971
981
case executorch_flatbuffer::InstructionArguments::FreeCall: {
972
982
EXECUTORCH_SCOPE_PROF (" FREE_CALL" );
983
+ internal::EventTracerProfileScope event_tracer_profile_scope =
984
+ internal::EventTracerProfileScope (event_tracer_, " FREE_CALL" );
973
985
auto free_call = instruction->instr_args_as_FreeCall ();
974
986
auto t = values_[free_call->value_index ()].toTensor ();
975
987
internal::reset_data_ptr (t);
@@ -997,7 +1009,14 @@ Error Method::experimental_step() {
997
1009
EXECUTORCH_PROFILE_INSTRUCTION_SCOPE (
998
1010
static_cast <int32_t >(step_state_.chain_idx ),
999
1011
static_cast <uint32_t >(step_state_.instr_idx ));
1012
+ internal::EventTracerProfileInstructionScope event_tracer_instr_scope =
1013
+ internal::EventTracerProfileInstructionScope (
1014
+ event_tracer_,
1015
+ static_cast <int32_t >(step_state_.chain_idx ),
1016
+ static_cast <uint32_t >(step_state_.instr_idx ));
1000
1017
EXECUTORCH_SCOPE_PROF (" Method::step" );
1018
+ internal::EventTracerProfileScope event_tracer_profile_scope =
1019
+ internal::EventTracerProfileScope (event_tracer_, " Method::step" );
1001
1020
ET_CHECK_OR_RETURN_ERROR (
1002
1021
initialized (),
1003
1022
InvalidState,
@@ -1032,6 +1051,9 @@ Error Method::experimental_step() {
1032
1051
}
1033
1052
1034
1053
Error Method::execute () {
1054
+ internal::event_tracer_create_event_block (event_tracer_, " Execute" );
1055
+ internal::EventTracerProfileScope event_tracer_profile_scope =
1056
+ internal::EventTracerProfileScope (event_tracer_, " Method::execute" );
1035
1057
EXECUTORCH_SCOPE_PROF (" Method::execute" );
1036
1058
ET_CHECK_OR_RETURN_ERROR (
1037
1059
initialized (),
@@ -1056,6 +1078,11 @@ Error Method::execute() {
1056
1078
EXECUTORCH_PROFILE_INSTRUCTION_SCOPE (
1057
1079
static_cast <int32_t >(step_state_.chain_idx ),
1058
1080
static_cast <uint32_t >(step_state_.instr_idx ));
1081
+ internal::EventTracerProfileInstructionScope event_tracer_instr_scope =
1082
+ internal::EventTracerProfileInstructionScope (
1083
+ event_tracer_,
1084
+ static_cast <ChainID>(step_state_.chain_idx ),
1085
+ static_cast <DebugHandle>(step_state_.instr_idx ));
1059
1086
auto status = execute_instruction ();
1060
1087
if (status != Error::Ok) {
1061
1088
return status;
0 commit comments