MCPcopy Create free account
hub / github.com/Oneflow-Inc/oneflow / do_test_softmax

Function do_test_softmax

python/oneflow/test/modules/test_activation.py:456–470  ·  view source on GitHub ↗
(batch_size: int, log_softmax: bool = False)

Source from the content-addressed store, hash-verified

454
455
456def do_test_softmax(batch_size: int, log_softmax: bool = False):
457 num_dims = random(low=1, high=5).to(int)
458 m = torch.nn.Softmax(dim=random(low=0, high=num_dims).to(int) | nothing())
459 if log_softmax:
460 m = torch.nn.LogSoftmax(dim=random(low=0, high=num_dims).to(int) | nothing())
461 m.train(random())
462 device = random_device()
463 m.to(device)
464 x = (
465 random_tensor(ndim=num_dims).to(device)
466 if batch_size < 0
467 else random_tensor(ndim=num_dims, dim0=batch_size).to(device)
468 )
469 y = m(x)
470 return y
471
472
473@flow.unittest.skip_unless_1n1d()

Calls 8

nothingClass · 0.85
random_deviceClass · 0.85
random_tensorFunction · 0.85
SoftmaxMethod · 0.80
LogSoftmaxMethod · 0.80
randomClass · 0.50
toMethod · 0.45
trainMethod · 0.45

Tested by

no test coverage detected