MCPcopy Create free account
hub / github.com/alibaba/MNN / onCompute

Method onCompute

source/geometry/GeometryTensorArray.cpp:54–79  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52class GeometryTensorArray : public GeometryComputer {
53public:
54 virtual bool onCompute(const Op* op, const std::vector<Tensor*>& inputs, const std::vector<Tensor*>& outputs,
55 Context& context, CommandBuffer& res) const override {
56 if (TensorUtils::getDescribe(outputs[1])->tensorArrayAttr == nullptr) {
57 MNN_ASSERT(false);
58 return false;
59 }
60 if (TensorUtils::getDescribe(outputs[1])->tensorArrayAttr->arraySize > 0) {
61 auto type = outputs[1]->getType();
62 auto zeroConst = context.allocConst(op, {}, type);
63 if (type == halide_type_of<float>()) {
64 zeroConst->host<float>()[0] = 0.0;
65 } else {
66 zeroConst->host<int>()[0] = 0;
67 }
68 for (int i = 0; i < 2; i++) {
69 auto des = TensorUtils::getDescribe(outputs[i]);
70 des->memoryType = Tensor::InsideDescribe::MEMORY_VIRTUAL;
71 auto& regions = des->regions;
72 regions.resize(1);
73 regions[0].origin = zeroConst.get();
74 regions[0].size[0] = outputs[1]->elementSize();
75 regions[0].src.stride[0] = 0;
76 }
77 }
78 return true;
79 }
80};
81class GeometryTensorArraySize : public GeometryComputer {
82public:

Callers

nothing calls this directly

Calls 4

allocConstMethod · 0.80
getTypeMethod · 0.45
resizeMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected