Swift: In Xcode has a build error:Array input is not a constant array of tensors

Created on 28 Apr 2018  Â·  16Comments  Â·  Source: tensorflow/swift

code:
import TensorFlow
let x = Tensor([[1, 2], [3, 4]]) //error:Array input is not a constant array of tensors
print(x)

i have install tensorflow-swift。Xcode Version 9.3 (9E145) and Selected a Swift toolchain affects the Xcode。

but the same code is ok in Swift REPL

Most helpful comment

@rxwei I installed from toolchain.
The Xcode playground will work fine, but the Xcode Project will not.

@rxwei, @TuomaXu I solved the problem by manually adding tensorflow framework.

Step 1: Set -O

Build Settings -> Swift Compiler!!!! -> Code Generation -> Optimization Level

Optimize for Speed [-O]

2018-04-28 19 42 16

Step 2: Add two *.so Library

General -> Linked Frameworks and Libraries
libtensorflow.so and libtensorflow_framework.so in folder

/Library/Developer/Toolchains/swift-tensorflow-DEVELOPMENT-2018-04-26-a.xctoolchain/usr/lib/swift/macosx/

2018-04-28 19 23 46

Step 3: Set Runpath

Build Settings -> Linking -> Runpath Search Path:

/Library/Developer/Toolchains/swift-tensorflow-DEVELOPMENT-2018-04-26-a.xctoolchain/usr/lib/swift/macosx

2018-04-28 19 27 21

All 16 comments

Have you enabled the optimizer by passing the -O flag to the compiler?

@rxwei i do not . and how to passing the -O flag to the compiler? thanks!

@TuomaXu Choose Build Settings -> Swift Compiler!!!! -> Code Generation -> Optimization Level [-O]

@rxwei , after I choose to Optimize for Speed, I still get error:

"Undefined symbols for architecture x86_64" error appears at Link step:

Link ~/Library/Developer/Xcode/DerivedData/TensorFlowTest-dmfssjehvgbjmzfmfkuplflenfzq/Build/Products/Debug/TensorFlowTest

Ld ~/Library/Developer/Xcode/DerivedData/TensorFlowTest-dmfssjehvgbjmzfmfkuplflenfzq/Build/Products/Debug/TensorFlowTest normal x86_64
    cd ~/Desktop/TensorFlowTest
    export MACOSX_DEPLOYMENT_TARGET=10.13
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -L~/Library/Developer/Xcode/DerivedData/TensorFlowTest-dmfssjehvgbjmzfmfkuplflenfzq/Build/Products/Debug -F~/Library/Developer/Xcode/DerivedData/TensorFlowTest-dmfssjehvgbjmzfmfkuplflenfzq/Build/Products/Debug -filelist ~/Library/Developer/Xcode/DerivedData/TensorFlowTest-dmfssjehvgbjmzfmfkuplflenfzq/Build/Intermediates.noindex/TensorFlowTest.build/Debug/TensorFlowTest.build/Objects-normal/x86_64/TensorFlowTest.LinkFileList -mmacosx-version-min=10.13 -Xlinker -object_path_lto -Xlinker ~/Library/Developer/Xcode/DerivedData/TensorFlowTest-dmfssjehvgbjmzfmfkuplflenfzq/Build/Intermediates.noindex/TensorFlowTest.build/Debug/TensorFlowTest.build/Objects-normal/x86_64/TensorFlowTest_lto.o -Xlinker -export_dynamic -Xlinker -no_deduplicate -fobjc-link-runtime -L/Library/Developer/Toolchains/swift-tensorflow-DEVELOPMENT-2018-04-26-a.xctoolchain/usr/lib/swift_static/macosx -Xlinker -force_load_swift_libs -lc++ -framework Foundation -Xlinker -add_ast_path -Xlinker ~/Library/Developer/Xcode/DerivedData/TensorFlowTest-dmfssjehvgbjmzfmfkuplflenfzq/Build/Intermediates.noindex/TensorFlowTest.build/Debug/TensorFlowTest.build/Objects-normal/x86_64/TensorFlowTest.swiftmodule -Xlinker -dependency_info -Xlinker ~/Library/Developer/Xcode/DerivedData/TensorFlowTest-dmfssjehvgbjmzfmfkuplflenfzq/Build/Intermediates.noindex/TensorFlowTest.build/Debug/TensorFlowTest.build/Objects-normal/x86_64/TensorFlowTest_dependency_info.dat -o ~/Library/Developer/Xcode/DerivedData/TensorFlowTest-dmfssjehvgbjmzfmfkuplflenfzq/Build/Products/Debug/TensorFlowTest
Undefined symbols for architecture x86_64:
  "_TFE_ContextAddFunction", referenced from:
      _$S10TensorFlow8TFEState33_F1EB29DDC3964F4495E8056659BC5464LLC_16programByteCount24entryFunctionNameAddressADSV_SiSPys4Int8VGtcfc in libswiftTensorFlow.a(TensorFlow.o)
  "_TFE_ContextListDevices", referenced from:
      _$S10TensorFlow17_ExecutionContextCACycfc in libswiftTensorFlow.a(TensorFlow.o)
      ...
  "tensorflow::port::InitMain(char const*, int*, char***)", referenced from:
      _InitTensorFlowRuntime in libswiftTensorFlow.a(ctensorflow_init.cpp.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Did you download and install the toolchain, or just build from source?

Same problem, on linux Ubuntu, with a small difference:

this works:

swift -I/<...>/tfswift/usr/lib/swift/clang/include
Welcome to Swift version 4.2-dev (LLVM 04bdb56f3d, Clang b44dbbdf44). Type :help for assistance.
  1> import TensorFlow
  2> let x = Tensor([[1, 2], [3, 4]])
2018-04-28 18:22:43.037014: I tensorflow/core/platform/cpu_feature_guard.cc:140] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX
x: TensorFlow.Tensor<Double> = [[1.0, 2.0], [3.0, 4.0]]
  3> print(x)
[[1.0, 2.0], [3.0, 4.0]]
  4>  

however with main.swift

let x = Tensor([[1, 2], [3, 4]])
print(x)

This works....

swift -O Sources/tf1/main.swift
[[1.0, 2.0], [3.0, 4.0]]

but this doesn't

swift build
'tf1' /<.... >/swiftTF/tf1: warning: Ignoring duplicate product 'tf1' 
Compile Swift Module 'tf1' (1 sources)
/< ... >/swiftTF/tf1/Sources/tf1/main.swift:7:16: error: array input is not a constant array of tensors
let x = Tensor([[1, 2], [3, 4]])
               ^~~~~~~~~~~~~~~
error: terminated(1): /<>/tfswift/usr/bin/swift-build-tool -f /<>/swiftTF/tf1/.build/debug.yaml main output:

Any Ideas?

@Mamonaku Try swift build -Xswiftc -O. You still need to pass -O to run optimizations.

Bingo!! thanks!

@rxwei I installed from toolchain.
The Xcode playground will work fine, but the Xcode Project will not.

@rxwei, @TuomaXu I solved the problem by manually adding tensorflow framework.

Step 1: Set -O

Build Settings -> Swift Compiler!!!! -> Code Generation -> Optimization Level

Optimize for Speed [-O]

2018-04-28 19 42 16

Step 2: Add two *.so Library

General -> Linked Frameworks and Libraries
libtensorflow.so and libtensorflow_framework.so in folder

/Library/Developer/Toolchains/swift-tensorflow-DEVELOPMENT-2018-04-26-a.xctoolchain/usr/lib/swift/macosx/

2018-04-28 19 23 46

Step 3: Set Runpath

Build Settings -> Linking -> Runpath Search Path:

/Library/Developer/Toolchains/swift-tensorflow-DEVELOPMENT-2018-04-26-a.xctoolchain/usr/lib/swift/macosx

2018-04-28 19 27 21

Note the paths above will be broken with each new release

You can simply use swift-latest which is symlink to latest toolchain.

/Library/Developer/Toolchains/swift-tensorflow-DEVELOPMENT-2018-04-26-a.xctoolchain/usr/lib/swift/macosx

->

/Library/Developer/Toolchains/swift-latest/usr/lib/swift/macosx

It’s complaining it cant find symbols for python.
Try adding the Xcode python2.7.tdb file to the frameworks

On Friday, September 21, 2018, Gosicfly notifications@github.com wrote:

Cannot work well after setting as your workaround. Please help. @frogcjn
https://github.com/frogcjn
[image: image]
https://user-images.githubusercontent.com/11231087/45875281-beaec100-bdc9-11e8-885e-4162f2981d69.png

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/tensorflow/swift/issues/10#issuecomment-423483833,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AARsyq3fcgHXJyws_mGnENkIVtn2FWAMks5udLtggaJpZM4TrTPZ
.

I tried to compile as per document and got error messages. Please let me know how to solve this

* https://github.com/tensorflow/swift/blob/master/Usage.md#compiler

root@63a312dbe740:/root# swiftc -O inference.swift
/tmp/inference-114639.o:inference-114639.o:function $s9inference13MLPClassifierV2w110TensorFlow0D0VySfGvpfi: error: undefined reference to 'TF_NewStatus'
/tmp/inference-114639.o:inference-114639.o:function $s9inference13MLPClassifierV2w110TensorFlow0D0VySfGvpfi: error: undefined reference to 'TFE_NewOp'
/tmp/inference-114639.o:inference-114639.o:function $s9inference13MLPClassifierV2w110TensorFlow0D0VySfGvpfi: error: undefined reference to 'TFE_OpSetAttrType'
/tmp/inference-114639.o:inference-114639.o:function $s9inference13MLPClassifierV2w110TensorFlow0D0VySfGvpfi: error: undefined reference to 'TFE_OpSetAttrType'
/tmp/inference-114639.o:inference-114639.o:function $s9inference13MLPClassifierV2w110TensorFlow0D0VySfGvpfi: error: undefined reference to 'TFE_OpSetDevice'
/tmp/inference-114639.o:inference-114639.o:function $s9inference13MLPClassifierV2w110TensorFlow0D0VySfGvpfi: error: undefined reference to 'TFE_DeleteOp'
/tmp/inference-114639.o:inference-114639.o:function $s9inference13MLPClassifierV2w110TensorFlow0D0VySfGvpfi: error: undefined reference to 'TF_DeleteStatus'
/tmp/inference-114639.o:inference-114639.o:function $s9inference13MLPClassifierV2b210TensorFlow0D0VySfGvpfi: error: undefined reference to 'TF_NewStatus'
/tmp/inference-114639.o:inference-114639.o:function $s9inference13MLPClassifierV2b210TensorFlow0D0VySfGvpfi: error: undefined reference to 'TFE_NewOp'
/tmp/inference-114639.o:inference-114639.o:function $s9inference13MLPClassifierV2b210TensorFlow0D0VySfGvpfi: error: undefined reference to 'TFE_OpSetAttrInt'
/tmp/inference-114639.o:inference-114639.o:function $s9inference13MLPClassifierV2b210TensorFlow0D0VySfGvpfi: error: undefined reference to 'TFE_OpSetAttrType'
/tmp/inference-114639.o:inference-114639.o:function $s9inference13MLPClassifierV2b210TensorFlow0D0VySfGvpfi: error: undefined reference to 'TFE_OpSetDevice'
/tmp/inference-114639.o:inference-114639.o:function $s9inference13MLPClassifierV2b210TensorFlow0D0VySfGvpfi: error: undefined reference to 'TFE_DeleteOp'
/tmp/inference-114639.o:inference-114639.o:function $s9inference13MLPClassifierV2b210TensorFlow0D0VySfGvpfi: error: undefined reference to 'TF_DeleteStatus'
/tmp/inference-114639.o:inference-114639.o:function $s9inference13MLPClassifierV2b210TensorFlow0D0VySfGvpfi: error: undefined reference to 'TF_NewStatus'
/tmp/inference-114639.o:inference-114639.o:function $s9inference13MLPClassifierV2b210TensorFlow0D0VySfGvpfi: error: undefined reference to 'TFE_NewOp'
/tmp/inference-114639.o:inference-114639.o:function $s9inference13MLPClassifierV2b210TensorFlow0D0VySfGvpfi: error: undefined reference to 'TFE_OpSetAttrInt'
/tmp/inference-114639.o:inference-114639.o:function $s9inference13MLPClassifierV2b210TensorFlow0D0VySfGvpfi: error: undefined reference to 'TFE_OpSetAttrType'
/tmp/inference-114639.o:inference-114639.o:function $s9inference13MLPClassifierV2b210TensorFlow0D0VySfGvpfi: error: undefined reference to 'TFE_OpSetAttrInt'
/tmp/inference-114639.o:inference-114639.o:function $s9inference13MLPClassifierV2b210TensorFlow0D0VySfGvpfi: error: undefined reference to 'TFE_OpSetDevice'
/tmp/inference-114639.o:inference-114639.o:function $s9inference13MLPClassifierV2b210TensorFlow0D0VySfGvpfi: error: undefined reference to 'TFE_DeleteOp'
/tmp/inference-114639.o:inference-114639.o:function $s9inference13MLPClassifierV2b210TensorFlow0D0VySfGvpfi: error: undefined reference to 'TF_DeleteStatus'
/tmp/inference-114639.o:inference-114639.o:function $s9inference13MLPClassifierV10prediction3for10TensorFlow0E0VySfGAI_tF: error: undefined reference to 'TF_NewStatus'
/tmp/inference-114639.o:inference-114639.o:function $s9inference13MLPClassifierV10prediction3for10TensorFlow0E0VySfGAI_tF: error: undefined reference to 'TFE_NewOp'
/tmp/inference-114639.o:inference-114639.o:function $s9inference13MLPClassifierV10prediction3for10TensorFlow0E0VySfGAI_tF: error: undefined reference to 'TFE_OpSetAttrBool'
/tmp/inference-114639.o:inference-114639.o:function $s9inference13MLPClassifierV10prediction3for10TensorFlow0E0VySfGAI_tF: error: undefined reference to 'TFE_OpSetAttrBool'
/tmp/inference-114639.o:inference-114639.o:function $s9inference13MLPClassifierV10prediction3for10TensorFlow0E0VySfGAI_tF: error: undefined reference to 'TFE_OpSetDevice'
/tmp/inference-114639.o:inference-114639.o:function $s9inference13MLPClassifierV10prediction3for10TensorFlow0E0VySfGAI_tF: error: undefined reference to 'TFE_DeleteOp'
/tmp/inference-114639.o:inference-114639.o:function $s9inference13MLPClassifierV10prediction3for10TensorFlow0E0VySfGAI_tF: error: undefined reference to 'TF_DeleteStatus'
/tmp/inference-114639.o:inference-114639.o:function $s9inference13MLPClassifierV10prediction3for10TensorFlow0E0VySfGAI_tF: error: undefined reference to 'TFE_OpSetAttrBool'
/tmp/inference-114639.o:inference-114639.o:function $s9inference13MLPClassifierV10prediction3for10TensorFlow0E0VySfGAI_tF: error: undefined reference to 'TFE_OpSetAttrBool'
/tmp/inference-114639.o:inference-114639.o:function $s9inference13MLPClassifierVACycfC: error: undefined reference to 'TFE_OpSetAttrInt'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
:0: error: link command failed with exit code 1 (use -v to see invocation)
root@63a312dbe740:~# cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.4 LTS"

I tried to compile as per document and got error messages. Please let me know how to solve this

* https://github.com/tensorflow/swift/blob/master/Usage.md#compiler

root@63a312dbe740:/root# swiftc -O inference.swift
/tmp/inference-114639.o:inference-114639.o:function $s9inference13MLPClassifierV2w110TensorFlow0D0VySfGvpfi: error: undefined reference to 'TF_NewStatus'
/tmp/inference-114639.o:inference-114639.o:function $s9inference13MLPClassifierV2w110TensorFlow0D0VySfGvpfi: error: undefined reference to 'TFE_NewOp'
/tmp/inference-114639.o:inference-114639.o:function $s9inference13MLPClassifierV2w110TensorFlow0D0VySfGvpfi: error: undefined reference to 'TFE_OpSetAttrType'
/tmp/inference-114639.o:inference-114639.o:function $s9inference13MLPClassifierV2w110TensorFlow0D0VySfGvpfi: error: undefined reference to 'TFE_OpSetAttrType'
/tmp/inference-114639.o:inference-114639.o:function $s9inference13MLPClassifierV2w110TensorFlow0D0VySfGvpfi: error: undefined reference to 'TFE_OpSetDevice'
/tmp/inference-114639.o:inference-114639.o:function $s9inference13MLPClassifierV2w110TensorFlow0D0VySfGvpfi: error: undefined reference to 'TFE_DeleteOp'
/tmp/inference-114639.o:inference-114639.o:function $s9inference13MLPClassifierV2w110TensorFlow0D0VySfGvpfi: error: undefined reference to 'TF_DeleteStatus'
/tmp/inference-114639.o:inference-114639.o:function $s9inference13MLPClassifierV2b210TensorFlow0D0VySfGvpfi: error: undefined reference to 'TF_NewStatus'
/tmp/inference-114639.o:inference-114639.o:function $s9inference13MLPClassifierV2b210TensorFlow0D0VySfGvpfi: error: undefined reference to 'TFE_NewOp'
/tmp/inference-114639.o:inference-114639.o:function $s9inference13MLPClassifierV2b210TensorFlow0D0VySfGvpfi: error: undefined reference to 'TFE_OpSetAttrInt'
/tmp/inference-114639.o:inference-114639.o:function $s9inference13MLPClassifierV2b210TensorFlow0D0VySfGvpfi: error: undefined reference to 'TFE_OpSetAttrType'
/tmp/inference-114639.o:inference-114639.o:function $s9inference13MLPClassifierV2b210TensorFlow0D0VySfGvpfi: error: undefined reference to 'TFE_OpSetDevice'
/tmp/inference-114639.o:inference-114639.o:function $s9inference13MLPClassifierV2b210TensorFlow0D0VySfGvpfi: error: undefined reference to 'TFE_DeleteOp'
/tmp/inference-114639.o:inference-114639.o:function $s9inference13MLPClassifierV2b210TensorFlow0D0VySfGvpfi: error: undefined reference to 'TF_DeleteStatus'
/tmp/inference-114639.o:inference-114639.o:function $s9inference13MLPClassifierV2b210TensorFlow0D0VySfGvpfi: error: undefined reference to 'TF_NewStatus'
/tmp/inference-114639.o:inference-114639.o:function $s9inference13MLPClassifierV2b210TensorFlow0D0VySfGvpfi: error: undefined reference to 'TFE_NewOp'
/tmp/inference-114639.o:inference-114639.o:function $s9inference13MLPClassifierV2b210TensorFlow0D0VySfGvpfi: error: undefined reference to 'TFE_OpSetAttrInt'
/tmp/inference-114639.o:inference-114639.o:function $s9inference13MLPClassifierV2b210TensorFlow0D0VySfGvpfi: error: undefined reference to 'TFE_OpSetAttrType'
/tmp/inference-114639.o:inference-114639.o:function $s9inference13MLPClassifierV2b210TensorFlow0D0VySfGvpfi: error: undefined reference to 'TFE_OpSetAttrInt'
/tmp/inference-114639.o:inference-114639.o:function $s9inference13MLPClassifierV2b210TensorFlow0D0VySfGvpfi: error: undefined reference to 'TFE_OpSetDevice'
/tmp/inference-114639.o:inference-114639.o:function $s9inference13MLPClassifierV2b210TensorFlow0D0VySfGvpfi: error: undefined reference to 'TFE_DeleteOp'
/tmp/inference-114639.o:inference-114639.o:function $s9inference13MLPClassifierV2b210TensorFlow0D0VySfGvpfi: error: undefined reference to 'TF_DeleteStatus'
/tmp/inference-114639.o:inference-114639.o:function $s9inference13MLPClassifierV10prediction3for10TensorFlow0E0VySfGAI_tF: error: undefined reference to 'TF_NewStatus'
/tmp/inference-114639.o:inference-114639.o:function $s9inference13MLPClassifierV10prediction3for10TensorFlow0E0VySfGAI_tF: error: undefined reference to 'TFE_NewOp'
/tmp/inference-114639.o:inference-114639.o:function $s9inference13MLPClassifierV10prediction3for10TensorFlow0E0VySfGAI_tF: error: undefined reference to 'TFE_OpSetAttrBool'
/tmp/inference-114639.o:inference-114639.o:function $s9inference13MLPClassifierV10prediction3for10TensorFlow0E0VySfGAI_tF: error: undefined reference to 'TFE_OpSetAttrBool'
/tmp/inference-114639.o:inference-114639.o:function $s9inference13MLPClassifierV10prediction3for10TensorFlow0E0VySfGAI_tF: error: undefined reference to 'TFE_OpSetDevice'
/tmp/inference-114639.o:inference-114639.o:function $s9inference13MLPClassifierV10prediction3for10TensorFlow0E0VySfGAI_tF: error: undefined reference to 'TFE_DeleteOp'
/tmp/inference-114639.o:inference-114639.o:function $s9inference13MLPClassifierV10prediction3for10TensorFlow0E0VySfGAI_tF: error: undefined reference to 'TF_DeleteStatus'
/tmp/inference-114639.o:inference-114639.o:function $s9inference13MLPClassifierV10prediction3for10TensorFlow0E0VySfGAI_tF: error: undefined reference to 'TFE_OpSetAttrBool'
/tmp/inference-114639.o:inference-114639.o:function $s9inference13MLPClassifierV10prediction3for10TensorFlow0E0VySfGAI_tF: error: undefined reference to 'TFE_OpSetAttrBool'
/tmp/inference-114639.o:inference-114639.o:function $s9inference13MLPClassifierVACycfC: error: undefined reference to 'TFE_OpSetAttrInt'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
:0: error: link command failed with exit code 1 (use -v to see invocation)
root@63a312dbe740:~# cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.4 LTS"

  • Created the executable package and copied the example code
    {{{
    root@63a312dbe740:/root/inference# swift package init --type executable
    Creating executable package: inference
    Creating Package.swift
    Creating README.md
    Creating .gitignore
    Creating Sources/
    Creating Sources/inference/main.swift
    Creating Tests/
    Creating Tests/LinuxMain.swift
    Creating Tests/inferenceTests/
    Creating Tests/inferenceTests/inferenceTests.swift
    Creating Tests/inferenceTests/XCTestManifests.swift
    root@63a312dbe740:~/inference# mv ../inference.swift Sources/inference/main.swift
    }}}
  • Tried to build the swift package and got errors again. Please let know how to solve the problem.
    root@63a312dbe740:/root/inference# swift build -Xswiftc -O
    Compile Swift Module 'inference' (1 sources)
    /root/inference/Sources/inference/main.swift:10:25: warning: 'x' implicitly copied to the accelerator, use .toAccelerator() to make transfer explicit
    func prediction(for x: Tensor) -> Tensor {
    ~~^~~~
    /root/inference/Sources/inference/main.swift:11:23: note: value used here
    let o1 = tanh(matmul(x, w1) + b1)
    ^
    ~~
    /root/inference/Sources/inference/main.swift:11:33: warning: value implicitly copied to the accelerator, use .toAccelerator() to make transfer explicit
    let o1 = tanh(matmul(x, w1) + b1)
    ^~
    /root/inference/Sources/inference/main.swift:11:39: warning: value implicitly copied to the accelerator, use .toAccelerator() to make transfer explicit
    let o1 = tanh(matmul(x, w1) + b1)
    ^~
    /root/inference/Sources/inference/main.swift:12:32: warning: value implicitly copied to the accelerator, use .toAccelerator() to make transfer explicit
    return tanh(matmul(o1, w2) + b2)
    ^~
    /root/inference/Sources/inference/main.swift:12:38: warning: value implicitly copied to the accelerator, use .toAccelerator() to make transfer explicit
    return tanh(matmul(o1, w2) + b2)
    ^~

Linking ./.build/x86_64-unknown-linux/debug/inference
/root/inference/.build/x86_64-unknown-linux/debug/inference.build/main.swift.o:main.swift.o:function $s9inference13MLPClassifierV2w110TensorFlow0D0VySfGvpfi: error: undefined reference to 'TF_NewStatus'
/root/inference/.build/x86_64-unknown-linux/debug/inference.build/main.swift.o:main.swift.o:function $s9inference13MLPClassifierV2w110TensorFlow0D0VySfGvpfi: error: undefined reference to 'TFE_NewOp'
/root/inference/.build/x86_64-unknown-linux/debug/inference.build/main.swift.o:main.swift.o:function $s9inference13MLPClassifierV2w110TensorFlow0D0VySfGvpfi: error: undefined reference to 'TFE_OpSetAttrType'
/root/inference/.build/x86_64-unknown-linux/debug/inference.build/main.swift.o:main.swift.o:function $s9inference13MLPClassifierV2w110TensorFlow0D0VySfGvpfi: error: undefined reference to 'TFE_OpSetAttrType'
/root/inference/.build/x86_64-unknown-linux/debug/inference.build/main.swift.o:main.swift.o:function $s9inference13MLPClassifierV2w110TensorFlow0D0VySfGvpfi: error: undefined reference to 'TFE_OpSetDevice'
/root/inference/.build/x86_64-unknown-linux/debug/inference.build/main.swift.o:main.swift.o:function $s9inference13MLPClassifierV2w110TensorFlow0D0VySfGvpfi: error: undefined reference to 'TFE_DeleteOp'
/root/inference/.build/x86_64-unknown-linux/debug/inference.build/main.swift.o:main.swift.o:function $s9inference13MLPClassifierV2w110TensorFlow0D0VySfGvpfi: error: undefined reference to 'TF_DeleteStatus'
/root/inference/.build/x86_64-unknown-linux/debug/inference.build/main.swift.o:main.swift.o:function $s9inference13MLPClassifierV2b210TensorFlow0D0VySfGvpfi: error: undefined reference to 'TF_NewStatus'
/root/inference/.build/x86_64-unknown-linux/debug/inference.build/main.swift.o:main.swift.o:function $s9inference13MLPClassifierV2b210TensorFlow0D0VySfGvpfi: error: undefined reference to 'TFE_NewOp'
/root/inference/.build/x86_64-unknown-linux/debug/inference.build/main.swift.o:main.swift.o:function $s9inference13MLPClassifierV2b210TensorFlow0D0VySfGvpfi: error: undefined reference to 'TFE_OpSetAttrInt'
/root/inference/.build/x86_64-unknown-linux/debug/inference.build/main.swift.o:main.swift.o:function $s9inference13MLPClassifierV2b210TensorFlow0D0VySfGvpfi: error: undefined reference to 'TFE_OpSetAttrType'
/root/inference/.build/x86_64-unknown-linux/debug/inference.build/main.swift.o:main.swift.o:function $s9inference13MLPClassifierV2b210TensorFlow0D0VySfGvpfi: error: undefined reference to 'TFE_OpSetDevice'
/root/inference/.build/x86_64-unknown-linux/debug/inference.build/main.swift.o:main.swift.o:function $s9inference13MLPClassifierV2b210TensorFlow0D0VySfGvpfi: error: undefined reference to 'TFE_DeleteOp'
/root/inference/.build/x86_64-unknown-linux/debug/inference.build/main.swift.o:main.swift.o:function $s9inference13MLPClassifierV2b210TensorFlow0D0VySfGvpfi: error: undefined reference to 'TF_DeleteStatus'
/root/inference/.build/x86_64-unknown-linux/debug/inference.build/main.swift.o:main.swift.o:function $s9inference13MLPClassifierV2b210TensorFlow0D0VySfGvpfi: error: undefined reference to 'TF_NewStatus'
/root/inference/.build/x86_64-unknown-linux/debug/inference.build/main.swift.o:main.swift.o:function $s9inference13MLPClassifierV2b210TensorFlow0D0VySfGvpfi: error: undefined reference to 'TFE_NewOp'
/root/inference/.build/x86_64-unknown-linux/debug/inference.build/main.swift.o:main.swift.o:function $s9inference13MLPClassifierV2b210TensorFlow0D0VySfGvpfi: error: undefined reference to 'TFE_OpSetAttrInt'
/root/inference/.build/x86_64-unknown-linux/debug/inference.build/main.swift.o:main.swift.o:function $s9inference13MLPClassifierV2b210TensorFlow0D0VySfGvpfi: error: undefined reference to 'TFE_OpSetAttrType'
/root/inference/.build/x86_64-unknown-linux/debug/inference.build/main.swift.o:main.swift.o:function $s9inference13MLPClassifierV2b210TensorFlow0D0VySfGvpfi: error: undefined reference to 'TFE_OpSetAttrInt'
/root/inference/.build/x86_64-unknown-linux/debug/inference.build/main.swift.o:main.swift.o:function $s9inference13MLPClassifierV2b210TensorFlow0D0VySfGvpfi: error: undefined reference to 'TFE_OpSetDevice
'
/root/inference/.build/x86_64-unknown-linux/debug/inference.build/main.swift.o:main.swift.o:function $s9inference13MLPClassifierV2b210TensorFlow0D0VySfGvpfi: error: undefined reference to 'TFE_DeleteOp'
/root/inference/.build/x86_64-unknown-linux/debug/inference.build/main.swift.o:main.swift.o:function $s9inference13MLPClassifierV2b210TensorFlow0D0VySfGvpfi: error: undefined reference to 'TF_DeleteStatus'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
:0: error: link command failed with exit code 1 (use -v to see invocation)

What build is this? From a toolchain or from a local build?

steps in the below link with swift interpreter is working fine.

root@63a312dbe740:~# swift
Welcome to Swift version 4.2-dev (LLVM fd66ce58db, Clang cca52e8396, Swift 0fe79b79a3).
Type :help for assistance.
1> import TensorFlow
2> var x = Tensor([[1, 2], [3, 4]])
x: TensorFlow.Tensor = [[1.0, 2.0], [3.0, 4.0]]
3> x + x
$R2: TensorFlow.Tensor = [[2.0, 4.0], [6.0, 8.0]]
4> for _ in 0..<3 {

  1. x += x
  2. }
    7> x
    $R5: TensorFlow.Tensor = [[8.0, 16.0], [24.0, 32.0]]
    8> x[0] + x[1]
    $R8: TensorFlow.Tensor = [32.0, 48.0]
    9> :q

root@63a312dbe740:~/inference# swift --version
Swift version 4.2-dev (LLVM fd66ce58db, Clang cca52e8396, Swift 0fe79b79a3)
Target: x86_64-unknown-linux-gnu

Hi Richard,

I've been following progress with project - and wanted to capture experience.
Consider this as a side note + suggestion -
I installed the latest toolchain 12-4-18 but the symlink swift-latest is out of date.
/Library/Developer/Toolchains/swift-latest/usr/lib/swift/macosx is still pointing to an older build.
(which impacts the import of .so files causing bunch of errors.)

sudo rm -rf /Library/Developer/Toolchains/swift-latest
sudo ln -s  /Library/Developer/Toolchains/swift-tensorflow-DEVELOPMENT-2018-12-04-a.xctoolchain/ /Library/Developer/Toolchains/swift-latest

not sure how this step (which seems to have been working) could break in updating symlink with installer. maybe due to sudo?.
screen shot 2019-01-03 at 11 01 45 am

Until there's a stable release build v 1.0 - mismatches between any monthly build of libTensorflow.so files and toolchains are going to haunt developers.
It would be awesome if the toolchain could catch/detect a mismatch.
Eg. I have a project on computer - with out of date import of libTensorflow.so file

  • you open project some in 3 months time with latest toolchain installed - but you get a whole bunch of cryptic compile errors which are not so clear on where problem lies.
    But if the toolchain could spit out an internal mismatch error between .so file + toolchain - then a whole host of troubleshooting errors could be alleviated. It might be an effort to throw this specific error in xcode (even if it hit some source code that was a swift method was func sanityCheckVersionMismatchCheckYourToolchainVersion) - but would be really helpful for end users(as well as reducing support). Does that make sense?

UPDATE -
I posted notes on simplifying new projects for macOS / xcode using xcodeGen
https://groups.google.com/a/tensorflow.org/forum/#!topic/swift/kvyo_tpb7EE

see this cheat sheet -
https://gist.github.com/johndpope/7ad704adf84f4ff6dbf48da6abde31f7

Was this page helpful?
0 / 5 - 0 ratings