GithubHelp home page GithubHelp logo

Comments (3)

Clonkk avatar Clonkk commented on June 13, 2024 1

@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.

HugoGranstrom avatar HugoGranstrom commented on June 13, 2024

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.

HugoGranstrom avatar HugoGranstrom commented on June 13, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.