下载
中文
注册
我要评分
文档获取效率
文档正确性
内容完整性
文档易理解
在线提单
论坛求助
昇腾小AI

Sample样例(C++)

#include "AscendHac.h"
#include "ErrorCode.h"
#include <string>
#include <iostream>
#include <map>
using namespace ascendhac;

int main(int argc, char *argv[])
{
    std::map<std::string, std::string> configData;

    //  < ---------- General Config ---------- >
    configData["ArchiveName"] = "Demo";
    configData["ArchiveMode"] = "ARCHIVE";
    configData["FeatureDim"] = "512";
    configData["FeatureDataType"] = "FP32";
    configData["FeatureSource"] = "RANDOM";
    configData["MetricType"] = "IP";
    configData["ExactSearchIndexType"] = "FLAT";
    configData["ExactSearchThreshold"] = "50000";
    configData["ApproximateSearchIndexType"] = "IVFSQ";
    configData["ApproximateSearchThreshold"] = "5000000";
    configData["Nlist"] = "1024";
    configData["Nprobe"] = "32";
    configData["DimReduction"] = "TRUE";
    configData["ShortDim"] = "64";
    configData["Devices"] = "0,1,2,3";
    configData["ThreadNum"] = "16";
    configData["ResourcesSize"] = "128";
    //  < ---------- Archive Config ---------- >
    configData["FeatureCount"] = "10000";
    configData["NeedNormalize"] = "TRUE";
    configData["PointPointThreshold"] = "0.875";
    configData["PointClusterThreshold"] = "0.7";
    configData["ClusterClusterThreshold"] = "0.8";
    configData["MinRankDistance"] = "6";
    configData["MaxRankDistance"] = "10";
    configData["MinPicNum"] = "2";
    configData["MaxCoverNum"] = "1";

    AscendHac ascendHac;
    if (ascendHac.Init(configData) != APP_ERR_OK) {
        std::cout << "[Error] Init Archive failed, please check config file!" << std::endl;
        ascendHac.Release();
        return -1;
    }

    if (ascendHac.SetArchiveInputRandomly() != APP_ERR_OK) {
        std::cout << "[Error] Set input data failed!" << std::endl;
        ascendHac.Release();
        return -1;
    }

    if (ascendHac.Run() != APP_ERR_OK) {
        std::cout << "[Error] Archive failed, please check config file!" << std::endl;
        ascendHac.Release();
        return -1;
    }

    if (ascendHac.SaveDataToFile() != APP_ERR_OK) {
        std::cout << "[ERROR] Save to file failed" << std::endl;
        ascendHac.Release();
        return -1;
    }

    if (ascendHac.Release() != APP_ERR_OK) {
        std::cout << "[ERROR] Resources released failed" << std::endl;
        ascendHac.Release();
        return -1;
    }

    std::cout << "Archive successfully!" << std::endl;
    return 0;
}
搜索结果
找到“0”个结果

当前产品无相关内容

未找到相关内容,请尝试其他搜索词