Skip to content

Commit

Permalink
Fix unit tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
liuliu committed Mar 14, 2024
1 parent a298bd8 commit 2180bc2
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
2 changes: 1 addition & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ git_repository(
name = "ccv",
commit = "b51f1612976340f5b57d249360874a6cdfe61e11",
remote = "https://github.com/liuliu/ccv.git",
shallow_since = "1710435067 -0400",
shallow_since = "1710435687 -0400",
)

load("@ccv//config:ccv.bzl", "ccv_deps", "ccv_setting")
Expand Down
2 changes: 1 addition & 1 deletion deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def s4nnc_deps():
name = "ccv",
remote = "https://github.com/liuliu/ccv.git",
commit = "b51f1612976340f5b57d249360874a6cdfe61e11",
shallow_since = "1710435067 -0400",
shallow_since = "1710435687 -0400",
)

_maybe(
Expand Down
25 changes: 20 additions & 5 deletions test/store.swift
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,12 @@ final class StoreTests: XCTestCase {

func testWriteTensorAndReadBackWithFPZIP() throws {
let graph = DynamicGraph()
var tensor: Tensor<Float32> = Tensor(.CPU, .C(2))
var tensor: Tensor<Float32> = Tensor(.CPU, .C(128))
tensor[0] = 2.2
tensor[1] = 1.1
for i in 2..<128 {
tensor[i] = 3.3
}
var readout: AnyTensor? = nil
var readoutCodec: DynamicGraph.Store.Codec? = nil
graph.openStore("test/tmp.db") { store in
Expand All @@ -205,9 +208,12 @@ final class StoreTests: XCTestCase {
#if !((os(macOS) || (os(iOS) && targetEnvironment(macCatalyst))) && (arch(i386) || arch(x86_64)))
func testWriteTensorAndReadBackWithFPZIPFloat16() throws {
let graph = DynamicGraph()
var tensor: Tensor<Float16> = Tensor(.CPU, .C(2))
var tensor: Tensor<Float16> = Tensor(.CPU, .C(64))
tensor[0] = 2.2
tensor[1] = 1.1
for i in 2..<64 {
tensor[i] = 3.3
}
var readout: AnyTensor? = nil
var readoutCodec: DynamicGraph.Store.Codec? = nil
graph.openStore("test/tmp.db") { store in
Expand Down Expand Up @@ -250,9 +256,12 @@ final class StoreTests: XCTestCase {

func testWriteTensorAndReadBackWithFPZIPDouble() throws {
let graph = DynamicGraph()
var tensor: Tensor<Double> = Tensor(.CPU, .C(2))
var tensor: Tensor<Double> = Tensor(.CPU, .C(32))
tensor[0] = 2.2
tensor[1] = 1.1
for i in 2..<32 {
tensor[i] = 3.3
}
var readout: AnyTensor? = nil
var readoutCodec: DynamicGraph.Store.Codec? = nil
graph.openStore("test/tmp.db") { store in
Expand Down Expand Up @@ -541,12 +550,18 @@ final class StoreTests: XCTestCase {

func testWriteTensorAndReadBackCodec() throws {
let graph = DynamicGraph()
var tensor: Tensor<Float32> = Tensor(.CPU, .C(2))
var tensor: Tensor<Float32> = Tensor(.CPU, .C(128))
tensor[0] = 2.2
tensor[1] = 1.1
var tensor16: Tensor<Float16> = Tensor(.CPU, .C(2))
for i in 2..<128 {
tensor[i] = 3.3
}
var tensor16: Tensor<Float16> = Tensor(.CPU, .C(128))
tensor16[0] = 2.2
tensor16[1] = 1.1
for i in 2..<128 {
tensor16[i] = 3.3
}
var intTensor: Tensor<Int32> = Tensor(.CPU, .C(2048))
for i in 0..<2048 {
intTensor[i] = Int32(i)
Expand Down

0 comments on commit 2180bc2

Please sign in to comment.