| 44 | return iter->second; |
| 45 | } |
| 46 | std::shared_ptr<Tensor> GeometryComputer::Context::allocConst(const Op* key, const std::vector<int>& shape, |
| 47 | halide_type_t type, Tensor::DimensionType dimType) { |
| 48 | std::shared_ptr<Tensor> tensor(Tensor::createDevice(shape, type, dimType)); |
| 49 | TensorUtils::getDescribe(tensor.get())->usage = Tensor::InsideDescribe::CONSTANT; |
| 50 | auto res = mBackend->onAcquireBuffer(tensor.get(), Backend::STATIC); |
| 51 | if (!res) { |
| 52 | return nullptr; |
| 53 | } |
| 54 | TensorUtils::getDescribeOrigin(tensor.get())->setBackend(mBackend.get()); |
| 55 | auto iter = mConstTensors.find(key); |
| 56 | if (iter != mConstTensors.end()) { |
| 57 | iter->second.emplace_back(tensor); |
| 58 | } else { |
| 59 | mTempConstTensors.emplace_back(tensor); |
| 60 | } |
| 61 | return tensor; |
| 62 | } |
| 63 | |
| 64 | bool GeometryComputer::Context::allocTensor(Tensor* tensor) { |
| 65 | auto res = mBackend->onAcquireBuffer(tensor, Backend::STATIC); |
no test coverage detected