【pir&npu】fix fetch op with memcpy_d2h use Npu indentity kernel. #72149
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
Bug fixes
Description
pcard-67164
x_data = paddle.static.data(shape=self.shape, name="data", dtype="float32")
output = paddle.incubate._npu_identity(x=x_data, format=self.format)
上述网络在PIR 下输出有误,原因是npu_identity b=不只是内存拷贝,还会根据format 修改内存布局,因此从npu 拷贝到cpu 时也需要用专用的kernel.
pir 的memcpy_d2h kernel 选择逻辑是按照src_place .type() 选backend, 所有的custom place 都选择custom backend , 而npu 注册了自己的kernel没被选到。 修改选kernel的逻辑,如果是customplace, 按照value.place 构造fake tensor, 进行kernr key set准备,按照优先级选到npu kernel。