-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
186fe5b
commit 48d0651
Showing
10 changed files
with
64 additions
and
93 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
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import os | ||
import sys | ||
import getpass | ||
|
||
# config start | ||
KERNELDB_REQUEST_FNAME="kerneldb_request.log" | ||
NNFUSION_ROOT = os.path.normpath(os.path.join(os.path.dirname(os.path.realpath(__file__)), '../../..')) | ||
TMP_DIR = os.path.join(NNFUSION_ROOT, "artifacts/models/tmp") | ||
KERNELDB_PATH = os.path.expanduser("~/.cache/nnfusion/kernel_cache.db") | ||
NUM_GPU = 1 | ||
# config end | ||
|
||
os.environ["NNFUSION_ROOT"] = NNFUSION_ROOT | ||
os.environ["PATH"] = os.path.join(NNFUSION_ROOT, "build/src/tools/nnfusion") + ":" + os.environ["PATH"] | ||
sys.path.insert(1, os.path.abspath(NNFUSION_ROOT + "/src/python")) | ||
|
||
sys.path.insert(1, TMP_DIR) | ||
os.system(f"mkdir -p {TMP_DIR}") |
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# use the final.cu tuned on V100 | ||
|
||
import os | ||
from db import save_to_db | ||
from test_config import * | ||
from tvm import te, auto_scheduler | ||
|
||
def save(identifier, kernel_dir): | ||
with open(os.path.join("ansor_kernels", kernel_dir, "final.cu")) as f: | ||
final = f.readlines() | ||
# cut until a line with '}' | ||
best_source = "".join(final[:final.index("}\n") + 1])+"\n" | ||
best_grid_size = None | ||
best_block_size = None | ||
for line in final: | ||
if line.startswith("dim3 grid"): | ||
assert best_grid_size is None | ||
best_grid_size = line[len("dim3 grid"):].strip() | ||
best_grid_size = best_grid_size.replace("(", "").replace(");", "").split(", ") | ||
best_grid_size = tuple([int(x) for x in best_grid_size]) | ||
if line.startswith("dim3 block"): | ||
assert best_block_size is None | ||
best_block_size = line[len("dim3 block"):].strip() | ||
best_block_size = best_block_size.replace("(", "").replace(");", "").split(", ") | ||
best_block_size = tuple([int(x) for x in best_block_size]) | ||
assert best_grid_size is not None | ||
assert best_block_size is not None | ||
save_to_db(identifier, best_source, best_grid_size, best_block_size, device_type="ROCM_GPU") | ||
|
||
save("BatchMatMul[1,12,64,64;1,12,64,1;1,12,64,1floatfloatfloat]", "batch_matmul_4d_4d_expr_1_12_64_1_64_ansor") |
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
python3 manual_kernels.py --device ROCM_GPU |
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