Skip to content

Commit

Permalink
Merging installation scripts.
Browse files Browse the repository at this point in the history
  • Loading branch information
RockfordWei committed Jun 14, 2017
1 parent 602f1ba commit 1c6ad35
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 66 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ The framework is Alpha testing now. Documents and examples are coming soon.
### TensorFlow C API Library Installation

Perfect-TensorFlow is based on TensorFlow C API, i.e., `libtensorflow.so` on runtime.
This project contains two express CPU v1.1.0 installation scripts for this module on both macOS / Ubuntu Linux, and will install the dynamic library into path `/usr/local/lib/libtensorflow.so`. You can download & run [`install.mac.sh`](https://github.com/PerfectlySoft/Perfect-TensorFlow/blob/master/install.mac.sh) for macOS X or [`install.linux.sh`](https://github.com/PerfectlySoft/Perfect-TensorFlow/blob/master/install.linux.sh).
This project contains an express CPU v1.1.0 installation script for this module on both macOS / Ubuntu Linux, and will install the dynamic library into path `/usr/local/lib/libtensorflow.so`. You can download & run [`install.sh`](https://github.com/PerfectlySoft/Perfect-TensorFlow/blob/master/install.sh).

For more installation options, such as GPU/CPU and multiple versions on the same machine, please check TensorFlow website: [Installing TensorFlow for C](https://www.tensorflow.org/install/install_c)

Expand Down Expand Up @@ -105,7 +105,7 @@ let tensor = try TF.Tensor.Scalar("Hello, Perfect TensorFlow! 🇨🇳🇨🇦")

// declare a new graph
let g = try TF.Graph()

// turn the tensor into an operation
let op = try g.const(tensor: tensor, name: "hello")

Expand All @@ -123,7 +123,7 @@ print(s2)
### Matrix Operations


As you can see, Swift version of TensorFlow keeps the same principals of the original one, i.e., create tensors, save tensors into graph, define the operations and then run the session & check the result.
As you can see, Swift version of TensorFlow keeps the same principals of the original one, i.e., create tensors, save tensors into graph, define the operations and then run the session & check the result.

Here is an other simple example of matrix operations in Perfect TensorFlow:

Expand All @@ -132,8 +132,8 @@ Here is an other simple example of matrix operations in Perfect TensorFlow:
| 1 2 | |0 1| |0 1|
| 3 4 | * |0 0| = |0 3|
*/
// input the matrix.
// *NOTE* no matter how many dimensions a matrix may have,
// input the matrix.
// *NOTE* no matter how many dimensions a matrix may have,
// the matrix should always input as an flattened array
let srcA:[Float] = [[1, 2], [3, 4]].flatMap { $0 }
let srcB:[Float] = [[0, 0], [1, 0]].flatMap { $0 }
Expand Down Expand Up @@ -170,12 +170,12 @@ let metaBuf = try TF.Buffer()
// load the session
let session = try g.load(
exportDir: "/path/to/saved/model",
tags: ["tag1", "tag2", ...],
tags: ["tag1", "tag2", ...],
metaGraphDef: metaBuf)
```

A detailed example of loading model can be found in the [Perfect TensorFlow Testing Examples](https://github.com/PerfectlySoft/Perfect-TensorFlow/blob/master/Tests/PerfectTensorFlowTests/PerfectTensorFlowTests.swift#L349-L390).

## Issues

We are transitioning to using JIRA for all bugs and support related issues, therefore the GitHub issues has been disabled.
Expand Down
6 changes: 3 additions & 3 deletions README.zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@

Perfect-TensorFlow 是基于其C语言函数库基础上的,简单说来就是您的计算机上在运行时必须安装 `libtensorflow.so`动态链接库。

本项目包含了两个用于快速安装该链接库 CPU v1.1.0版本的脚本,一个用于macOS而另外一个用于Ubuntu Linux。默认安装路径为`/usr/local/lib/libtensorflow.so`。您可以根据平台要求下载并运行 [`install.mac.sh`](https://github.com/PerfectlySoft/Perfect-TensorFlow/blob/master/install.mac.sh)[`install.linux.sh`](https://github.com/PerfectlySoft/Perfect-TensorFlow/blob/master/install.linux.sh).
本项目包含了一个用于快速安装该链接库 CPU v1.1.0版本的脚本,默认安装路径为`/usr/local/lib/libtensorflow.so`。您可以根据平台要求下载并运行 [`install.sh`](https://github.com/PerfectlySoft/Perfect-TensorFlow/blob/master/install.sh)

更多的安装选项,如需要在同一台计算机上同时安装CPU/GPU或者多个不同版本,请参考官网网站: [Installing TensorFlow for C](https://www.tensorflow.org/install/install_c)

Expand Down Expand Up @@ -105,7 +105,7 @@ let tensor = try TF.Tensor.Scalar("你好,Perfect TensorFlow! 🇨🇳🇨🇦

// 声明一个流程图
let g = try TF.Graph()

// 将张量节点加入流程图
let op = try g.const(tensor: tensor, name: "hello")

Expand Down Expand Up @@ -168,7 +168,7 @@ let metaBuf = try TF.Buffer()
// 还原会话
let session = try g.load(
exportDir: "/path/to/saved/model",
tags: ["tag1", "tag2", ...],
tags: ["tag1", "tag2", ...],
metaGraphDef: metaBuf)
```

Expand Down
1 change: 1 addition & 0 deletions Sources/PerfectTensorFlow/PerfectTensorFlow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
//
//===----------------------------------------------------------------------===//
//

import Foundation
import TensorFlowAPI

Expand Down
36 changes: 18 additions & 18 deletions Sources/TensorFlowAPI/TensorFlowAPI.c
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
//
// TensorFlowAPI.c
// Perfect-TensorFlow
//
// Created by Rockford Wei on 2017-05-18.
// Copyright © 2017 PerfectlySoft. All rights reserved.
//
//===----------------------------------------------------------------------===//
//
// This source file is part of the Perfect.org open source project
//
// Copyright (c) 2017 - 2018 PerfectlySoft Inc. and the Perfect project authors
// Licensed under Apache License v2.0
//
// See http://perfect.org/licensing.html for license information
//
//===----------------------------------------------------------------------===//
//
//
// TensorFlowAPI.c
// Perfect-TensorFlow
//
// Created by Rockford Wei on 2017-05-18.
// Copyright © 2017 PerfectlySoft. All rights reserved.
//
//===----------------------------------------------------------------------===//
//
// This source file is part of the Perfect.org open source project
//
// Copyright (c) 2017 - 2018 PerfectlySoft Inc. and the Perfect project authors
// Licensed under Apache License v2.0
//
// See http://perfect.org/licensing.html for license information
//
//===----------------------------------------------------------------------===//
//

#include "TensorFlowAPI.h"
#include <dlfcn.h>
Expand Down
37 changes: 19 additions & 18 deletions Sources/TensorFlowAPI/include/TensorFlowAPI.h
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
//
// TensorFlowAPI.h
// Perfect-TensorFlow
//
// Created by Rockford Wei on 2017-05-18.
// Copyright © 2017 PerfectlySoft. All rights reserved.
//
//===----------------------------------------------------------------------===//
//
// This source file is part of the Perfect.org open source project
//
// Copyright (c) 2017 - 2018 PerfectlySoft Inc. and the Perfect project authors
// Licensed under Apache License v2.0
//
// See http://perfect.org/licensing.html for license information
//
//===----------------------------------------------------------------------===//
//
//
// TensorFlowAPI.h
// Perfect-TensorFlow
//
// Created by Rockford Wei on 2017-05-18.
// Copyright © 2017 PerfectlySoft. All rights reserved.
//
//===----------------------------------------------------------------------===//
//
// This source file is part of the Perfect.org open source project
//
// Copyright (c) 2017 - 2018 PerfectlySoft Inc. and the Perfect project authors
// Licensed under Apache License v2.0
//
// See http://perfect.org/licensing.html for license information
//
//===----------------------------------------------------------------------===//
//

#ifndef __TENSOR_FLOW_STRUCT__
#define __TENSOR_FLOW_STRUCT__
#include <stddef.h>
Expand Down
10 changes: 0 additions & 10 deletions install.linux.sh

This file was deleted.

10 changes: 0 additions & 10 deletions install.mac.sh

This file was deleted.

14 changes: 14 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
OSABR=$(echo $(uname)|tr '[:upper:]' '[:lower:]')
DWN=/tmp/libtensorflow.tgz
DIR=/tmp/libtf
rm -rf $DIR
mkdir $DIR
rm -f $DWN
URL=https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-$OSABR-x86_64-1.1.0.tar.gz
echo $URL
curl $URL -o $DWN
tar xzf $DWN -C $DIR
sudo cp $DIR/lib/libtensorflow.so /usr/local/lib
rm -rf $DIR
rm -f $DWN
ls -l /usr/local/lib/libtensorflow.so

0 comments on commit 1c6ad35

Please sign in to comment.