Compare commits
No commits in common. "main" and "main" have entirely different histories.
|
|
@ -4,6 +4,7 @@ build-*/
|
|||
__pycache__/
|
||||
.pytest_cache/
|
||||
.mypy_cache/
|
||||
.vscode/
|
||||
.ruff_cache/
|
||||
*.pyc
|
||||
*.so
|
||||
|
|
@ -12,3 +13,5 @@ __pycache__/
|
|||
*.log
|
||||
/generated/
|
||||
/third_party/
|
||||
.git-credentials
|
||||
.vscode/
|
||||
|
|
|
|||
|
|
@ -0,0 +1,33 @@
|
|||
|
||||
```bash
|
||||
# git保存用户名密码
|
||||
# 本地仓库配置,不加 --global
|
||||
git config credential.helper store
|
||||
# 指定凭证文件存在项目目录(默认存在~/.git-credentials,改到本地)
|
||||
git config credential.helper "store --file ./.git-credentials"
|
||||
echo ".git-credentials" >> .gitignore
|
||||
# 查看本仓库git配置
|
||||
git config --list --local
|
||||
# 查看所有远程仓库
|
||||
git remote -v
|
||||
|
||||
# 将本地 master 分支重命名为 main
|
||||
git branch -m master main
|
||||
# 拉取远程 main 分支,同步远端代码
|
||||
git pull origin main --allow-unrelated-histories
|
||||
# 绑定本地 main 与远程 main,推送
|
||||
git push -u origin main
|
||||
# 查看本地 + 远程所有分支
|
||||
git branch -a
|
||||
|
||||
# 默认3.7.0版本不行
|
||||
rm -rf third_party/cutlass
|
||||
mkdir -p third_party
|
||||
cd third_party/cutlass
|
||||
git clone --depth 1 --branch v4.4.0 https://gitcode.com/NVIDIA/cutlass.git third_party/cutlass
|
||||
|
||||
cd build-nvidia
|
||||
cmake .. -DCMAKE_CUDA_ARCHITECTURES=80 -DCUTLASS_PATH=../third_party/cutlass
|
||||
|
||||
PYTHONPATH=python:. CAMP_BUILD_DIR=build-nvidia pytest tests/op_tests/test_copy.py -v
|
||||
```
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
import torch
|
||||
|
||||
from operator_runtime import copy, copy_
|
||||
from operator_runtime_testing import assert_close, require_cuda
|
||||
from tests.cases import copy as copy_cases
|
||||
|
||||
|
||||
@pytest.mark.parametrize("case", copy_cases.correctness_cases(), ids=lambda c: c["name"])
|
||||
def test_copy_correctness(case, backend):
|
||||
require_cuda()
|
||||
src = torch.randn(case["shape"], dtype=case["dtype"], device="cuda")
|
||||
out = copy(src, backend=backend)
|
||||
assert_close(out, src, atol=case["atol"], rtol=case["rtol"])
|
||||
|
||||
|
||||
@pytest.mark.parametrize("case", copy_cases.api_error_cases(), ids=lambda c: c["name"])
|
||||
def test_copy_api_contract(case, backend):
|
||||
require_cuda()
|
||||
if case["name"] == "shape_mismatch":
|
||||
src = torch.randn(case["shape"], device="cuda", dtype=case["dtype"])
|
||||
out = torch.empty(case["out_shape"], device="cuda", dtype=case["dtype"])
|
||||
with pytest.raises(ValueError, match="matching shapes"):
|
||||
copy_(out, src, backend=backend)
|
||||
return
|
||||
if case["name"] == "dtype_mismatch":
|
||||
src = torch.randn(case["shape"], device="cuda", dtype=case["dtype"])
|
||||
out = torch.empty(case["shape"], device="cuda", dtype=case["out_dtype"])
|
||||
with pytest.raises(TypeError, match="matching dtypes"):
|
||||
copy_(out, src, backend=backend)
|
||||
return
|
||||
if case["name"] == "non_contiguous":
|
||||
src = torch.randn(case["shape"], device="cuda", dtype=case["dtype"]).t()
|
||||
out = torch.empty(case["shape"], device="cuda", dtype=case["dtype"]).t()
|
||||
with pytest.raises(ValueError, match="contiguous"):
|
||||
copy_(out, src, backend=backend)
|
||||
return
|
||||
raise AssertionError(f"unhandled case: {case['name']}")
|
||||
Loading…
Reference in New Issue