GithubHelp home page GithubHelp logo

Comments (7)

LaurentMazare avatar LaurentMazare commented on May 10, 2024

Sure, you can run the following code.

open Torch;;
let x = Tensor.of_float1 [| 5.5; 3. |];;
Tensor.print x;;

Fwiw for playing with the library I often use utop by just running dune utop at the root of the github repo. You can then try various functions and have some nice code completion. You can also use the ocaml-jupyter kernel but it requires slightly more set up.
When writing code in an editor, merlin is a must have for completion, it allows you to easily discover the functions that you're looking for.

from ocaml-torch.

zeroexcuses avatar zeroexcuses commented on May 10, 2024
  1. Thanks, code worked.

  2. I have "dune utop" running, not at the top of the github repo, but in a separate directory with a dune file of

(executable
 (name scratch)
 (libraries base torch torch.core stdio))
  1. dune top is running inside tmux, which I can send commands to from Vim via vim-slime.

  2. I also have merlin/syntastic installed + working inside vim.

I definitely don't have a fluid workflow though. Here are issues I run into:

  1. When I type in Tensor. and hit C-x C-o for auto complete, it returns for me 1014 auto completion results. Mentally, I'm looking for one titled "tensor" or "from_slice" -- not "of_float." Secondly, because there's "of_float0, of_float1, of_float2, of_float3", it looks like auto generated internal functions, not functions I should call.

  2. I'm not sure if this is a problem of merlin or VIM -- but in my auto completion, it only shows the function name, not the type signature -- which is unfortunate, as reading the type signature would help alot.

  3. Of course, the type signature of tensor.ml functions are in tensor.mli, but I haven't quite figured outa fluid way to switch the two yet. There's ':MerlinTypeOf', but I haven't quite got a hang of it yet.

what would really help

Most of the time, I'd really like to be able to filter functions by type signature. So in this particular case, if I could say "list me all functions that take a float array as one of it's arguments, and returns a Tensor as output" that would drastically narrow everything. I'm not sure existing tools allow me to do this.

from ocaml-torch.

LaurentMazare avatar LaurentMazare commented on May 10, 2024

Cool, you seem to already have a nice setup. I do get the types with merlin in vim and that's very helpful.
Re (5), there are some ocamldoc comments in src/torch/tensor.mli that describe what of_floatX is doing. I don't get them in merlin though, maybe it's possible to set this up.

from ocaml-torch.

zeroexcuses avatar zeroexcuses commented on May 10, 2024

I do get the types with merlin in vim and that's very helpful.

Interesting. Are you (1) getting this during auto completion, where it shows the type signature of each potential completion or (2) getting this outside of auto completion, when cursor is over some identifier / expr ?

I can achieve (2) via :MerlinTypeOf, but I can't figure out how to do (1).

from ocaml-torch.

LaurentMazare avatar LaurentMazare commented on May 10, 2024

I get both (1) and (2), (1) looks like the following for me. I don't remember having to do anything special to get this to work (and I also get the types when using the completion in jupyter notebooks).
image

from ocaml-torch.

zeroexcuses avatar zeroexcuses commented on May 10, 2024

share

Weird, I'm not getting type signatures yet. Will look into why.

from ocaml-torch.

zeroexcuses avatar zeroexcuses commented on May 10, 2024

It turns out "Tensor." C-x C-o => names, but no types
"Tensor.X" C-x C-o where X xis any char => names with types

So now (1) also "works" for me. Thanks!

from ocaml-torch.

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.