-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbit_linear_new.py
More file actions
36 lines (23 loc) · 801 Bytes
/
bit_linear_new.py
File metadata and controls
36 lines (23 loc) · 801 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import torch
from bitnet import BitLinearNew
torch.set_default_device("cuda")
# Create a random tensor of shape (16, 10)
x = torch.randn(16, 1000, 512)
# Create an instance of the BitLinearNew class with input size 10, output size 20, and 2 groups
layer = BitLinearNew(512, 20)
import time
start_time = time.time()
# Perform a forward pass through the BitLinearNew layer with input x
output = layer(x)
# Print the output tensor
# print(output)
print(output.shape)
print("--- %s seconds ---" % (time.time() - start_time))
layer = torch.nn.Linear(512, 20)
start_time = time.time()
# Perform a forward pass through the torch.nn.Linear layer with input x
output = layer(x)
# Print the output tensor
# print(output)
print(output.shape)
print("--- %s seconds ---" % (time.time() - start_time))