Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
aidge_core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Cyril Moineau
aidge_core
Commits
4540e79c
Commit
4540e79c
authored
1 year ago
by
vincent lorrain
Browse files
Options
Downloads
Patches
Plain Diff
clean and remove old graph matching
parent
717a683e
No related branches found
No related tags found
No related merge requests found
Changes
22
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
unit_tests/graphMatching/Test_SeqStm.cpp
+0
-167
0 additions, 167 deletions
unit_tests/graphMatching/Test_SeqStm.cpp
unit_tests/graphMatching/Test_StmFactory.cpp
+0
-204
0 additions, 204 deletions
unit_tests/graphMatching/Test_StmFactory.cpp
with
0 additions
and
371 deletions
unit_tests/graphMatching/Test_SeqStm.cpp
deleted
100644 → 0
+
0
−
167
View file @
717a683e
/********************************************************************************
* Copyright (c) 2023 CEA-List
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*
********************************************************************************/
#include
<iostream>
#include
<map>
#include
<memory>
#include
<vector>
#include
<utility>
#include
<cassert>
#include
<catch2/catch_test_macros.hpp>
//test
#include
"aidge/graphmatching/SeqStm.hpp"
#include
"aidge/graphmatching/NodeRegex.hpp"
//use
#include
"aidge/backend/OperatorImpl.hpp"
#include
"aidge/operator/GenericOperator.hpp"
#include
"aidge/operator/Producer.hpp"
using
namespace
Aidge
;
TEST_CASE
(
"Create good init SeqStm"
,
"[SeqStm]"
)
{
//init all iniput for SeqStm
int
stmIdx
=
0
;
//matrix that in B->C
std
::
vector
<
std
::
vector
<
int
>>
transitionMatrix
{
{
-
1
,
1
,
-
1
},
{
-
1
,
-
1
,
2
},
{
-
1
,
-
1
,
-
1
}
};
//std::cout << transitionMatrix.size() << "\n";
// init the nodes Regex map
std
::
map
<
std
::
string
,
NodeRegex
*>
nodesRegex
;
std
::
vector
<
std
::
string
>
nodeTypeKey
{
"A"
,
"B"
,
"C"
};
for
(
const
std
::
string
&
key
:
nodeTypeKey
)
{
nodesRegex
[
key
]
=
new
NodeRegex
(
key
);
}
//
std
::
map
<
NodeTypeKey
,
int
>
typeToIdxTransition
;
std
::
vector
<
NodeTypeKey
>
nodeTypeCommonTag
{{
"A"
,
""
},{
"B"
,
""
},{
"C"
,
""
}};
//init nodeTypeCommonTag
int
idx
=
0
;
for
(
const
NodeTypeKey
&
key
:
nodeTypeCommonTag
)
{
typeToIdxTransition
[
key
]
=
idx
;
idx
+=
1
;
}
int
actSt
=
0
;
std
::
set
<
NodeTmp
>
allNodeValidated
;
std
::
set
<
NodeTmp
>
allNodeTested
;
std
::
set
<
std
::
pair
<
NodeTmp
,
std
::
string
>>
allCommonNode
;
bool
stmIsValid
=
false
;
SeqStm
stm
(
stmIdx
,
transitionMatrix
,
nodesRegex
,
typeToIdxTransition
,
actSt
,
allNodeValidated
,
allNodeTested
,
allCommonNode
,
stmIsValid
);
REQUIRE
(
stm
.
getStmIdx
()
==
0
);
REQUIRE
(
stm
.
isValid
()
==
false
);
REQUIRE
(
stm
.
getAllCommonNode
().
size
()
==
0
);
REQUIRE
(
stm
.
getAllNodeTested
().
size
()
==
0
);
REQUIRE
(
stm
.
getAllNodeValidated
().
size
()
==
0
);
for
(
const
std
::
string
&
key
:
nodeTypeKey
)
{
delete
nodesRegex
[
key
];
}
}
TEST_CASE
(
"Test testNode function"
,
"[SeqStm]"
)
{
int
stmIdx
=
0
;
std
::
map
<
NodeTypeKey
,
int
>
typeToIdxTransition
;
std
::
vector
<
NodeTypeKey
>
nodeTypeCommonTag
{{
"A"
,
""
},{
"B"
,
""
},{
"C"
,
""
}};
//init nodeTypeCommonTag
int
idx
=
0
;
for
(
const
NodeTypeKey
&
key
:
nodeTypeCommonTag
)
{
typeToIdxTransition
[
key
]
=
idx
;
idx
+=
1
;
}
//matrix that in B->C
std
::
vector
<
std
::
vector
<
int
>>
transitionMatrix
{
{
-
1
,
1
,
-
1
},
{
-
1
,
-
1
,
2
},
{
-
1
,
-
1
,
-
1
}
};
//std::cout << transitionMatrix.size() << "\n";
// init the nodes Regex map
std
::
map
<
std
::
string
,
NodeRegex
*>
nodesRegex
;
std
::
vector
<
std
::
string
>
nodeTypeKey
{
"A"
,
"B"
,
"C"
};
for
(
const
std
::
string
&
key
:
nodeTypeKey
)
{
nodesRegex
[
key
]
=
new
NodeRegex
(
key
);
}
//
int
actSt
=
0
;
std
::
set
<
NodeTmp
>
allNodeValidated
;
std
::
set
<
NodeTmp
>
allNodeTested
;
std
::
set
<
std
::
pair
<
NodeTmp
,
std
::
string
>>
allCommonNode
;
bool
stmIsValid
=
false
;
SeqStm
stm
(
stmIdx
,
transitionMatrix
,
nodesRegex
,
typeToIdxTransition
,
actSt
,
allNodeValidated
,
allNodeTested
,
allCommonNode
,
stmIsValid
);
REQUIRE
(
stm
.
getStmIdx
()
==
0
);
//test a node
std
::
shared_ptr
<
Node
>
nodeB
=
GenericOperator
(
"B"
,
1
,
1
,
1
);
std
::
shared_ptr
<
Node
>
nodeC
=
GenericOperator
(
"C"
,
1
,
1
,
1
);
//set use to test the state of the smt
std
::
set
<
NodeTmp
>
testAllNodeTested
;
std
::
set
<
NodeTmp
>
testAllNodeValidated
;
stm
.
testNode
(
nodeB
);
REQUIRE
(
stm
.
isValid
()
==
false
);
REQUIRE
(
stm
.
getState
()
==
1
);
REQUIRE
(
stm
.
isStmBlocked
()
==
false
);
testAllNodeTested
.
insert
(
nodeB
);
testAllNodeValidated
.
insert
(
nodeB
);
REQUIRE
(
stm
.
getAllNodeTested
()
==
testAllNodeTested
);
REQUIRE
(
stm
.
getAllNodeValidated
()
==
testAllNodeValidated
);
stm
.
testNode
(
nodeC
);
REQUIRE
(
stm
.
isValid
()
==
true
);
REQUIRE
(
stm
.
getState
()
==
2
);
REQUIRE
(
stm
.
isStmBlocked
()
==
false
);
testAllNodeTested
.
insert
(
nodeC
);
testAllNodeValidated
.
insert
(
nodeC
);
REQUIRE
(
stm
.
getAllNodeTested
()
==
testAllNodeTested
);
REQUIRE
(
stm
.
getAllNodeValidated
()
==
testAllNodeValidated
);
stm
.
testNode
(
nodeC
);
REQUIRE
(
stm
.
isValid
()
==
true
);
REQUIRE
(
stm
.
getState
()
==
-
1
);
REQUIRE
(
stm
.
isStmBlocked
()
==
true
);
REQUIRE
(
stm
.
getAllNodeTested
()
==
testAllNodeTested
);
REQUIRE
(
stm
.
getAllNodeValidated
()
==
testAllNodeValidated
);
for
(
const
std
::
string
&
key
:
nodeTypeKey
)
{
delete
nodesRegex
[
key
];
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
unit_tests/graphMatching/Test_StmFactory.cpp
deleted
100644 → 0
+
0
−
204
View file @
717a683e
/********************************************************************************
* Copyright (c) 2023 CEA-List
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*
********************************************************************************/
#include
<iostream>
#include
<map>
#include
<memory>
#include
<vector>
#include
<utility>
#include
<cassert>
#include
<catch2/catch_test_macros.hpp>
//test
#include
"aidge/graphmatching/StmFactory.hpp"
#include
"aidge/graphmatching/NodeRegex.hpp"
//use
#include
"aidge/backend/OperatorImpl.hpp"
#include
"aidge/operator/GenericOperator.hpp"
#include
"aidge/operator/Producer.hpp"
using
namespace
Aidge
;
TEST_CASE
(
"Create good init StmFactory"
,
"[StmFactory]"
)
{
// init the nodes Regex map
std
::
map
<
std
::
string
,
NodeRegex
*>
nodesRegex
;
std
::
vector
<
std
::
string
>
nodeTypeKey
{
"A"
,
"B"
,
"C"
};
for
(
const
std
::
string
&
key
:
nodeTypeKey
)
{
nodesRegex
[
key
]
=
new
NodeRegex
(
key
);
}
StmFactory
stmF
(
nodesRegex
);
REQUIRE
(
stmF
.
getNumberOfStm
()
==
0
);
for
(
const
std
::
string
&
key
:
nodeTypeKey
)
{
delete
nodesRegex
[
key
];
}
}
TEST_CASE
(
"Test in makeNewStm the getStmIdx StmFactory"
,
"[SeqStm]"
)
{
std
::
map
<
std
::
string
,
NodeRegex
*>
nodesRegex
;
std
::
vector
<
std
::
string
>
nodeTypeKey
{
"A"
,
"B"
,
"C"
};
for
(
const
std
::
string
&
key
:
nodeTypeKey
)
{
nodesRegex
[
key
]
=
new
NodeRegex
(
key
);
}
StmFactory
stmF
(
nodesRegex
);
std
::
string
seq1
=
"A->B+->A#;"
;
SeqStm
*
stm
=
stmF
.
makeNewStm
(
seq1
);
REQUIRE
(
stm
->
getStmIdx
()
==
0
);
REQUIRE
(
stm
->
isValid
()
==
false
);
REQUIRE
(
stm
->
getAllCommonNode
().
size
()
==
0
);
REQUIRE
(
stm
->
getAllNodeTested
().
size
()
==
0
);
REQUIRE
(
stm
->
getAllNodeValidated
().
size
()
==
0
);
std
::
string
seq2
=
"A->B;"
;
SeqStm
*
stm2
=
stmF
.
makeNewStm
(
seq2
);
REQUIRE
(
stm2
->
getStmIdx
()
==
1
);
REQUIRE
(
stm2
->
isValid
()
==
false
);
REQUIRE
(
stm2
->
getAllCommonNode
().
size
()
==
0
);
REQUIRE
(
stm2
->
getAllNodeTested
().
size
()
==
0
);
REQUIRE
(
stm2
->
getAllNodeValidated
().
size
()
==
0
);
//test the number of stm
REQUIRE
(
stmF
.
getNumberOfStm
()
==
2
);
for
(
const
std
::
string
&
key
:
nodeTypeKey
)
{
delete
nodesRegex
[
key
];
}
}
TEST_CASE
(
"Test in makeNewStm the stm StmFactory"
,
"[SeqStm]"
)
{
std
::
map
<
std
::
string
,
NodeRegex
*>
nodesRegex
;
std
::
vector
<
std
::
string
>
nodeTypeKey
{
"A"
,
"B"
,
"C"
};
for
(
const
std
::
string
&
key
:
nodeTypeKey
)
{
nodesRegex
[
key
]
=
new
NodeRegex
(
key
);
}
StmFactory
stmF
(
nodesRegex
);
std
::
string
seq1
=
"B->C;"
;
SeqStm
*
stm
=
stmF
.
makeNewStm
(
seq1
);
//test the number of stm
REQUIRE
(
stmF
.
getNumberOfStm
()
==
1
);
//std::shared_ptr<Node> nodeB = GenericOperator("B",1,1,1);
//std::shared_ptr<Node> nodeC = GenericiOperator("C",1,1,1);
std
::
shared_ptr
<
Node
>
nodeB
=
GenericOperator
(
"B"
,
1
,
1
,
1
);
std
::
shared_ptr
<
Node
>
nodeC
=
GenericOperator
(
"C"
,
1
,
1
,
1
);
//set use to test the state of the smt
std
::
set
<
NodeTmp
>
testAllNodeTested
;
std
::
set
<
NodeTmp
>
testAllNodeValidated
;
REQUIRE
(
stm
->
isValid
()
==
false
);
REQUIRE
(
stm
->
getState
()
==
0
);
REQUIRE
(
stm
->
isStmBlocked
()
==
false
);
REQUIRE
(
stm
->
getAllNodeTested
()
==
testAllNodeTested
);
REQUIRE
(
stm
->
getAllNodeValidated
()
==
testAllNodeValidated
);
stm
->
testNode
(
nodeB
);
REQUIRE
(
stm
->
isValid
()
==
false
);
REQUIRE
(
stm
->
getState
()
==
1
);
REQUIRE
(
stm
->
isStmBlocked
()
==
false
);
testAllNodeTested
.
insert
(
nodeB
);
testAllNodeValidated
.
insert
(
nodeB
);
REQUIRE
(
stm
->
getAllNodeTested
()
==
testAllNodeTested
);
REQUIRE
(
stm
->
getAllNodeValidated
()
==
testAllNodeValidated
);
stm
->
testNode
(
nodeC
);
REQUIRE
(
stm
->
isValid
()
==
true
);
REQUIRE
(
stm
->
getState
()
==
2
);
REQUIRE
(
stm
->
isStmBlocked
()
==
false
);
testAllNodeTested
.
insert
(
nodeC
);
testAllNodeValidated
.
insert
(
nodeC
);
REQUIRE
(
stm
->
getAllNodeTested
()
==
testAllNodeTested
);
REQUIRE
(
stm
->
getAllNodeValidated
()
==
testAllNodeValidated
);
stm
->
testNode
(
nodeC
);
REQUIRE
(
stm
->
isValid
()
==
true
);
REQUIRE
(
stm
->
getState
()
==
-
1
);
REQUIRE
(
stm
->
isStmBlocked
()
==
true
);
REQUIRE
(
stm
->
getAllNodeTested
()
==
testAllNodeTested
);
REQUIRE
(
stm
->
getAllNodeValidated
()
==
testAllNodeValidated
);
for
(
const
std
::
string
&
key
:
nodeTypeKey
)
{
delete
nodesRegex
[
key
];
}
}
TEST_CASE
(
"Test in duplicateStm StmFactory"
,
"[SeqStm]"
)
{
std
::
map
<
std
::
string
,
NodeRegex
*>
nodesRegex
;
std
::
vector
<
std
::
string
>
nodeTypeKey
{
"A"
,
"B"
,
"C"
};
for
(
const
std
::
string
&
key
:
nodeTypeKey
)
{
nodesRegex
[
key
]
=
new
NodeRegex
(
key
);
}
StmFactory
stmF
(
nodesRegex
);
std
::
string
seq1
=
"B->C;"
;
SeqStm
*
stm
=
stmF
.
makeNewStm
(
seq1
);
SeqStm
*
stmD
=
stmF
.
duplicateStm
(
stm
);
std
::
shared_ptr
<
Node
>
nodeB
=
GenericOperator
(
"B"
,
1
,
1
,
1
);
std
::
shared_ptr
<
Node
>
nodeC
=
GenericOperator
(
"C"
,
1
,
1
,
1
);
//set use to test the state of the smt
std
::
set
<
NodeTmp
>
testAllNodeTested
;
std
::
set
<
NodeTmp
>
testAllNodeValidated
;
//run the stm
REQUIRE
(
stm
->
isValid
()
==
false
);
REQUIRE
(
stm
->
getState
()
==
0
);
REQUIRE
(
stm
->
isStmBlocked
()
==
false
);
REQUIRE
(
stm
->
getAllNodeTested
()
==
testAllNodeTested
);
REQUIRE
(
stm
->
getAllNodeValidated
()
==
testAllNodeValidated
);
stm
->
testNode
(
nodeB
);
REQUIRE
(
stm
->
isValid
()
==
false
);
REQUIRE
(
stm
->
getState
()
==
1
);
REQUIRE
(
stm
->
isStmBlocked
()
==
false
);
testAllNodeTested
.
insert
(
nodeB
);
testAllNodeValidated
.
insert
(
nodeB
);
REQUIRE
(
stm
->
getAllNodeTested
()
==
testAllNodeTested
);
REQUIRE
(
stm
->
getAllNodeValidated
()
==
testAllNodeValidated
);
stm
->
testNode
(
nodeC
);
REQUIRE
(
stm
->
isValid
()
==
true
);
REQUIRE
(
stm
->
getState
()
==
2
);
REQUIRE
(
stm
->
isStmBlocked
()
==
false
);
testAllNodeTested
.
insert
(
nodeC
);
testAllNodeValidated
.
insert
(
nodeC
);
REQUIRE
(
stm
->
getAllNodeTested
()
==
testAllNodeTested
);
REQUIRE
(
stm
->
getAllNodeValidated
()
==
testAllNodeValidated
);
stm
->
testNode
(
nodeC
);
REQUIRE
(
stm
->
isValid
()
==
true
);
REQUIRE
(
stm
->
getState
()
==
-
1
);
REQUIRE
(
stm
->
isStmBlocked
()
==
true
);
REQUIRE
(
stm
->
getAllNodeTested
()
==
testAllNodeTested
);
REQUIRE
(
stm
->
getAllNodeValidated
()
==
testAllNodeValidated
);
//check if stmD not move
REQUIRE
(
stmD
->
isValid
()
==
false
);
REQUIRE
(
stmD
->
getState
()
==
0
);
REQUIRE
(
stmD
->
isStmBlocked
()
==
false
);
REQUIRE
(
stmD
->
getAllNodeTested
().
size
()
==
0
);
REQUIRE
(
stmD
->
getAllNodeValidated
().
size
()
==
0
);
for
(
const
std
::
string
&
key
:
nodeTypeKey
)
{
delete
nodesRegex
[
key
];
}
}
This diff is collapsed.
Click to expand it.
Prev
1
2
Next
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment