Run_program_op add scope cache & reuse #45813
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR types
Performance optimization
PR changes
OPs
Describe
动转静调用run_program_op的执行过程中,每个step都会传入新的scope,在动转静接入新执行器,新执行器替换scope的开销较大,本pr设计了scope的cache和reuse策略,使得每个step无需传入新的scope,节省新执行器替换scope的开销。
Scope缓存的原则:
run_program_op内部通过program_id对执行器(interpretercore)进行缓存,为保证执行器与scope一致,因此,python 端的 partial_program 同样根据 program_id 对 scope 进行缓存,保证每个 program 对应同一套 执行器及 scope。
Scope复用的原则: