[PIR save/load]Fix save combine memory #69683
                
     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 Category
Execute Infrastructure
PR Types
Performance
Description
pcard-67164
Fix save combine memory
save_combine存储参数时为保持save_to_memory参数的处理逻辑一致,会统一使用
ostringstream进行序列化,之后根据保存到内存或是文件中再做区分。这样在写入文件时再次构造ofstream导致最大内存占用为参数量大小的二倍,在参数量大的模型上会造成OOM。修改了旧IR
SaveCombineTensorKernel和PIRSaveCombineFunction中的序列化逻辑,其中SaveCombineTensorKernel中根据是否保存到内存中创建不同的二进制流传入序列化函数,避免二次内存占用。