| 484 | class GeometryTensorArrayErase : public GeometryComputer { |
| 485 | public: |
| 486 | virtual bool onCompute(const Op* op, const std::vector<Tensor*>& inputs, const std::vector<Tensor*>& outputs, |
| 487 | Context& context, CommandBuffer& res) const override { |
| 488 | auto tensorArrayInput = inputs[2]; |
| 489 | auto inDes = TensorUtils::getDescribe(tensorArrayInput); |
| 490 | if (inDes->tensorArrayAttr == nullptr) { |
| 491 | MNN_ASSERT(false); |
| 492 | return false; |
| 493 | } |
| 494 | auto output = outputs[0]; |
| 495 | auto outputDes = TensorUtils::getDescribe(output); |
| 496 | outputDes->memoryType = Tensor::InsideDescribe::MEMORY_VIRTUAL; |
| 497 | |
| 498 | int eraseIndex = inputs[1]->host<int32_t>()[0], oldSize = inDes->tensorArrayAttr->arraySize; |
| 499 | eraseIndex += (eraseIndex < 0 ? oldSize: 0); |
| 500 | auto eleSize = getElemSize(tensorArrayInput, eraseIndex); |
| 501 | outputDes->regions.clear(); |
| 502 | if (eraseIndex > 0) { |
| 503 | Tensor::InsideDescribe::Region reg; |
| 504 | reg.origin = tensorArrayInput; |
| 505 | reg.src.offset = 0; |
| 506 | reg.src.stride[0] = reg.src.stride[1] = reg.src.stride[2] = 1; |
| 507 | reg.dst.offset = 0; |
| 508 | reg.dst.stride[0] = reg.dst.stride[1] = reg.dst.stride[2] = 1; |
| 509 | reg.size[0] = eleSize.first; |
| 510 | reg.size[1] = reg.size[2] = 1; |
| 511 | outputDes->regions.push_back(reg); |
| 512 | } |
| 513 | if (eraseIndex < oldSize - 1) { |
| 514 | int offset = eleSize.first + eleSize.second; |
| 515 | Tensor::InsideDescribe::Region reg; |
| 516 | reg.origin = tensorArrayInput; |
| 517 | reg.src.offset = offset; |
| 518 | reg.src.stride[0] = reg.src.stride[1] = reg.src.stride[2] = 1; |
| 519 | reg.dst.offset = eleSize.first; |
| 520 | reg.dst.stride[0] = reg.dst.stride[1] = reg.dst.stride[2] = 1; |
| 521 | reg.size[0] = tensorArrayInput->elementSize() - offset; |
| 522 | reg.size[1] = reg.size[2] = 1; |
| 523 | outputDes->regions.push_back(reg); |
| 524 | } |
| 525 | return true; |
| 526 | } |
| 527 | }; |
| 528 | |
| 529 | static void _create() { |
nothing calls this directly
no test coverage detected