How can I access data in cuda kernel like in pytorch?

未關閉
#79 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
2/5
預估耗時
1-3 小時
新手友好度
25/100
Issue 類型
缺陷
描述清晰度
需要釐清
活躍度
停滯
技術堆疊
cpp, python

研究方向

Start by reproducing with delete.py after building the add3 extension via setup.py install, since the attached test.zip is the only example. Compare the tensor's strides and contiguity on the Python side with the raw data pointer the kernel receives, and check how the extension's wrapper gets its input. Done means the reporter's question about transposed views is answered, with a reproduction showing why the kernel sees the original memory layout. The linear.cpp link in the issue points to code that is not in the payload.

由索引模型根據 Issue 內容生成。

描述

  • OS: win10
  • PyTorch version: 1.10
  • How you installed PyTorch (conda, pip, source): pip
  • Python version: 3.9
  • CUDA/cuDNN version: 11.3
  • GPU models and configuration: 1650 geforce PC
  • GCC version (if compiling from source): not sure/.....

I have a tensor a in pytorch, a. And then I transpose it to have a1. But it will not really transpose in memory, but just change the way we read it. And then we pass this pointer to the cuda kernel like is written in the tutorial. Then we access it within the kernel. It is not transposed!!!!! But we enter the pytorch interface and print out the transposed a1, it is correct!

How can we access the tensor within the kernel? We do not know whether it is
transposed or not!!!!

Thank you!!!
test.zip
I have attached a file here. You can reproduce it by unzip it.
Then open a python env with pytorch. Also have GPU
Then enter: python pytorch/setup.py install
You will install the "add3" library.
Then run the "delete.py" file within it. You will see how the bug appears like I discribe above!!

Another way to solve it is to understand how nn.linear solve it. How they can access data correctly? I think this is the implementation for nn.linear inside:
https://github.com/pytorch/pytorch/blob/4cb534f92ef6f5b2ec99109b0329f93a859ae831/torch/csrc/api/src/nn/modules/linear.cpp
But again it links to "torch::nn::linear" And I really can not find the cpp code for it.....

主要語言
Python
星號
1.2k
分支
250
PR 合併指標
30 天內沒有已合併 PR

環境準備

這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

pytorch/extension-cpp 的其他 Issue

查看 pytorch/extension-cpp 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。