Skip to content

Commit 815bae3

Browse files
authored
Add available pattern handlers for graph optimization in documentation (#553)
1 parent 58b2cb6 commit 815bae3

2 files changed

Lines changed: 28 additions & 11 deletions

File tree

docs/description/netspresso/enums/graph_optimize.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,21 @@ Graph optimization enums for configuring pattern handlers in NetsPresso's graph
1111
show_root_heading: true
1212
show_source: false
1313
show_symbol_type_toc: true
14+
15+
## Available Pattern Handlers
16+
17+
| Category | Pattern Name | Status | Description |
18+
|----------|--------------|--------|-------------|
19+
| **Fuse** | `PatternHandlerFuseBNToConv` || Fuse batch normalization to convolution layers |
20+
| **Fuse** | `PatternHandlerFuseMathIntoConv` || Fuse math operators (add, sub, mul, div) to convolution recursively |
21+
| **Fuse** | `PatternHandlerFuseMultiReshapeTranspose` || Fuse multiple reshapes and transposes into one |
22+
| **Fuse** | `PatternHandlerFuseMultiBranchReshapeTranspose` | To do | Fuse multiple branched reshapes and transposes into one |
23+
| **Fuse** | `PatternHandlerFuseContinuousConcat` || Fuse continuous concatenation operations |
24+
| **Fuse** | `PatternHandlerFoldingGeLU` || Optimize GeLU activation functions by folding |
25+
| **Fuse** | `PatternHandlerFoldingSilu` || Optimize SiLU activation functions by folding |
26+
| **Fuse** | `PatternHandlerFoldingRMSNorm` || Optimize RMS normalization layers by folding |
27+
| **Fuse** | `PatternHandlerFoldingLayerNorm` || Optimize layer normalization operations by folding |
28+
| **Remove** | `PatternHandlerRemoveUselessSlice` || Remove meaningless tensor slice operators |
29+
| **Replace** | `PatternHandlerReplaceNegToConv` || Replace negation by depthwise convolution |
30+
| **Replace** | `PatternHandlerReplaceMatmulToConv` || Replace matrix multiplication with convolution operations |
31+
| **Optimize** | `PatternHandlerChangeAxisOfSoftmax` || Optimize softmax operations by changing axis configurations |

netspresso/simulator/simulator.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,20 @@ def create_metadata_with_status(status, error_message=None):
4848

4949
def _upload_model_file(self, model_path: str) -> ResponseModelItem:
5050
# Get presigned_model_upload_url
51-
presigned_url_response = launcher_client_v2.graph_optimizer.presigned_model_upload_url(
51+
presigned_url_response = launcher_client_v2.simulator.presigned_model_upload_url(
5252
access_token=self.token_handler.tokens.access_token,
5353
input_model_path=model_path,
5454
)
5555

5656
# Upload model_file
57-
launcher_client_v2.graph_optimizer.upload_model_file(
57+
launcher_client_v2.simulator.upload_model_file(
5858
access_token=self.token_handler.tokens.access_token,
5959
input_model_path=model_path,
6060
presigned_upload_url=presigned_url_response.data.presigned_upload_url,
6161
)
6262

6363
# Validate model_file
64-
validate_model_response = launcher_client_v2.graph_optimizer.validate_model_file(
64+
validate_model_response = launcher_client_v2.simulator.validate_model_file(
6565
access_token=self.token_handler.tokens.access_token,
6666
input_model_path=model_path,
6767
ai_model_id=presigned_url_response.data.ai_model_id,
@@ -76,20 +76,19 @@ def simulate_model(
7676
output_dir: str,
7777
dataset_path: Optional[str] = None,
7878
) -> SimulatorMetadata:
79-
"""Optimize a model to the specified framework.
79+
"""Simulate a model to the specified framework.
8080
8181
Args:
82-
input_model_path (str): The file path where the model is located.
83-
output_dir (str): The local folder path to save the optimized model.
84-
pattern_handlers (List[GraphOptimizePatternHandler]): The pattern handlers to optimize the model.
85-
wait_until_done (bool): If True, wait for the graph optimize result before returning the function.
86-
If False, request the graph optimize and return the function immediately.
82+
base_model_path (str): The file path where the base model is located.
83+
target_model_path (str): The file path where the target model is located.
84+
output_dir (str): The local folder path to save the simulation result.
85+
dataset_path (str): The file path where the dataset is located.
8786
8887
Raises:
89-
e: If an error occurs during the graph optimize.
88+
e: If an error occurs during the simulation.
9089
9190
Returns:
92-
GraphOptimizerMetadata: Graph optimize metadata.
91+
SimulatorMetadata: Simulator metadata.
9392
"""
9493

9594
netspresso_analytics.send_event(event_name="simulate_model_using_np")

0 commit comments

Comments
 (0)