This repository has been archived by the owner on Jan 25, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
pcpLiu
committed
Nov 3, 2017
0 parents
commit 76e99d8
Showing
266 changed files
with
42,135 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
ignore: | ||
- "Source/library" # C library | ||
- "Tests" # Test files | ||
|
||
max_report_age: off |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# C libarary | ||
Source/library/* linguist-vendored |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<hr> | ||
<hr> | ||
|
||
## DO NOT Submit Non-bug Issue or Framework Question Here | ||
Please go to [pcpLiu/SerranoExplore](https://github.com/pcpLiu/SerranoExplore) opening an issue for general support. This repo only accepts bug-related issues. | ||
|
||
<hr> | ||
<hr> | ||
<!-- | ||
Fill the form below. Replace content in `()` with your information. | ||
All fields are required excepted optional fields. | ||
--> | ||
|
||
#### Description | ||
(Give a overall description of the situation you have met) | ||
|
||
|
||
#### Environment Information | ||
- Serrano version: (XXXXX) | ||
- Xcode Version: (XXXXX) | ||
- Platform: (macOS or iOS) | ||
- Platform System version: (iOSxxxx or macOSxxx) | ||
|
||
|
||
#### Reproduce Steps | ||
(A __gist__ or __github repo__ is prefered. Should be detailed enough to reproduce.) | ||
|
||
|
||
#### Expecting behavior | ||
(Describe what result or behavior should be expecting) | ||
|
||
|
||
#### Actual behavior | ||
(Describe actual result or behavior) | ||
|
||
|
||
#### Possible Implementation (Optional) | ||
(Optional implementation to fix this bug) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<hr> | ||
<hr> | ||
|
||
## DO NOT Submit Non-bug PR Here | ||
Please go to [pcpLiu/SerranoExplore](https://github.com/pcpLiu/SerranoExplore) to discuss feature enhancements. This repo only accepts bug-related PRs. | ||
|
||
<hr> | ||
<hr> | ||
|
||
<!-- | ||
Fill the form below. Replace content in `()` with your information. | ||
All fields are required excepted optional fields. | ||
--> | ||
#### Description | ||
(Description of this PR) | ||
|
||
#### Related Issues | ||
(List related issues for this PR) | ||
|
||
#### How Has This Been Tested? | ||
(Give information how your tested the fixed code) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
serrano.xcodeproj/xcuserdata | ||
.testing | ||
xcuserdata | ||
|
||
*.coverage.txt | ||
*.xccoverage.plist | ||
|
||
.cov/ | ||
build/ | ||
DerivedData/ | ||
|
||
# auto generated local docs | ||
docs/generated_docs/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
## This configure used to generate guides docs only. Not for API | ||
|
||
|
||
xcodebuild_arguments: ['-scheme', 'TestingHostApp', '-project', 'serrano.xcodeproj'] | ||
module: Serrano | ||
|
||
author: pcpLiu | ||
author_url: https://github.com/pcpLiu | ||
github_url: https://github.com/pcpLiu/Serrano | ||
module_version: v0.1.0-alpha | ||
github_file_prefix: https://github.com/pcpLiu/Serrano/tree/v0.1.0-alpha | ||
root_url: http://serrano-lib.org/docs/v0.1.0-alpha/guides | ||
theme: docs/fullwidth | ||
output: docs/generated_docs/v0.1.0-alpha/guides | ||
|
||
# Generate guides only | ||
exclude: Source/* | ||
|
||
|
||
documentation: docs/guides/**/*.md | ||
abstract: docs/sections/**/*.md' | ||
readme: docs/sections/Home.md | ||
|
||
|
||
# Layout | ||
custom_categories: | ||
- name: 'Getting started' | ||
children: | ||
- 'What is Serrano' | ||
- 'Core concepts' | ||
- 'VGG16 Example' | ||
- name: 'Extension' | ||
children: | ||
- 'Write your own operator' | ||
- 'Write your own optimizer' | ||
- name: 'Contribution' | ||
children: [Contribution] | ||
- name: 'API Reference' | ||
children: [API Reference] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
os: osx | ||
osx_image: xcode9 | ||
language: swift | ||
xcode_sdk: | ||
- iphonesimulator10.3 | ||
- macosx10.12 | ||
|
||
branches: | ||
only: | ||
- master | ||
|
||
script: | ||
- bash scripts/travisCI.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
import XCTest | ||
import Serrano | ||
|
||
/** | ||
This code shows how to construct a VGG16 network using graph's low-level API. | ||
[vgg16](http://book.paddlepaddle.org/03.image_classification/image/vgg16.png) | ||
*/ | ||
func configureVGG16() -> ComputationGraph { | ||
let g = ComputationGraph() | ||
|
||
// input [244, 244, 3] | ||
let shape = TensorShape(dataType: .float, shape: [244, 244, 3]) | ||
let input = g.tensor(shape: shape) | ||
|
||
// block 1 | ||
let convOp = ConvOperator2D(numFilters: 64, | ||
kernelSize: [3, 3], | ||
padMode: PaddingMode.Same, | ||
channelPosition: TensorChannelOrder.Last, | ||
inputShape: input.shape) | ||
let (out, _, _) = g.operation(inputs: [input], op: convOp) | ||
|
||
let convOp1 = ConvOperator2D(numFilters: 64, | ||
kernelSize: [3, 3], | ||
padMode: PaddingMode.Same, | ||
channelPosition: TensorChannelOrder.Last, | ||
inputShape: out.first!.shape) | ||
let (out1, _, _) = g.operation(inputs: out, op: convOp1) | ||
|
||
let poo1 = MaxPool2DOperator(kernelSize: [2, 2], | ||
channelPosition: TensorChannelOrder.Last, | ||
paddingMode: PaddingMode.Valid) | ||
let (out_block_1, _, _) = g.operation(inputs: out1, op: poo1) | ||
|
||
// block 2 | ||
let convOp2 = ConvOperator2D(numFilters: 128, | ||
kernelSize: [3, 3], | ||
padMode: PaddingMode.Same, | ||
channelPosition: TensorChannelOrder.Last, | ||
inputShape: out_block_1.first!.shape) | ||
let (out2, _, _) = g.operation(inputs: out_block_1, op: convOp2) | ||
|
||
let convOp3 = ConvOperator2D(numFilters: 128, | ||
kernelSize: [3, 3], | ||
padMode: PaddingMode.Same, | ||
channelPosition: TensorChannelOrder.Last, | ||
inputShape: out2.first!.shape) | ||
let (out3, _, _) = g.operation(inputs: out2, op: convOp3) | ||
|
||
let poo2 = MaxPool2DOperator(kernelSize: [2, 2], | ||
channelPosition: TensorChannelOrder.Last, | ||
paddingMode: PaddingMode.Valid) | ||
let (out_block_2, _, _) = g.operation(inputs: out3, op: poo2) | ||
|
||
// block 3 | ||
let convOp4 = ConvOperator2D(numFilters: 256, | ||
kernelSize: [3, 3], | ||
padMode: PaddingMode.Same, | ||
channelPosition: TensorChannelOrder.Last, | ||
inputShape: out_block_2.first!.shape) | ||
let (out4, _, _) = g.operation(inputs: out_block_2, op: convOp4) | ||
|
||
let convOp5 = ConvOperator2D(numFilters: 256, | ||
kernelSize: [3, 3], | ||
padMode: PaddingMode.Same, | ||
channelPosition: TensorChannelOrder.Last, | ||
inputShape: out4.first!.shape) | ||
let (out5, _, _) = g.operation(inputs: out4, op: convOp5) | ||
|
||
let convOp6 = ConvOperator2D(numFilters: 256, | ||
kernelSize: [3, 3], | ||
padMode: PaddingMode.Same, | ||
channelPosition: TensorChannelOrder.Last, | ||
inputShape: out5.first!.shape) | ||
let (out6, _, _) = g.operation(inputs: out5, op: convOp6) | ||
|
||
let poo3 = MaxPool2DOperator(kernelSize: [2, 2], | ||
channelPosition: TensorChannelOrder.Last, | ||
paddingMode: PaddingMode.Valid) | ||
let (out_block_3, _, _) = g.operation(inputs: out6, op: poo3) | ||
|
||
// bloack 4 | ||
let convOp7 = ConvOperator2D(numFilters: 512, | ||
kernelSize: [3, 3], | ||
padMode: PaddingMode.Same, | ||
channelPosition: TensorChannelOrder.Last, | ||
inputShape: out_block_3.first!.shape) | ||
let (out7, _, _) = g.operation(inputs: out_block_3, op: convOp7) | ||
|
||
let convOp8 = ConvOperator2D(numFilters: 512, | ||
kernelSize: [3, 3], | ||
padMode: PaddingMode.Same, | ||
channelPosition: TensorChannelOrder.Last, | ||
inputShape: out7.first!.shape) | ||
let (out8, _, _) = g.operation(inputs: out7, op: convOp8) | ||
|
||
let convOp9 = ConvOperator2D(numFilters: 512, | ||
kernelSize: [3, 3], | ||
padMode: PaddingMode.Same, | ||
channelPosition: TensorChannelOrder.Last, | ||
inputShape: out8.first!.shape) | ||
let (out9, _, _) = g.operation(inputs: out8, op: convOp9) | ||
|
||
let poo4 = MaxPool2DOperator(kernelSize: [2, 2], | ||
channelPosition: TensorChannelOrder.Last, | ||
paddingMode: PaddingMode.Valid) | ||
let (out_block_4, _, _) = g.operation(inputs: out9, op: poo4) | ||
|
||
// block 5 | ||
let convOp10 = ConvOperator2D(numFilters: 512, | ||
kernelSize: [3, 3], | ||
padMode: PaddingMode.Same, | ||
channelPosition: TensorChannelOrder.Last, | ||
inputShape: out_block_4.first!.shape) | ||
let (out10, _, _) = g.operation(inputs: out_block_4, op: convOp10) | ||
|
||
let convOp11 = ConvOperator2D(numFilters: 512, | ||
kernelSize: [3, 3], | ||
padMode: PaddingMode.Same, | ||
channelPosition: TensorChannelOrder.Last, | ||
inputShape: out10.first!.shape) | ||
let (out11, _, _) = g.operation(inputs: out10, op: convOp11) | ||
|
||
let convOp12 = ConvOperator2D(numFilters: 512, | ||
kernelSize: [3, 3], | ||
padMode: PaddingMode.Same, | ||
channelPosition: TensorChannelOrder.Last, | ||
inputShape: out11.first!.shape) | ||
let (out12, _, _) = g.operation(inputs: out11, op: convOp12) | ||
|
||
let poo5 = MaxPool2DOperator(kernelSize: [2, 2], | ||
channelPosition: TensorChannelOrder.Last, | ||
paddingMode: PaddingMode.Valid) | ||
let (out_block_5, _, _) = g.operation(inputs: out12, op: poo5) | ||
|
||
// block 6 | ||
let fc13 = FullyconnectedOperator(inputDim: 25088, numUnits: 4096) | ||
let (out13, _, _) = g.operation(inputs: out_block_5, op: fc13) | ||
|
||
let fc14 = FullyconnectedOperator(inputDim: 4096, numUnits: 4096) | ||
let (out14, _, _) = g.operation(inputs: out13, op: fc14) | ||
|
||
let fc15 = FullyconnectedOperator(inputDim: 4096, numUnits: 4096) | ||
let (out15, _, _) = g.operation(inputs: out14, op: fc15) | ||
|
||
return g | ||
} | ||
|
||
|
||
|
||
class Example_VGG16: XCTestCase { | ||
// Test vgg16 network forward | ||
// Suggestion: run this function on macOS or real iOS devices supporting GPU. It goona be very slow on CPU mode. | ||
func testVGG16Forawad() { | ||
SerranoLogging.release = true | ||
|
||
let _ = SerranoEngine.configuredEngine.configureEngine(computationMode: .GPU) | ||
let vgg16 = configureVGG16() | ||
vgg16.allocateAllTensors() | ||
vgg16.forwardPrepare() | ||
|
||
let start = CFAbsoluteTimeGetCurrent() | ||
// vgg16.forward(mode: .CPU) | ||
vgg16.forward(mode: .GPU) | ||
print("Forward Execution Time : \((CFAbsoluteTimeGetCurrent() - start) * 100) ms") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// | ||
// YOLO.swift | ||
// serrano | ||
// | ||
// Created by ZHONGHAO LIU on 10/25/17. | ||
// Copyright © 2017 ZHONGHAO LIU. All rights reserved. | ||
// | ||
|
||
import XCTest | ||
|
||
class YOLO: XCTestCase { | ||
|
||
override func setUp() { | ||
super.setUp() | ||
// Put setup code here. This method is called before the invocation of each test method in the class. | ||
} | ||
|
||
override func tearDown() { | ||
// Put teardown code here. This method is called after the invocation of each test method in the class. | ||
super.tearDown() | ||
} | ||
|
||
func testExample() { | ||
// This is an example of a functional test case. | ||
// Use XCTAssert and related functions to verify your tests produce the correct results. | ||
} | ||
|
||
func testPerformanceExample() { | ||
// This is an example of a performance test case. | ||
self.measure { | ||
// Put the code you want to measure the time of here. | ||
} | ||
} | ||
|
||
//TODO: | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2017 Zhonghao LIU | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
Oops, something went wrong.