Comments (8)
@rusty1s you can now pass None
if you use at::optional<at::Tensor>
in C++ (and at::nullopt
or nullptr
as the C++ default type)
from extension-cpp.
Hi, we don't currently provide a way of creating a "void"/"None" Tensor in our C++ extension API. Would it be enough for you to use something like at::empty(torch::CPU(at::kDouble), {0}));
as the default argument and then check with .numel() == 0
whether or not it is empty? This would work both in the function prototype and for the py::arg() = ...
.
Let me know whether this would be sufficient for you.
from extension-cpp.
Thanks! python setup.py install
now works perfectly.
However, calling the function in Python with a None
argument gives the following error message:
incompatible function arguments. The following argument types are supported:
1. (tensor1: at::Tensor, tensor2 = tensor([], dtype=torch.float64)) -> at::Tensor
Invoked with: tensor([2, 2]), None
from extension-cpp.
from extension-cpp.
Yeah, I see. Actually, I wanted to pass None
, but I guess I'm fine with the proposed solution (unless you know of an easy way to allow for None
arguments). Thanks again!
from extension-cpp.
I will keep the possibility of None
converting to an undefined Tensor in mind as we expand the extension API. Thanks for posting the issue! I'll mark it as resolved.
from extension-cpp.
@goldsborough how about we expose torch::optional
and let None
s bind to that?
from extension-cpp.
Yes that's a good idea, I'll do that
from extension-cpp.
Related Issues (20)
- www.facebook.com/rozi.khatun.961
- This repo can not compile using Pytorch 1.6.0 HOT 1
- This repo can not compile using Pytorch 1.6.0 HOT 1
- A question about backward propagation speed in cpp extension in tutorial
- Error when building cpp extension HOT 1
- AttributeError: module 'depthwise' has no attribute 'forward'
- cuda does not install HOT 17
- How does the layer of C++ extensions translate to TorchScript or onnx? HOT 1
- Cannot Unpack, Too Many Items
- How to debug in cuda-pytorch env?
- Writing a custom C++ extension with variants for both CPU and GPU? HOT 2
- Custom CUDA operator only work well on cuda:0 HOT 3
- How can I access data in cuda kernel like in pytorch?
- error LNK2001 undefined reference to `__cudaRegisterLinkedBinary
- Relation between at::Half and __half
- Deprecation warning
- Scikit-build-core / scikit-build support for binding
- `TORCH_LIBRARY` and `m.def` Not Working as Documented
- [feature request] Instruction on how to setup compile-env for Windows
- JIT-compiling the extension results in non-functional Python module.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from extension-cpp.