-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Add Numpy / Torch / Triton differentiation" (#20)
This reverts commit e5e549d.
- Loading branch information
Showing
2 changed files
with
4 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,8 @@ | ||
import triton.language as tl | ||
import triton | ||
import torch | ||
|
||
|
||
@triton.jit | ||
def vector_add_kernel(A, B, C, N, BLOCK_SIZE: tl.constexpr): | ||
# Get the unique program ID for each block | ||
pid = tl.program_id(0) | ||
|
||
# Calculate the start index for each block | ||
start = pid * BLOCK_SIZE | ||
|
||
# Load data from A and B into registers for vector addition | ||
offset = start + tl.arange(0, BLOCK_SIZE) | ||
a = tl.load(A + offset, mask=offset < N) # Load elements from A | ||
b = tl.load(B + offset, mask=offset < N) # Load elements from B | ||
|
||
# Perform element-wise addition | ||
c = a + b | ||
|
||
# Store the result back into C | ||
tl.store(C + offset, c, mask=offset < N) | ||
|
||
|
||
a = torch.Tensor([1, 2, 3, 4, 5]).cuda() | ||
b = torch.Tensor([1, 2, 3, 4, 5]).cuda() | ||
b= torch.Tensor([1, 2, 3, 4, 5]).cuda() | ||
|
||
print(a) | ||
print(b) | ||
print(a + b) | ||
|
||
print(a + b) |