| 246 | class GeometryTensorArrayGather : public GeometryComputer { |
| 247 | public: |
| 248 | virtual bool onCompute(const Op* op, const std::vector<Tensor*>& inputs, const std::vector<Tensor*>& outputs, |
| 249 | Context& context, CommandBuffer& res) const override { |
| 250 | auto tensorArrayInput = inputs[2]; |
| 251 | auto inDes = TensorUtils::getDescribe(tensorArrayInput); |
| 252 | if (inDes->tensorArrayAttr == nullptr) { |
| 253 | return false; |
| 254 | } |
| 255 | auto indicesTensor = inputs[1]; |
| 256 | std::vector<int> indices(indicesTensor->elementSize()); |
| 257 | for (int i = 0; i < indices.size(); i++) { |
| 258 | indices[i] = indicesTensor->host<int>()[i]; |
| 259 | } |
| 260 | auto output = outputs[0]; |
| 261 | auto outputDes = TensorUtils::getDescribe(output); |
| 262 | outputDes->memoryType = Tensor::InsideDescribe::MEMORY_VIRTUAL; |
| 263 | outputDes->regions.resize(indices.size()); |
| 264 | int arraySize = inDes->tensorArrayAttr->arraySize; |
| 265 | int dstOffset = 0; |
| 266 | for (int i = 0; i < indices.size(); i++) { |
| 267 | MNN_ASSERT(indices[i] < arraySize); |
| 268 | auto elemSize = getElemSize(tensorArrayInput, indices[i]); |
| 269 | auto& reg = outputDes->regions[i]; |
| 270 | reg.origin = tensorArrayInput; |
| 271 | reg.src.offset = elemSize.first; |
| 272 | reg.src.stride[0] = 1; |
| 273 | reg.src.stride[1] = 1; |
| 274 | reg.src.stride[2] = 1; |
| 275 | reg.dst.offset = dstOffset; |
| 276 | reg.dst.stride[0] = 1; |
| 277 | reg.dst.stride[1] = 1; |
| 278 | reg.dst.stride[2] = 1; |
| 279 | reg.size[0] = elemSize.second; |
| 280 | reg.size[1] = 1; |
| 281 | reg.size[2] = 1; |
| 282 | dstOffset += elemSize.second; |
| 283 | } |
| 284 | return true; |
| 285 | } |
| 286 | }; |
| 287 | |
| 288 | class GeometryTensorArrayScatter : public GeometryComputer { |
nothing calls this directly
no test coverage detected