Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions tools/projmgr/include/ProjMgrMlops.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ class ProjMgrMlops {
std::string BuildActive(const std::string& targetType, const std::string& targetSet) const;
std::string GetCustomScalar(const CustomItem& custom, const std::string& key) const;
std::string BuildVelaOptions(const MlopsNpuType& npu, const MlopsVelaItem& vela) const;
bool ResolveMlopsPath(std::string& path, const std::string& solutionDir,
bool hardwareFound, ContextItem& hardwareContext) const;
void SetMlopsRunType(MlopsRunType& run, const std::string& targetType, const std::string& targetSet,
const std::vector<ContextItem>& contexts, const std::string& outBaseDir, const std::string& solutionName) const;
};
Expand Down
95 changes: 47 additions & 48 deletions tools/projmgr/src/ProjMgrMlops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

#include "ProjMgrMlops.h"

#include "ProjMgrLogger.h"
#include "ProjMgrParser.h"
#include "ProjMgrUtils.h"

Expand All @@ -27,7 +26,6 @@ bool ProjMgrMlops::FindTargetType(const CsolutionItem& csolution, const string&
return true;
}
}
ProjMgrLogger::Get().Error("mlops: target-type '" + typeName + "' not found");
return false;
}

Expand All @@ -41,7 +39,6 @@ bool ProjMgrMlops::GetTargetSetItemRef(const TargetType& targetType, const strin
return true;
}
}
ProjMgrLogger::Get().Error("mlops: simulator target with debugger 'Arm-FVP' not found");
return false;
}
if (!targetType.targetSet.empty()) {
Expand All @@ -56,8 +53,6 @@ bool ProjMgrMlops::GetTargetSetItemRef(const TargetType& targetType, const strin
}
}
}
ProjMgrLogger::Get().Error("mlops: target-type '" + targetTypeName + "' target-set '" +
(targetSetName.empty() ? "<default>" : targetSetName) + "' not found");
return false;
}

Expand Down Expand Up @@ -91,6 +86,20 @@ string ProjMgrMlops::BuildVelaOptions(const MlopsNpuType& npu, const MlopsVelaIt
return options;
}

bool ProjMgrMlops::ResolveMlopsPath(string& path, const string& solutionDir,
bool hardwareFound, ContextItem& hardwareContext) const {
if (hardwareFound && !m_worker->ProcessSequenceRelative(hardwareContext, path, solutionDir, false)) {
return false;
}
if (ProjMgrUtils::HasAccessSequence(path)) {
path.clear();
} else if (RteFsUtils::IsRelative(path)) {
const auto& baseDir = hardwareFound ? hardwareContext.directories.cprj : solutionDir;
RteFsUtils::NormalizePath(path, baseDir);
}
return true;
}

void ProjMgrMlops::SetMlopsRunType(MlopsRunType& run, const string& targetType, const string& targetSet,
const vector<ContextItem>& contexts, const string& outBaseDir, const string& solutionName) const {
run.active = BuildActive(targetType, targetSet);
Expand Down Expand Up @@ -119,17 +128,15 @@ bool ProjMgrMlops::CollectSettings(const CsolutionItem& csolution, MlopsType& ml
// get hardware set
TargetType hardwareTargetType;
TargetSetItem hardwareTargetSet;
if (!FindTargetType(csolution, hardwareType, hardwareTargetType) ||
!GetTargetSetItemRef(hardwareTargetType, hardwareType, solutionMlops.hardware.targetSet, false, hardwareTargetSet)) {
return false;
if (FindTargetType(csolution, hardwareType, hardwareTargetType)) {
GetTargetSetItemRef(hardwareTargetType, hardwareType, solutionMlops.hardware.targetSet, false, hardwareTargetSet);
}

// get simulator set
TargetType simulatorTargetType;
TargetSetItem simulatorTargetSet;
if (!FindTargetType(csolution, simulatorType, simulatorTargetType) ||
!GetTargetSetItemRef(simulatorTargetType, simulatorType, solutionMlops.simulator.targetSet, true, simulatorTargetSet)) {
return false;
if (FindTargetType(csolution, simulatorType, simulatorTargetType)) {
GetTargetSetItemRef(simulatorTargetType, simulatorType, solutionMlops.simulator.targetSet, true, simulatorTargetSet);
}

// get all context items
Expand Down Expand Up @@ -164,20 +171,11 @@ bool ProjMgrMlops::CollectSettings(const CsolutionItem& csolution, MlopsType& ml
}

// check if hardware and simulator contexts were found
vector<tuple<const vector<ContextItem>&, const string&, const string&>> contextRefs = {
{hardwareContexts, hardwareType, hardwareTargetSet.set},
{simulatorContexts, simulatorType, simulatorTargetSet.set}
};
for (const auto& [ref, targetType, targetSet] : contextRefs) {
if (ref.empty()) {
ProjMgrLogger::Get().Error("mlops: target-type '" + targetType + "' target-set '" +
(targetSet.empty() ? "<default>" : targetSet) + "' project-contexts not found");
return false;
}
}

auto& hardwareContext = hardwareContexts.front();
auto& simulatorContext = simulatorContexts.front();
bool hardwareFound = !hardwareContexts.empty();
bool simulatorFound = !simulatorContexts.empty();
ContextItem defaultContext;
ContextItem& hardwareContext = hardwareFound ? hardwareContexts.front() : defaultContext;
ContextItem& simulatorContext = simulatorFound ? simulatorContexts.front() : defaultContext;

// mlops description
mlops.description = solutionMlops.description;
Expand Down Expand Up @@ -244,40 +242,41 @@ bool ProjMgrMlops::CollectSettings(const CsolutionItem& csolution, MlopsType& ml
} else {
// explicit vela ini
mlops.vela.ini = solutionMlops.vela.ini;
if (!m_worker->ProcessSequenceRelative(hardwareContext, mlops.vela.ini, csolution.directory, false)) {
if (!ResolveMlopsPath(mlops.vela.ini, csolution.directory, hardwareFound, hardwareContext)) {
return false;
}
if (RteFsUtils::IsRelative(mlops.vela.ini)) {
RteFsUtils::NormalizePath(mlops.vela.ini, hardwareContext.directories.cprj);
}
}

// model name and clayer
if (!solutionMlops.model.clayer.empty()) {
mlops.model.name = solutionMlops.model.name.empty() ? "Algorithm" : solutionMlops.model.name;
mlops.model.clayer = solutionMlops.model.clayer;
if (!m_worker->ProcessSequenceRelative(hardwareContext, mlops.model.clayer, csolution.directory, false)) {
if (!ResolveMlopsPath(mlops.model.clayer, csolution.directory, hardwareFound, hardwareContext)) {
return false;
}
if (RteFsUtils::IsRelative(mlops.model.clayer)) {
RteFsUtils::NormalizePath(mlops.model.clayer, hardwareContext.directories.cprj);
}
}
}

// set hardware and simulator run types
const string outBaseDir = hardwareContext.directories.cprj + "/" + hardwareContext.directories.outBaseDir;
SetMlopsRunType(mlops.hardware, hardwareType, hardwareTargetSet.set, hardwareContexts, outBaseDir, csolution.name);
SetMlopsRunType(mlops.simulator, simulatorType, simulatorTargetSet.set, simulatorContexts, outBaseDir, csolution.name);
if (hardwareFound) {
// set hardware run types
const string outBaseDir = hardwareContext.directories.cprj + "/" + hardwareContext.directories.outBaseDir;
SetMlopsRunType(mlops.hardware, hardwareType, hardwareTargetSet.set, hardwareContexts, outBaseDir, csolution.name);
}

// get debugger model and config-file
mlops.simulator.model = GetCustomScalar(simulatorTargetSet.debugger.custom, "model");
mlops.simulator.configFile = GetCustomScalar(simulatorTargetSet.debugger.custom, "config-file");
if (!mlops.simulator.configFile.empty()) {
if (!m_worker->ProcessSequenceRelative(simulatorContext, mlops.simulator.configFile, csolution.directory, false)) {
return false;
}
if (RteFsUtils::IsRelative(mlops.simulator.configFile)) {
RteFsUtils::NormalizePath(mlops.simulator.configFile, simulatorContext.directories.cprj);
if (simulatorFound) {
// set simulator run types
const string outBaseDir = simulatorContext.directories.cprj + "/" + simulatorContext.directories.outBaseDir;
SetMlopsRunType(mlops.simulator, simulatorType, simulatorTargetSet.set, simulatorContexts, outBaseDir, csolution.name);

// get debugger model and config-file
mlops.simulator.model = GetCustomScalar(simulatorTargetSet.debugger.custom, "model");
mlops.simulator.configFile = GetCustomScalar(simulatorTargetSet.debugger.custom, "config-file");
if (!mlops.simulator.configFile.empty()) {
if (!m_worker->ProcessSequenceRelative(simulatorContext, mlops.simulator.configFile, csolution.directory, false)) {
return false;
}
if (RteFsUtils::IsRelative(mlops.simulator.configFile)) {
RteFsUtils::NormalizePath(mlops.simulator.configFile, simulatorContext.directories.cprj);
}
}
}

Expand Down
18 changes: 0 additions & 18 deletions tools/projmgr/test/data/MLOps/failure1.csolution.yml

This file was deleted.

18 changes: 0 additions & 18 deletions tools/projmgr/test/data/MLOps/failure2.csolution.yml

This file was deleted.

20 changes: 0 additions & 20 deletions tools/projmgr/test/data/MLOps/failure3.csolution.yml

This file was deleted.

2 changes: 0 additions & 2 deletions tools/projmgr/test/data/MLOps/minimal.csolution.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ solution:

- type: Simulator
device: RteTest_ARMCM0_Dual
define:
- SIMULATOR
variables:
- AI-Layer: $SolutionDir()$/ai_layer/ai_layer.clayer.yml
target-set:
Expand Down
40 changes: 40 additions & 0 deletions tools/projmgr/test/data/MLOps/no_hardware.csolution.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/Open-CMSIS-Pack/devtools/main/tools/projmgr/schemas/csolution.schema.json

solution:
compiler: AC6

mlops:
description: hardware target not present
model:
clayer: $AI-Layer$
hardware:
target: OtherHardware

target-types:
- type: Hardware
device: RteTest_ARMCM0_Dual
variables:
- AI-Layer: $SolutionDir()$/ai_layer/ai_layer.clayer.yml
target-set:
- set:
images:
- project-context: core0
- project-context: core1

- type: Simulator
device: RteTest_ARMCM0_Dual
variables:
- AI-Layer: $SolutionDir()$/ai_layer/ai_layer.clayer.yml
target-set:
- set: FVP-Test
debugger:
name: Arm-FVP
model: FVP_Corstone_SSE-320
config-file: fvp/fvp_config.txt
images:
- project-context: core0
- project-context: core1

projects:
- project: core0/core0.cproject.yml
- project: core1/core1.cproject.yml
42 changes: 42 additions & 0 deletions tools/projmgr/test/data/MLOps/no_hardware_extended.csolution.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/Open-CMSIS-Pack/devtools/main/tools/projmgr/schemas/csolution.schema.json

solution:
compiler: AC6

mlops:
description: hardware context not found
vela:
ini: vela/custom.ini
model:
clayer: ai_layer/ai_layer.clayer.yml
hardware:
target: Hardware

target-types:
- type: Hardware
device: RteTest_ARMCM0_Dual
variables:
- AI-Layer: $SolutionDir()$/ai_layer/ai_layer.clayer.yml
target-set:
- set:
images:
- project-context: coreX
- project-context: coreY

- type: Simulator
device: RteTest_ARMCM0_Dual
variables:
- AI-Layer: $SolutionDir()$/ai_layer/ai_layer.clayer.yml
target-set:
- set: FVP-Test
debugger:
name: Arm-FVP
model: FVP_Corstone_SSE-320
config-file: fvp/fvp_config.txt
images:
- project-context: core0
- project-context: core1

projects:
- project: core0/core0.cproject.yml
- project: core1/core1.cproject.yml
40 changes: 40 additions & 0 deletions tools/projmgr/test/data/MLOps/no_simulator.csolution.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/Open-CMSIS-Pack/devtools/main/tools/projmgr/schemas/csolution.schema.json

solution:
compiler: AC6

mlops:
description: simulator target not present
model:
clayer: $AI-Layer$
simulator:
target: OtherSimulator

target-types:
- type: Hardware
device: RteTest_ARMCM0_Dual
variables:
- AI-Layer: $SolutionDir()$/ai_layer/ai_layer.clayer.yml
target-set:
- set:
images:
- project-context: core0
- project-context: core1

- type: Simulator
device: RteTest_ARMCM0_Dual
variables:
- AI-Layer: $SolutionDir()$/ai_layer/ai_layer.clayer.yml
target-set:
- set: FVP-Test
debugger:
name: Arm-FVP
model: FVP_Corstone_SSE-320
config-file: fvp/fvp_config.txt
images:
- project-context: core0
- project-context: core1

projects:
- project: core0/core0.cproject.yml
- project: core1/core1.cproject.yml
Loading
Loading