Skip to content

Commit

Permalink
Address some of Jorge's comments to new docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
StephanieKemna committed Jul 25, 2024
1 parent 9e65e09 commit 35fb83c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/mlfmu/fmu_build/templates/fmu/fmu_template.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class
/**
* \brief Constructs a new {FmuName} object.
*
* \param fmuResourceLocation The location of the FMU resource.
* \param fmuResourceLocation The location of the resources of the FMU.
*/
{FmuName}(cppfmu::FMIString fmuResourceLocation) : OnnxFmu(fmuResourceLocation) {}

Expand Down
15 changes: 8 additions & 7 deletions src/mlfmu/fmu_build/templates/onnx_fmu/onnxFmu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ std::wstring OnnxFmu::formatOnnxPath(cppfmu::FMIString fmuResourceLocation)
}

/**
* \brief Creates a session for the ONNX FMU.
* \brief Creates a session to the ONNX model.
*
* This function creates a session for the ONNX FMU using the specified ONNX model file.
* This function creates a session to the ONNX model, using the specified ONNX model file.
* This loads the weights of the model such that we can run predictions in the doStep function.
*
* \note The ONNX model file path must be set before calling this function.
* \throws std::runtime_error if the session creation fails.
Expand Down Expand Up @@ -168,11 +169,11 @@ void OnnxFmu::GetBoolean(const cppfmu::FMIValueReference vr[], std::size_t nvr,
}

/**
* \brief Sets the ONNX inputs for the ONNX FMU.
* \brief Sets the ONNX inputs for the ONNX FMU, matching FMU variables with inputs of ONNX model.
*
* This function sets the ONNX inputs for the ONNX FMU by iterating over the ONNX input
* value-reference index pairs and assigning the corresponding FMU variable's real value
* to the ONNX input.
* This function matches the FMU variables with the inputs to the ONNX model.
* It iterates over the ONNX input value-reference index pairs and assigns the corresponding FMU
* variable's real value to the ONNX input.
*
* \returns `true` if the ONNX inputs are successfully set, `false` otherwise.
*/
Expand Down Expand Up @@ -230,7 +231,7 @@ bool OnnxFmu::GetOnnxOutputs()
}

/**
* \brief Initializes the ONNX states of the ONNX FMU.
* \brief Initializes the ONNX states of the ONNX model.
*
* This function initializes the ONNX states of the ONNX FMU by assigning the initial values
* of the ONNX states from the corresponding variables in the FMU.
Expand Down
11 changes: 6 additions & 5 deletions src/mlfmu/types/fmu_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ class InternalState(BaseModelConfig):
If this field is set, parameters for initialization will be automatically generated for these states.
initialization_variable (Optional[str]): The name of an input or parameter in the same model interface
that should be used to initialize this state.
agent_output_indexes (List[str]): Index or range of indices of agent outputs that will be stored as
agent_output_indexes (List[str]): Index or range of indices of agent (ONNX model) outputs that will be stored as
internal states and will be fed as inputs in the next time step. Note: the FMU signal and the
agent outputs need to have the same length.
ONNX (agent) outputs need to have the same length.
"""

name: Optional[str] = Field(
Expand Down Expand Up @@ -174,8 +174,8 @@ class InputVariable(Variable):
Attributes
----------
agent_input_indexes (List[str]): Index or range of indices of agent inputs to which this FMU signal shall be linked to.
Note: The FMU signal and the agent inputs need to have the same length.
agent_input_indexes (List[str]): Index or range of indices of ONNX (agent) inputs to which this FMU signal shall be linked.
Note: The FMU signal and the ONNX (agent) inputs need to have the same length.
Examples
--------
Expand Down Expand Up @@ -301,7 +301,8 @@ class FmiVariable:

class ModelComponent(BaseModelConfig):
"""
Represents a simulation model component.
Represents a simulation model component, used to generate the JSON schema for the model interface.
We define the structure of the FMU and how the inputs and outputs of the ONNX model correspond to the FMU variables.
Attributes
----------
Expand Down
2 changes: 1 addition & 1 deletion src/mlfmu/utils/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def format_template_file(template_path: Path, save_path: Path, data: dict[str, s

def create_model_description(fmu: FmiModel, src_path: Path):
"""
Compute XML structure for FMU and save it in a file.
Generate modelDescription.xml structure for FMU, and save it in a file.
Args
----
Expand Down

0 comments on commit 35fb83c

Please sign in to comment.