torch::Tensor的文件存取

bool classA::saveCvecById(const std::string& user_id, at::Tensor cvec) {
#ifndef NDEBUG
    std::cerr << __FUNCTION__ << ": user_id: " << user_id << std::endl;
#endif
    std::string fileName = user_id + ".pt";
    torch::save(cvec, fileName);
    return true;
}

bool classA::readCvecById(const std::string& user_id, at::Tensor& cvec) {
#ifndef NDEBUG
    std::cerr << __FUNCTION__ << ": user_id: " << user_id << std::endl;
#endif
    std::string fileName = user_id + ".pt";
    torch::load(cvec, fileName);
    return true;
}

你可能感兴趣的:(c++)