| 880 | } |
| 881 | |
| 882 | virtual ErrorCode onExecute(const std::vector<Tensor *> &originInputs, const std::vector<Tensor *> &originOutputs) override { |
| 883 | auto cpubackend = static_cast<CPUBackend*>(backend()); |
| 884 | auto precision = cpubackend->precisionMode(); |
| 885 | auto threadNumber = cpubackend->threadNumber(); |
| 886 | if (mLoop->initCommand() != nullptr) { |
| 887 | for (int i=0; i<mLoop->initCommand()->size(); ++i) { |
| 888 | auto cmd = mLoop->initCommand()->GetAs<RegionCommand>(i); |
| 889 | if (cmd->op() == nullptr) { |
| 890 | auto output = mStack[cmd->indexes()->data()[0]]; |
| 891 | ::memset(output->host<void>(), 0, cpubackend->getTensorSize(output) * cpubackend->functions()->bytes); |
| 892 | } else { |
| 893 | Tensor::InsideDescribe::Region reg; |
| 894 | auto srcView = cmd->view()->GetAs<View>(1); |
| 895 | auto dstView = cmd->view()->GetAs<View>(0); |
| 896 | ::memcpy(reg.size, cmd->size()->data(), 3 * sizeof(int32_t)); |
| 897 | ::memcpy(reg.src.stride, srcView->stride()->data(), 3 * sizeof(int32_t)); |
| 898 | ::memcpy(reg.dst.stride, dstView->stride()->data(), 3 * sizeof(int32_t)); |
| 899 | auto input = mStack[cmd->indexes()->data()[1]]; |
| 900 | auto inputSize = input->elementSize(); |
| 901 | auto output = mStack[cmd->indexes()->data()[0]]; |
| 902 | auto bytes = input->getType().bytes(); |
| 903 | if (halide_type_float == input->getType().code) { |
| 904 | bytes = cpubackend->functions()->bytes; |
| 905 | } |
| 906 | _blit(reg, bytes, input->host<uint8_t>(), output->host<uint8_t>(), false); |
| 907 | } |
| 908 | |
| 909 | } |
| 910 | } |
| 911 | if (1 == mLoop->commands()->size()) { |
| 912 | auto cmd = mLoop->commands()->GetAs<RegionCommand>(0); |
| 913 | auto op = cmd->op(); |
| 914 | if (OpType_UnaryOp == op->type() && nullptr == op->main() && cmd->fuse() < 0) { |
| 915 | // For Gather / Single Unary |
| 916 | auto index0 = cmd->iterIndexes()->data()[0]; |
| 917 | auto index1 = cmd->iterIndexes()->data()[1]; |
| 918 | int32_t iter = 0; |
| 919 | int32_t* iter0 = &iter; |
| 920 | int32_t* iter1 = &iter; |
| 921 | int32_t iter0Stride = 0; |
| 922 | int32_t iter1Stride = 0; |
| 923 | if (index0 >= 0) { |
| 924 | iter0 = originInputs[index0]->host<int32_t>(); |
| 925 | iter0Stride = 1; |
| 926 | } |
| 927 | if (index1 >= 0) { |
| 928 | iter1 = originInputs[index1]->host<int32_t>(); |
| 929 | iter1Stride = 1; |
| 930 | } |
| 931 | Tensor::InsideDescribe::Region reg; |
| 932 | auto srcView = cmd->view()->GetAs<View>(1); |
| 933 | auto dstView = cmd->view()->GetAs<View>(0); |
| 934 | ::memcpy(reg.size, cmd->size()->data(), 3 * sizeof(int32_t)); |
| 935 | ::memcpy(reg.src.stride, srcView->stride()->data(), 3 * sizeof(int32_t)); |
| 936 | ::memcpy(reg.dst.stride, dstView->stride()->data(), 3 * sizeof(int32_t)); |
| 937 | auto input = mStack[cmd->indexes()->data()[1]]; |
| 938 | auto inputSize = input->usize() / input->buffer().type.bytes(); |
| 939 | auto output = mStack[cmd->indexes()->data()[0]]; |
nothing calls this directly
no test coverage detected