MCPcopy Create free account
hub / github.com/apache/singa / run

Function run

examples/hfl/src/client.py:202–357  ·  view source on GitHub ↗
(
        global_rank,
        world_size,
        device_id,
        max_epoch,
        batch_size,
        model,
        data,
        data_dist,
        sgd,
        graph,
        verbosity,
        dist_option="plain",
        spars=None,
        precision="float32",
)

Source from the content-addressed store, hash-verified

200
201
202def run(
203 global_rank,
204 world_size,
205 device_id,
206 max_epoch,
207 batch_size,
208 model,
209 data,
210 data_dist,
211 sgd,
212 graph,
213 verbosity,
214 dist_option="plain",
215 spars=None,
216 precision="float32",
217):
218 # Connect to server
219 client = Client(global_rank=device_id)
220 client.start()
221
222 dev = device.get_default_device()
223 dev.SetRandSeed(0)
224 np.random.seed(0)
225
226 # Prepare dataset
227 train_x, train_y, val_x, val_y, num_classes = get_data(data, data_dist, device_id)
228
229 num_channels = train_x.shape[1]
230 data_size = np.prod(train_x.shape[1: train_x.ndim]).item()
231
232 # Prepare model
233 model = get_model(
234 model, num_channels=num_channels, num_classes=num_classes, data_size=data_size
235 )
236
237 if model.dimension == 4:
238 image_size = train_x.shape[2]
239
240 # For distributed training, sequential has better performance
241 if hasattr(sgd, "communicator"):
242 DIST = True
243 sequential = True
244 else:
245 DIST = False
246 sequential = False
247
248 if DIST:
249 train_x, train_y, val_x, val_y = partition(
250 global_rank, world_size, train_x, train_y, val_x, val_y
251 )
252
253 if model.dimension == 4:
254 tx = tensor.Tensor(
255 (batch_size, num_channels, model.input_size, model.input_size),
256 dev,
257 singa_dtype[precision],
258 )
259 elif model.dimension == 2:

Callers 1

client.pyFile · 0.70

Calls 15

startMethod · 0.95
pullMethod · 0.95
copy_from_numpyMethod · 0.95
pushMethod · 0.95
closeMethod · 0.95
ClientClass · 0.85
get_dataFunction · 0.85
get_modelFunction · 0.85
TensorMethod · 0.80
SetVerbosityMethod · 0.80
partitionFunction · 0.70
augmentationFunction · 0.70

Tested by

no test coverage detected