[NNPA] Support matching tensor information in the JSON config file for NNPA#3412
Open
[NNPA] Support matching tensor information in the JSON config file for NNPA#3412
Conversation
- Created JsonConfigObject class for JSON configuration management * Implemented loadFromFile, saveToFile, getArray, getObject, getString * Added set, remove, clear, dump methods * Added applyConfigToOps() for reusable configuration application - Integrated global NNPA configuration object * Added globalNNPAConfig in NNPACompilerUtils.cpp * Added getGlobalNNPAConfig() accessor function * Automatic loading from nnpaLoadConfigFile option - Refactored DevicePlacement and QuantOpSelection passes * Unified configObject pointer approach (local vs global) * Single code path using applyConfigToOps() * Backward compatible with loadConfigFile parameter * Added single-argument overload for createDevicePlacementPass() - Created GenerateConfigFile pass * Generates JSON config from IR operations * Saves both device placement and quantization configs * Integrated into NNPA compilation pipeline - Code style compliance * All comments end with periods per project convention All 421 tests pass successfully. Signed-off-by: Tung D. Le <tung@jp.ibm.com>
- Moved nnpaLoadConfigFile loading logic to start of function - Moved nnpaSaveConfigFile initialization to start of function - This ensures config is loaded before any pass configuration - Improves code organization and clarity All 421 tests pass successfully. Signed-off-by: Tung D. Le <tung@jp.ibm.com>
- Moved global NNPA config instance from NNPACompilerUtils.cpp to JsonConfigObject.cpp - Moved getGlobalNNPAConfig() accessor function to JsonConfigObject.cpp - Added accessor declaration to JsonConfigObject.hpp - Removed forward declaration and accessor from NNPACompilerUtils.hpp - Updated NNPACompilerUtils.cpp to use accessor function Benefits: - Follows Single Responsibility Principle - Better discoverability - global instance lives with its class - Reduces coupling between modules - Standard C++ practice for global instances All 421 tests pass successfully. Signed-off-by: Tung D. Le <tung@jp.ibm.com>
Signed-off-by: Tung D. Le <tung@jp.ibm.com>
Signed-off-by: Tung D. Le <tung@jp.ibm.com>
Signed-off-by: Tung D. Le <tung@jp.ibm.com>
Signed-off-by: Tung D. Le <tung@jp.ibm.com>
Signed-off-by: Tung D. Le <tung@jp.ibm.com>
Signed-off-by: Tung D. Le <tung@jp.ibm.com>
Signed-off-by: Tung D. Le <tung@jp.ibm.com>
Signed-off-by: Tung D. Le <tung@jp.ibm.com>
Signed-off-by: Tung D. Le <tung@jp.ibm.com>
Signed-off-by: Tung D. Le <tung@jp.ibm.com>
Signed-off-by: Tung D. Le <tung@jp.ibm.com>
Signed-off-by: Tung D. Le <tung@jp.ibm.com>
Signed-off-by: Tung D. Le <tung@jp.ibm.com>
Signed-off-by: Tung D. Le <tung@jp.ibm.com>
Signed-off-by: Tung D. Le <tung@jp.ibm.com>
Signed-off-by: Tung D. Le <tung@jp.ibm.com>
Signed-off-by: Tung D. Le <tung@jp.ibm.com>
…d json file options Signed-off-by: Tung D. Le <tung@jp.ibm.com>
Signed-off-by: Tung D. Le <tung@jp.ibm.com>
Signed-off-by: Tung D. Le <tung@jp.ibm.com>
Signed-off-by: Tung D. Le <tung@jp.ibm.com>
…from_cli Signed-off-by: Tung D. Le <tung@jp.ibm.com>
Signed-off-by: Tung D. Le <tung@jp.ibm.com>
Signed-off-by: Tung D. Le <tung@jp.ibm.com>
Signed-off-by: Tung D. Le <tung@jp.ibm.com>
Signed-off-by: Tung D. Le <tung@jp.ibm.com>
Signed-off-by: Tung D. Le <tung@jp.ibm.com>
Signed-off-by: Tung D. Le <tung@jp.ibm.com>
Signed-off-by: Tung D. Le <tung@jp.ibm.com>
Signed-off-by: Tung D. Le <tung@jp.ibm.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR supports matching tensor information such as: rank, data type, dimension size in the JSON config file for NNPA.
For example: match MatMul operations of
A_3D x B_2Dand the last dimensions of A and B are divisible by 64, then use NNPA for those MatMul operations.{ "nnpa_ops_config": [ { "pattern": { "match": { "node_type": "onnx.MatMul", "inputs": { "0": { "rank": "3", "type": "f32", "dims": { "-1": "%64==0" } }, "1": { "rank": "2", "type": "f32", "dims": { "-1": "%64==0" } } } }, "rewrite": { "device": "nnpa" } } } ] }Supported patterns for checking integers (rank and dimension size):
Comparison Operators:
"3"- Exact match (implicit equality): value must equal 3">3"- Greater than: value must be > 3">=3"- Greater than or equal: value must be >= 3"<3"- Less than: value must be < 3"<=3"- Less than or equal: value must be <= 3"==3"- Explicit equality: value must equal 3"!=3"- Not equal: value must not equal 3Modulo Operations (for divisibility/alignment checks):
"%32==0"- Modulo constraint: (value % 32) must equal 0"%64==0"- Divisibility by 64: (value % 64) must equal 0"%N==R"- General form: (value % N) must equal RInput/output/dim index
See the documents JsonConfigFile-NNPA.md for more examples.