Skip to content

Commit

Permalink
Add SPDX License Identifiers and code clean up (#3)
Browse files Browse the repository at this point in the history
* Clean up the code
* Add SPDX License Identifiers to all source files
  • Loading branch information
xinyazhang committed Feb 14, 2024
1 parent a78e4d2 commit 2569660
Show file tree
Hide file tree
Showing 76 changed files with 338 additions and 184 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright © 2023-2024 Advanced Micro Devices, Inc.
# SPDX-License-Identifier: MIT

cmake_minimum_required(VERSION 3.18 FATAL_ERROR)

project(AOTriton CXX C)
Expand Down
43 changes: 0 additions & 43 deletions Makefile

This file was deleted.

18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
## Usage
## Build Instructions

```
mkdir build
python python/generate.py
(cd build; make -j `nproc` -f Makefile.compile)
python python/generate_shim.py
(cd build; make -j `nproc` -f Makefile.shim)
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=./install_dir
# Use ccmake to tweak options
make install
```

Then the `attn_fwd.so` and `attn_fwd.h` can be found under `build/`
The library and the header file can be found under `build/install_dir` afterwards.

Note: do not run `make` separately, due to the limit of the current build
system, `make install` will run the whole build process unconditionally.

### Prerequisites

* `hipcc`
* `triton`
* `hipcc` in `/opt/rocm/bin`, as a part of [ROCm](https://rocm.docs.amd.com/projects/install-on-linux/en/latest/)
3 changes: 3 additions & 0 deletions bindings/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright © 2023-2024 Advanced Micro Devices, Inc.
# SPDX-License-Identifier: MIT

aux_source_directory(. PYAOTRITON_SRC)
# find_package(hip REQUIRED)
pybind11_add_module(pyaotriton ${PYAOTRITON_SRC})
Expand Down
3 changes: 3 additions & 0 deletions bindings/hipruntime.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright © 2023-2024 Advanced Micro Devices, Inc.
// SPDX-License-Identifier: MIT

#include <aotriton/runtime.h>
#include <pybind11/pybind11.h>
namespace py = pybind11;
Expand Down
3 changes: 3 additions & 0 deletions bindings/module.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright © 2023-2024 Advanced Micro Devices, Inc.
// SPDX-License-Identifier: MIT

#include <aotriton/dtypes.h>
#include <aotriton/flash.h>
#include <aotriton/runtime.h>
Expand Down
3 changes: 3 additions & 0 deletions csrc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright © 2023-2024 Advanced Micro Devices, Inc.
# SPDX-License-Identifier: MIT

message("CMAKE_SOURCE_DIR ${CMAKE_SOURCE_DIR}")
message("CMAKE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}")
message("CMAKE_CURRENT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}")
Expand Down
3 changes: 3 additions & 0 deletions csrc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Deprecated Content

The code under this directory is deprecated, and will be removed in future releases.
3 changes: 3 additions & 0 deletions csrc/aotriton_kernel.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright © 2023-2024 Advanced Micro Devices, Inc.
// SPDX-License-Identifier: MIT

#ifndef AOTRITON_KERNEL_H
#define AOTRITON_KERNEL_H

Expand Down
3 changes: 3 additions & 0 deletions csrc/template/kernel_shim.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright © 2023-2024 Advanced Micro Devices, Inc.
// SPDX-License-Identifier: MIT

#define INCBIN_PREFIX g_aotriton_kernel_for_shim_
#define INCBIN_STYLE INCBIN_STYLE_SNAKE
#include <incbin.h>
Expand Down
3 changes: 3 additions & 0 deletions csrc/template/kernel_shim.footer.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright © 2023-2024 Advanced Micro Devices, Inc.
// SPDX-License-Identifier: MIT

}; // namespace aotriton::v1

#endif
3 changes: 3 additions & 0 deletions csrc/template/kernel_shim.header.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright © 2023-2024 Advanced Micro Devices, Inc.
// SPDX-License-Identifier: MIT

#ifndef AOTRITON_{shim_kernel_name}_H
#define AOTRITON_{shim_kernel_name}_H

Expand Down
3 changes: 3 additions & 0 deletions include/aotriton/_internal/triton_kernel.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright © 2023-2024 Advanced Micro Devices, Inc.
// SPDX-License-Identifier: MIT

#ifndef AOTRITON_V2_API_TRITON_KERNEL_H
#define AOTRITON_V2_API_TRITON_KERNEL_H

Expand Down
3 changes: 3 additions & 0 deletions include/aotriton/dtypes.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright © 2023-2024 Advanced Micro Devices, Inc.
// SPDX-License-Identifier: MIT

#ifndef AOTRITON_V2_API_DTYPES_H
#define AOTRITON_V2_API_DTYPES_H

Expand Down
3 changes: 3 additions & 0 deletions include/aotriton/flash.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright © 2023-2024 Advanced Micro Devices, Inc.
// SPDX-License-Identifier: MIT

#ifndef AOTRITON_V2_API_FLASH_ATTN_H
#define AOTRITON_V2_API_FLASH_ATTN_H

Expand Down
3 changes: 3 additions & 0 deletions include/aotriton/runtime.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright © 2023-2024 Advanced Micro Devices, Inc.
// SPDX-License-Identifier: MIT

#ifndef AOTRITON_V2_API_RUNTIME_H
#define AOTRITON_V2_API_RUNTIME_H

Expand Down
3 changes: 3 additions & 0 deletions include/aotriton/util.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright © 2023-2024 Advanced Micro Devices, Inc.
// SPDX-License-Identifier: MIT

#ifndef AOTRITON_V2_API_UTIL_H
#define AOTRITON_V2_API_UTIL_H

Expand Down
3 changes: 3 additions & 0 deletions python/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Deprecated Content

The code under this directory is deprecated, and will be removed in future releases.
132 changes: 0 additions & 132 deletions python/compile.py

This file was deleted.

1 change: 1 addition & 0 deletions python/compile.py
3 changes: 3 additions & 0 deletions python/generate.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright © 2023-2024 Advanced Micro Devices, Inc.
# SPDX-License-Identifier: MIT

import rules
import io
import shutil
Expand Down
3 changes: 3 additions & 0 deletions python/generate_shim.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright © 2023-2024 Advanced Micro Devices, Inc.
# SPDX-License-Identifier: MIT

import rules
import io
import shutil
Expand Down
2 changes: 2 additions & 0 deletions python/kernel_desc.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env python
# Copyright © 2023-2024 Advanced Micro Devices, Inc.
# SPDX-License-Identifier: MIT

from abc import ABC, abstractmethod
from pathlib import Path
Expand Down
2 changes: 2 additions & 0 deletions python/object_desc.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env python
# Copyright © 2023-2024 Advanced Micro Devices, Inc.
# SPDX-License-Identifier: MIT

from pathlib import Path
import json
Expand Down
3 changes: 3 additions & 0 deletions python/rules.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright © 2023-2024 Advanced Micro Devices, Inc.
# SPDX-License-Identifier: MIT

from kernel_desc import KernelDescription, get_possible_types

def _pattern(arguments, prefix):
Expand Down
3 changes: 3 additions & 0 deletions test/aotriton_flash.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright © 2023-2024 Advanced Micro Devices, Inc.
# SPDX-License-Identifier: MIT

from pyaotriton.v2.flash import attn_fwd as fa_forward, attn_bwd as fa_backward
from pyaotriton import T1, T2, T4, DType, Stream

Expand Down
2 changes: 2 additions & 0 deletions test/attn_torch_function.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env python
# Copyright © 2023-2024 Advanced Micro Devices, Inc.
# SPDX-License-Identifier: MIT

import torch
from aotriton_flash import attn_fwd, attn_bwd
Expand Down
2 changes: 2 additions & 0 deletions test/bwd_preprocess.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env python
# Copyright © 2023-2024 Advanced Micro Devices, Inc.
# SPDX-License-Identifier: MIT

"""
Fused Attention
Expand Down
2 changes: 2 additions & 0 deletions test/bwd_split_kernel.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env python
# Copyright © 2023-2024 Advanced Micro Devices, Inc.
# SPDX-License-Identifier: MIT

"""
Fused Attention
Expand Down
2 changes: 2 additions & 0 deletions test/fwd_kernel.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env python
# Copyright © 2023-2024 Advanced Micro Devices, Inc.
# SPDX-License-Identifier: MIT

"""
Fused Attention
Expand Down
2 changes: 2 additions & 0 deletions test/test_backward.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env python
# Copyright © 2023-2024 Advanced Micro Devices, Inc.
# SPDX-License-Identifier: MIT

import pytest
import torch
Expand Down
2 changes: 2 additions & 0 deletions test/test_forward.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env python
# Copyright © 2023-2024 Advanced Micro Devices, Inc.
# SPDX-License-Identifier: MIT

import pytest
import torch
Expand Down
Loading

0 comments on commit 2569660

Please sign in to comment.