Comments (4)
It would be great to support basic cross-type auto-converting arithmetic operations for floating point types as well.
Copy/Assignment operations are already supported (VERY permissive):
f = torch.FloatTensor(5)
d = torch.DoubleTensor(5).fill_(float('nan')) # fill with nan to challenge double->int...
i = torch.IntTensor(5)
d.copy_(f)
f.copy_(d) # ok, maybe I accept this as explicit cast...
f[:] = d[:] # implicit conversion to smaller type? data-scientists world...
d[:] = f[:]
i[:] = d[:] # wow, even double to int without complaints...
Things become strange/normal (depending on whether you are data or computer scientist) when you try to assign a SINGLE float to an int:
>>> i[1] = d[1]
RuntimeError: can't assign a float to a scalar value of type int
A nice feature I would like to see in the future are relatively save cross-type arithmetic ops for +,-,*,/ ... e.g.
r = d[:] + f[:]
# currently only possible with explicit conversion (-> additional copy), e.g.
r = d[:] + f[:].double()
Currently yields:
return self.add(other)
TypeError: add received an invalid combination of arguments - got (torch.FloatTensor), but expected one of:
* (float value)
didn't match because some of the arguments have invalid types: (torch.FloatTensor)
* (torch.DoubleTensor other)
didn't match because some of the arguments have invalid types: (torch.FloatTensor)
* (float value, torch.DoubleTensor other)
* (torch.DoubleTensor mat1, torch.SparseDoubleTensor mat2)
* (torch.DoubleTensor mat1, float value, torch.SparseDoubleTensor mat2)
from pytorch.
@soumith this issue was accidentally closed I believe
from pytorch.
This still does not work
from pytorch.
This works now after type promotion.
from pytorch.
Related Issues (20)
- Re-enable AsyncCompile.warm_pool in 3.12 Inductor
- Initial state of RNNs: h_0 or hx?
- torch.save and torch.load is slow. Slower than numpy. Slower even than pickle.
- [torch.compile][FlopCounter] AssertionError: Global is not OptimizedModule._orig_mod
- Libtorch crashes docker when included in header file HOT 5
- DISABLED test_batched_mm_float32_bs_10_cuda_float32 (__main__.TestDecompCUDA) HOT 1
- DISABLED test_comprehensive_ones_cuda_int32 (__main__.TestInductorOpInfoCUDA) HOT 5
- RPC + DDP VRAM overflow to rank 0 GPU. HOT 1
- [NestedTensor] torch.compile silent specialization on _max_seqlen
- MPS backend incorrect tensor slicing results
- [NestedTensor] NJT with lengths set fails torch.compile()
- DISABLED test_duplicate_backward_root (__main__.TestAutogradWithCompiledAutograd) HOT 3
- DISABLED test_refcounts (__main__.TestTorchTidyProfiler) HOT 2
- DISABLED test_aot_export_multiple_outputs_require_grad_banned (__main__.TestAOTExport) HOT 2
- Bot to recomment on high pri issues if no activity HOT 3
- [DeviceMesh] Current cache for submesh result is not thread save
- DISABLED test_inputs_aliasing_bytecode_stack_restore (__main__.TestCompiledAutograd) HOT 3
- DISABLED test_function_returns_input (__main__.TestAutogradWithCompiledAutograd) HOT 7
- [RFC] Add new CPP builder for inductor on pytorch Windows HOT 2
- [torch.compile] torch._dynamo.exc.TorchRuntimeError: Failed running call_function <method 'numpy' of 'torch._C.TensorBase' objects>(*(FakeTensor(..., size=(32, 3, 64, 64)),), **{})
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 pytorch.