Skip to content

Commit

Permalink
Refs #22026: Update usage and documentation
Browse files Browse the repository at this point in the history
Signed-off-by: eProsima <jesuspoderoso@eprosima.com>
  • Loading branch information
JesusPoderoso committed Oct 30, 2024
1 parent 7e0d820 commit a49a15c
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 4 deletions.
1 change: 1 addition & 0 deletions sustainml_cpp/examples/CliModules/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,7 @@ class CustomHardwareConstraintsListener : public sustainml::hardware_module::Har

// Populate output
output.max_memory_footprint(user_input.task_id().problem_id());
output.hardware_required(std::vector<std::string>{"PIM_AI_1chip"});

// Wait the time it takes the node to generate the output
sleep(1);
Expand Down
1 change: 1 addition & 0 deletions sustainml_cpp/test/blackbox/helpers/data_generators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ std::list<HWConstraintsImpl> default_hwconstraints_task_generator(
hw_cons.task_id().problem_id(index);
hw_cons.task_id().iteration_id(1);
hw_cons.max_memory_footprint(index);
hw_cons.hardware_required(std::vector<std::string>{"PIM_AI_1chip"});
++index;
return hw_cons;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ User is meant to implement the funcionality of the node within the ``test:callba
# There is no need to specify node_status for the moment
# as it will automatically be set to IDLE when the callback returns.
hw_constraints.max_memory_footprint(100)
hw_constraints.hardware_required(["PIM_AI_1chip"])
# Main workflow routine
def run():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ User is meant to implement the funcionality of the node within the ``test:callba
print(requirement)
# HWConstraints
hw_constraint = hw_constraints.max_memory_footprint()
max_mem_footprint = hw_constraints.max_memory_footprint()
hw_required = hw_constraints.hardware_required()
# Do processing...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ User is meant to implement the funcionality of the node within the ``test:callba
print(requirement)
# HWConstraints
hw_constraint = hw_constraints.max_memory_footprint()
max_mem_footprint = hw_constraints.max_memory_footprint()
hw_required = hw_constraints.hardware_required()
# MLModel
# Only in case of optimization (task_id.iteration_id() > 1)
Expand Down
2 changes: 2 additions & 0 deletions sustainml_docs/rst/developer_manual/data_model/data_model.rst
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ Hardware Constraints Type
The ``HWConstraints`` represents the group of constraints defined (or not) by the user when describing the problem. It is the output from the ``Hardware Constraints Node``.
* ``max_memory_footprint``: The maximum memory footprint allowed for the ML model.
* ``hardware_required``: A sequence of hardware selected by the user to be taken into account by the framework.
* ``extra_data``: A sequence of raw extra data for out-of-scope use cases.
* ``task_id``: The identifier of the ML problem to solve.
Expand All @@ -203,6 +204,7 @@ The ``HWConstraints`` represents the group of constraints defined (or not) by th
struct HWConstraints
{
unsigned long max_memory_footprint;
sequence<string> hardware_required;
sequence<octet> extra_data;
@key long task_id;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,9 @@ def get_hw_constraints(self, task_id):

# Parse data into json
max_value = node_data.max_memory_footprint()
json_output = {'max_memory_footprint': f'{max_value}'}
required_hardware = node_data.hardware_required()
json_output = {'max_memory_footprint': f'{max_value}',
'hardware_required': f'{utils.string_std_vector(required_hardware)}'}
return json_output

def get_ml_model_provider(self, task_id):
Expand Down
1 change: 1 addition & 0 deletions sustainml_py/examples/hw_constratins_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def signal_handler(sig, frame):
def task_callback(user_input, node_status, hw_constraints):
print (user_input.problem_definition())
hw_constraints.max_memory_footprint(100)
hw_constraints.hardware_required(['PIM_AI_1chip'])

# Main workflow routine
def run():
Expand Down
4 changes: 3 additions & 1 deletion sustainml_py/examples/ml_model_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ def task_callback(
print("Received metadata " + metadata)
for requirement in app_requirements.app_requirements():
print("Received app requirement " + requirement)
print ("Received HW constraints: Max memory footprint: " + str(hw_constraints.max_memory_footprint()) + " MB")
print ("Received HW constraints:\n Max memory footprint: " + str(hw_constraints.max_memory_footprint()) + " MB")
for hw in hw_constraints.hardware_required():
print(" Hardware required: " + hw)
print (node_status.node_status())
ml_model.model("MODEL in ONXX format")

Expand Down

0 comments on commit a49a15c

Please sign in to comment.