ShardGraphs
Applicable Products
Ascend 950PR /Ascend 950DT : not supportedAtlas A3 training products /Atlas A3 inference products : not supportedAtlas A2 training products /Atlas A2 inference products : supportedAtlas 200I/500 A2 inference products : not supportedAtlas inference products : supportedAtlas training products : supported
Header File/Library File
- Header file: #include <ge/ge_api.h>
- Library file: libge_runner.so
Function Usage
This API is deprecated. Avoid using it.
This API is not recommended. ShardGraphsToFile is recommended. The performance of the ShardGraphsToFile API is better than that of the ShardGraphs API.
This API shards graphs in a session based on the AddGraph sequence. Sharded graphs are saved in the memory.
The sharding mode is specified by the ge.graphParallelOptionPath option. See Options. If the parallel graph function is disabled, this API does not work.
Naming rules for sharded graphs:
- In SPMD mode: The naming format is {Original graph name}_{ClusterId}_{ItemId}_{ChipId}_{VirtualStageId}_{Original GraphId}. The number of sharded graphs equals the number of original graphs multiplied by the number of shards.
- In non-SPMD mode: The naming format is {Original graph name}_{Original GraphId}. The number of sharded graphs equals the number of original graphs.
After a graph is sharded, it does not exist in the session. For the ID of the newly generated graph after sharding, the original graph ID is replaced by another ID.
- ShardGraphs can search for the strategy, shard a graph, and output sharded graphs. Sharded graphs are saved in the memory and then flushed to disks using SaveGraphsToPb.
- ShardGraphsToFile can search for the strategy, shard a graph, and output sharded graphs. Sharded graphs are also flushed to disks using this API (file_path must be a valid path).
Prototype
1 | Status Session::ShardGraphs() |
Parameters
N/A
Returns
Parameter |
Type |
Description |
|---|---|---|
- |
Status |
SUCCESS: success. FAILED: failure. |
Restrictions
This API takes effect only when the parallel graph function is enabled.
Example
1 2 3 4 5 | Session session(options); // The parallel graph function has been enabled through options. Graph init_graph("init_graph"); Graph first_graph("first_graph"); Graph second_graph("second_graph"); session.ShardGraphs(); |