Skip to content
Snippets Groups Projects
Commit cda46ffd authored by Maxence Naud's avatar Maxence Naud
Browse files

Merge branch 'dev' into 'main'

v0.4.0

Closes #196 and #160

See merge request eclipse/aidge/aidge_core!279
parents 577e654a cc6b7704
No related branches found
No related tags found
1 merge request!279v0.4.0
Pipeline #63431 failed
Showing
with 424 additions and 228 deletions
...@@ -31,10 +31,10 @@ namespace Aidge{ ...@@ -31,10 +31,10 @@ namespace Aidge{
/** /**
* @brief is a node in the FSM graph, it's a state in the FSM * @brief is a node in the FSM graph, it's a state in the FSM
* @details a state can be and/or : * @details a state can be and/or :
* - a valide state, the match is valide if it stop on this edge * - a valid state, the match is valid if it stop on this edge
* - a start state , the match start on this state * - a start state , the match start on this state
* The state is also define by this Origin (is the unique id of it's expretion ) * The state is also define by this Origin (is the unique id of it's expretion )
* and it's groupe (for inner expression TODO) * and it's group (for inner expression TODO)
*/ */
class FsmNode : public std::enable_shared_from_this<FsmNode> class FsmNode : public std::enable_shared_from_this<FsmNode>
{ {
...@@ -84,7 +84,7 @@ namespace Aidge{ ...@@ -84,7 +84,7 @@ namespace Aidge{
bool isValid(void); bool isValid(void);
bool isStart(void); bool isStart(void);
void unValid(void); void invalid(void);
void valid(void); void valid(void);
void unStart(void); void unStart(void);
void start(void); void start(void);
......
...@@ -40,7 +40,7 @@ private: ...@@ -40,7 +40,7 @@ private:
*/ */
std::map<NodePtr,std::size_t> mCommonNodes; std::map<NodePtr,std::size_t> mCommonNodes;
/** /**
* @brief the map of the node that as been valid in this context , and the test that valide the node * @brief the map of the node that as been valid in this context , and the test that valid the node
*/ */
std::map<std::shared_ptr<ConditionalInterpreter>,std::set<NodePtr>> mValidNodes; std::map<std::shared_ptr<ConditionalInterpreter>,std::set<NodePtr>> mValidNodes;
/** /**
...@@ -52,7 +52,7 @@ public: ...@@ -52,7 +52,7 @@ public:
* @brief constructor * @brief constructor
* @param actState the actual state in the FSM * @param actState the actual state in the FSM
* @param actOpNode the actual node in the graph * @param actOpNode the actual node in the graph
* @param idxRejeced the idx in the global regected node vector init max() as sentinel value of undefind * @param idxRejeced the idx in the global regected node vector init max() as sentinel value of undefined
*/ */
FsmRunTimeContext(std::shared_ptr<FsmNode> actState ,NodePtr actOpNode ,std::size_t idxRejeced =std::numeric_limits<std::size_t>::max() ); FsmRunTimeContext(std::shared_ptr<FsmNode> actState ,NodePtr actOpNode ,std::size_t idxRejeced =std::numeric_limits<std::size_t>::max() );
FsmRunTimeContext(std::shared_ptr<FsmRunTimeContext> fsmRunTime); FsmRunTimeContext(std::shared_ptr<FsmRunTimeContext> fsmRunTime);
...@@ -85,7 +85,7 @@ public: ...@@ -85,7 +85,7 @@ public:
/** /**
* @ingroup FsmRunTimeContextTest * @ingroup FsmRunTimeContextTest
* @brief test if the actual state is valide * @brief test if the actual state is valid
* @return bool * @return bool
*/ */
bool isOnValidState(void); bool isOnValidState(void);
......
/**
* \file execTime.hpp
* \brief execTime structure
* \version file 1.0.0
* \date Creation 27 June 2023
* \date 27 June 2023
* \par ChangeLog
* \par
* v1.0.0, 27 June 2023<br>
* - Initial version.
* \author mn271187, ik243221
* \copyright
* Copyright (c) 2023 CEA, LIST, Embedded Artificial Intelligence Laboratory. All
* rights reserved.
*/
#ifndef execTime_H_
#define execTime_H_
#include "aidge/operator/Operator.hpp"
#include "aidge/hook/Hook.hpp"
#include <memory>
#include <chrono>
#include <vector>
namespace Aidge {
class ExecTime : public Hook {
private:
std::vector<std::chrono::high_resolution_clock::time_point> registeredTimes = std::vector<std::chrono::high_resolution_clock::time_point>();
public:
ExecTime(const std::shared_ptr<Operator> op) : Hook(op) {}
~ExecTime() = default;
void call() override final {
registeredTimes.push_back(std::chrono::high_resolution_clock::now());
}
static std::shared_ptr<ExecTime> create(const std::shared_ptr<Operator> op)
{
return std::make_shared<ExecTime>(op);
}
std::vector<std::chrono::high_resolution_clock::time_point> getTimes() {
return registeredTimes;
}
std::chrono::high_resolution_clock::time_point getTime(size_t idx) {
return registeredTimes[idx];
}
};
namespace {
static Registrar<Hook> registrarHook_ExecTime({"execution_time"}, Aidge::ExecTime::create);
}
}
#endif /* execTime_H_ */
\ No newline at end of file
/**
* \file Hook.hpp
* \brief Hook structure
* \version file 1.0.0
* \date Creation 27 June 2023
* \date 27 June 2023
* \par ChangeLog
* \par
* v1.0.0, 27 June 2023<br>
* - Initial version.
* \author mn271187, ik243221
* \copyright
* Copyright (c) 2023 CEA, LIST, Embedded Artificial Intelligence Laboratory. All
* rights reserved.
*/
#ifndef Hook_H_
#define Hook_H_
#include "aidge/utils/Attributes.hpp"
#include "aidge/utils/Registrar.hpp"
#include <memory>
namespace Aidge {
class Operator;
class Hook : public Registrable<Hook, std::tuple<std::string>, std::function<std::shared_ptr<Hook>(const std::shared_ptr<Operator>)>> {
//class Hook : public Registrable<Hook, std::tuple<std::string>, std::function<std::shared_ptr<Hook>(const std::shared_ptr<Operator>)>>{
protected:
const std::shared_ptr<Operator> mOperator;
public:
Hook(std::shared_ptr<Operator> op) : mOperator(op) {}
virtual ~Hook() = default;
virtual void call() = 0;
};
}
#endif /* Hook_H_ */
/**
* \file execTime.hpp
* \brief execTime structure
* \version file 1.0.0
* \date Creation 27 June 2023
* \date 27 June 2023
* \par ChangeLog
* \par
* v1.0.0, 27 June 2023<br>
* - Initial version.
* \author ik243221
* \copyright
* Copyright (c) 2023 CEA, LIST, Embedded Artificial Intelligence Laboratory. All
* rights reserved.
*/
#ifndef AIDGE_CORE_HOOK_OUTPUTRANGE_H_
#define AIDGE_CORE_HOOK_OUTPUTRANGE_H_
#include "aidge/operator/Operator.hpp"
#include "aidge/hook/Hook.hpp"
#include <memory>
#include <chrono>
#include <vector>
#include <cmath>
namespace Aidge {
class OutputRange : public Hook {
private:
std::vector<float> registeredOutputs = std::vector<float>();
public:
OutputRange(const std::shared_ptr<Operator> op) : Hook(op) {}
~OutputRange() = default;
void call() override final {
//std::cout << "call() outputRange hook " << std::endl;
//this assumes there is only 1 output possible
std::shared_ptr<Tensor> tensor = mOperator->getOutput(0);
//tensor->print();
//std::cout << "call() outputRange hook : tensor printed" << std::endl;
float max_value = 0.;
float * casted_tensor = static_cast<float *>(tensor->getImpl()->rawPtr());
//find the absolute max value in the tensor, save it to registered outputs
for(std::size_t i = 0; i < tensor->size(); ++i) {
//std::cout << "call() outputRange hook : casted_tensor[i] = " << casted_tensor[i] << std::endl;
if(std::abs(casted_tensor[i]) > max_value){
max_value = std::abs(casted_tensor[i]);
}
}
//std::cout << "call() outputRange hook : max_value = " << max_value << std::endl;
registeredOutputs.push_back(max_value);
}
static std::shared_ptr<OutputRange> create(const std::shared_ptr<Operator> op)
{
return std::make_shared<OutputRange>(op);
}
std::vector<float> getOutputs() {
return registeredOutputs;
}
float getOutput(size_t idx) {
return registeredOutputs[idx];
}
};
namespace {
static Registrar<Hook> registrarHook_OutputRange({"output_range"}, Aidge::OutputRange::create);
}
}
#endif /* outputRange_H_ */
\ No newline at end of file
...@@ -12,7 +12,7 @@ namespace Aidge{ ...@@ -12,7 +12,7 @@ namespace Aidge{
///////////////////////// /////////////////////////
// The data type in AST Intepretation // The data type in AST Interpretation
//////////////////////// ////////////////////////
class BaseConditionalValue { class BaseConditionalValue {
......
This diff is collapsed.
...@@ -65,7 +65,7 @@ private: ...@@ -65,7 +65,7 @@ private:
/** /**
* @brief Constructs an error message to display the character not understood by the lexer * @brief Constructs an error message to display the character not understood by the lexer
* @return error mesage * @return error message
*/ */
std::runtime_error badTokenError(const std::string& currentChars,std::size_t position); std::runtime_error badTokenError(const std::string& currentChars,std::size_t position);
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -92,7 +92,7 @@ public: ...@@ -92,7 +92,7 @@ public:
* @brief Will compute the dimensions of operator's output tensor given the input sizes * @brief Will compute the dimensions of operator's output tensor given the input sizes
* If the output dimensions cannot be computed because it depends on some undefined inputs then forwardDims will return false and enter in TOKEN mode for subsequent tensors. * If the output dimensions cannot be computed because it depends on some undefined inputs then forwardDims will return false and enter in TOKEN mode for subsequent tensors.
* - TOKEN mode means that forwarddims will only ensure that all inputs and outputs of the graph the node is within are connected. * - TOKEN mode means that forwarddims will only ensure that all inputs and outputs of the graph the node is within are connected.
* @param[in] allowDataDependency if set to true, this means that this operator output dimensions depends on the dimensions of optionnal parameter tensors. * @param[in] allowDataDependency if set to true, this means that this operator output dimensions depends on the dimensions of optional parameter tensors.
* @return true if dims have been properly forwarded. false otherwise. If set to false, then forwardDims will enter in token mode. * @return true if dims have been properly forwarded. false otherwise. If set to false, then forwardDims will enter in token mode.
* *
*/ */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment