* -------------------------------------------------------------------------
* This file is part of the MindStudio project.
* Copyright (c) 2025 Huawei Technologies Co.,Ltd.
*
* MindStudio is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
*
* http://license.coscl.org.cn/MulanPSL2
*
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* -------------------------------------------------------------------------
*/
#include "../../TestSuit.h"
#include "ProtocolDefs.h"
#include "AclnnOpAdvisor.h"
#include "AffinityAPIAdvisor.h"
#include "AffinityOptimizerAdvisor.h"
#include "AICpuOpAdvisor.h"
#include "FusedOpAdvisor.h"
#include "OperatorDispatchAdvisor.h"
#include "DataBaseManager.h"
using namespace Dic::Protocol;
using namespace Dic::Module::Advisor;
using namespace Dic::Module::Timeline;
class AdvisorProcessTest : public TestSuit {
protected:
APITypeParams params = {.rankId = "0",
.deviceId = "0",
.currentPage = 2,
.pageSize = 20,
.orderBy = "duration",
.orderType = "ascend"};
};
TEST_F(AdvisorProcessTest, AclnnOpAdvisorProcessSuccessfulWithSpecificParam) {
AclnnOperatorResBody resBody = {};
auto res = AclnnOpAdvisor::Process(params, resBody);
EXPECT_EQ(res, true);
EXPECT_EQ(resBody.size, 0);
}
TEST_F(AdvisorProcessTest, AffinityAPIAdvisorProcessSuccessfulWithSpecificParam) {
AffinityAPIResBody resBody = {};
auto res = AffinityAPIAdvisor::Process(params, resBody);
EXPECT_EQ(res, true);
EXPECT_EQ(resBody.size, 24);
EXPECT_EQ(resBody.data.size(), 4);
}
TEST_F(AdvisorProcessTest, AffinityOptimizerAdvisorProcessSuccessfulWithSpecificParam) {
AffinityOptimizerResBody resBody = {};
auto res = AffinityOptimizerAdvisor::Process(params, resBody);
EXPECT_EQ(res, true);
EXPECT_EQ(resBody.size, 1);
}
TEST_F(AdvisorProcessTest, AICpuOpAdvisorProcessSuccessfulWithSpecificParam) {
AICpuOperatorResBody resBody = {};
auto res = AICpuOpAdvisor::Process(params, resBody);
EXPECT_EQ(res, true);
EXPECT_EQ(resBody.size, 2);
}
TEST_F(AdvisorProcessTest, FusedOpAdvisorProcessSuccessfulWithSpecificParam) {
OperatorFusionResBody resBody = {};
auto res = FusedOpAdvisor::Process(params, resBody);
EXPECT_EQ(res, true);
EXPECT_EQ(resBody.size, 0);
}
TEST_F(AdvisorProcessTest, OperatorDispatchAdvisorProcessSuccessfulWithSpecificParam) {
OperatorDispatchResBody resBody = {};
auto res = OperatorDispatchAdvisor::Process(params, resBody);
EXPECT_EQ(res, true);
EXPECT_EQ(resBody.size, 529);
}