Git Product home page Git Product logo

Comments (4)

dan-zheng avatar dan-zheng commented on May 5, 2024

Sorry, this is a bug!

It seems that you are running the compiler-integrated REPL, which doesn't yet support TensorFlow (because the new TensorFlow-specific compiler passes aren't being run in executeSwiftSource).

I'll work on fixing this - in the meantime you'll have to build LLDB to use the REPL.
The easiest way to do so is to use the tensorflow_osx and tensorflow_linux build presets:

macOS:

# First, you'll need to create a Keychain Access certificate called "lldb_codesign".
# Follow the instructions here:
# https://github.com/llvm-mirror/lldb/blob/master/docs/code-signing.txt
SWIFT_PACKAGE=tensorflow_osx swift/utils/build-toolchain

Linux:

SWIFT_PACKAGE=tensorflow_linux swift/utils/build-toolchain

After building, you can run the LLDB-enabled REPL like so:

swift/swift-nightly-install/usr/bin/swift

You should see a prompt like:

Welcome to Swift version 4.2-dev (LLVM 04bdb56f3d, Clang b44dbbdf44). Type :help for assistance.
  1>

Please note that these build presets are likely to change frequently.

from swift.

viirya avatar viirya commented on May 5, 2024

Thanks! I'll try it.

from swift.

dan-zheng avatar dan-zheng commented on May 5, 2024

This is fixed in 5233a8f.

Verified on macOS and Ubuntu 16.04. (On Ubuntu 14.04, I got this "internal REPL unimplemented" error).

I ran the REPL like so:

$ build/buildbot_osx/swift-macosx-x86_64/bin/swift -O
***  You are running Swift's integrated REPL,  ***
***  intended for compiler and stdlib          ***
***  development and testing purposes only.    ***
***  The full REPL is built as part of LLDB.   ***
***  Type ':help' for assistance.              ***
(swift) import TensorFlow
(swift) var x = Tensor([[1, 2], [3, 4]])
// x : Tensor<Double> = [[1.0, 2.0], [3.0, 4.0]]
(swift) x * x
// r0 : Tensor<Double> = [[1.0, 4.0], [9.0, 16.0]]
(swift) for _ in 0..<3 {
          x += x
        }
(swift) x
// x : Tensor<Double> = [[8.0, 16.0], [24.0, 32.0]]

Notice that it's necessary to specify -O when running the compiler-integrated compiler. It's easy to turn on -O by default but we should avoid doing so when possible.

from swift.

viirya avatar viirya commented on May 5, 2024

Cool! Thanks. I will try it.

from swift.

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.