Comments (3)
@HugoGranstrom I think this is mostly fixed and I propose we close this. I've reviewed the high level API and it uses openArray or Varargs for most procs and convert with as TorchView internally.
The low level API will still rely on asTorchView / ArrayRef so be as close as C++ Torch as possible.
from flambeau.
I've stumbled upon this a fair bit myself. The problem is that the expression is inline and doesn't have an address. So if we just assign it to a variable in asTorchView
it does work:
template asTorchView*[T](oa: openarray[T]): ArrayRef[T] =
let a = oa
ArrayRef[T].init(a[0].unsafeAddr, oa.len)
Not sure if we introduce unneccecary copies though, but as oa
is openarray
it should only be the pointer+len that is copied into a
.
from flambeau.
Even though this works, I still think we should expose openarray
for the high-level API. asTorchView
is 11 characters too long for me 😝
from flambeau.
Related Issues (20)
- Which C++ library? HOT 2
- Brand Name HOT 6
- defModule macro to define neural nets without inline C++ HOT 30
- nimble file with torch_installer run on install HOT 2
- Fix linking
- vendoring and wrapping torchvision, torchtext and torchaudio
- Problems with ArrayRef in the C++ compiler HOT 1
- Fix accessors HOT 1
- [RFC] Should we keep dimensions (like Arraymancer) or squezze dimensions (like Pytorch) by default HOT 6
- Error: undeclared identifier: 'IntArrayRef' HOT 1
- Comparing Tensor of different type segfault HOT 1
- item(Complex64) does not compile HOT 15
- Operation on Tensor with different shape cause a segfault HOT 1
- Convert C10_Complex / CppComplex to Nim Complex[T] on high level API HOT 8
- To `lent` or not to `lent` HOT 4
- define NOMINMAX when compiling your program on Windows HOT 5
- `hasCuda` is not in global Torch scope HOT 3
- CI is broken for Windows
- Project status HOT 3
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 flambeau.