@@ -61,8 +61,8 @@ look something like this::
61
61
# 3 * state_size for input gate, output gate and candidate cell gate.
62
62
# input_features + state_size because we will multiply with [input, h].
63
63
self.weights = torch.nn.Parameter(
64
- torch.Tensor (3 * state_size, input_features + state_size))
65
- self.bias = torch.nn.Parameter(torch.Tensor (3 * state_size))
64
+ torch.empty (3 * state_size, input_features + state_size))
65
+ self.bias = torch.nn.Parameter(torch.empty (3 * state_size))
66
66
self.reset_parameters()
67
67
68
68
def reset_parameters(self):
@@ -389,10 +389,9 @@ should look something like this::
389
389
390
390
A small note on compilers: Due to ABI versioning issues, the compiler you use to
391
391
build your C++ extension must be *ABI-compatible * with the compiler PyTorch was
392
- built with. In practice, this means that you must use GCC version 4.9 and above.
392
+ built with. In practice, this means that you must use GCC version 4.9 and above on Linux .
393
393
For Ubuntu 16.04 and other more-recent Linux distributions, this should be the
394
- default compiler already. On MacOS, you will have to download GCC (e.g. `brew
395
- install gcc ` will give you GCC 7 at the time of this writing). In the worst
394
+ default compiler already. On MacOS, you must use clang (which does not have any ABI versioning issues). In the worst
396
395
case, you can build PyTorch from source with your compiler and then build the
397
396
extension with that same compiler.
398
397
@@ -449,8 +448,8 @@ class citizens of PyTorch::
449
448
self.input_features = input_features
450
449
self.state_size = state_size
451
450
self.weights = torch.nn.Parameter(
452
- torch.Tensor (3 * state_size, input_features + state_size))
453
- self.bias = torch.nn.Parameter(torch.Tensor (3 * state_size))
451
+ torch.empty (3 * state_size, input_features + state_size))
452
+ self.bias = torch.nn.Parameter(torch.empty (3 * state_size))
454
453
self.reset_parameters()
455
454
456
455
def reset_parameters(self):
@@ -543,10 +542,12 @@ memory with ``.cuda()`` from Python::
543
542
for _ in range(100000):
544
543
start = time.time()
545
544
new_h, new_C = rnn(X, (h, C))
545
+ torch.cuda.synchronize()
546
546
forward += time.time() - start
547
547
548
548
start = time.time()
549
549
(new_h.sum() + new_C.sum()).backward()
550
+ torch.cuda.synchronize()
550
551
backward += time.time() - start
551
552
552
553
print('Forward: {:.3f} us | Backward {:.3f} us'.format(forward * 1e6/1e5, backward * 1e6/1e5))
0 commit comments