コード例 #1
0
import pyOcean_cpu as ocean

a = ocean.zeros([0, 5], ocean.float)
b = ocean.ones([5], ocean.float)
c = a * b
print(c)
コード例 #2
0
import pyOcean_cpu as ocean

a = ocean.zeros([5, 0], ocean.float)
b = ocean.ones([0, 5], ocean.float)
c = a * b
print(c)
コード例 #3
0
def exceptionMsg():
    print("Expected error: %s" % str(sys.exc_info()[1]))


def failTest(command):
    try:
        eval(command)
    except:
        print("\n>>> %s" % command)
        exceptionMsg()


a = ocean.asTensor([[1, 2], [2, 3, 4]], 0)
print(a)

a = ocean.asTensor([range(3, 7), [7, 8]], 0)
print(a)

a = ocean.asTensor([[[1], [2, 3], [4, 5, 6]], ocean.ones([3, 3])], 0)
print(a)

failTest("ocean.asTensor([1,[1,2]])")
failTest("ocean.asTensor([[1,2],1])")
failTest("ocean.asTensor([xrange(4),[[1,2],[3,4]]],0)")
failTest("ocean.asTensor([[[1,2],[3,4]],xrange(4)],0)")
failTest("ocean.asTensor([ocean.ones([3]),ocean.ones([3,4])],0)")
failTest("ocean.asTensor([ocean.ones([2]),ocean.ones([3])])")
failTest("ocean.asTensor([ocean.ones([2,2,2]),ocean.ones([2,3,2])])")
failTest("ocean.asTensor([ocean.ones([2,2,2]),ocean.ones([2,2,3])])")
コード例 #4
0
import pyOcean_cpu as ocean

a = ocean.ones([3,4])
print(a)

a = ocean.ones([3,4],ocean.int8)
print(a)

a = ocean.ones([3,4],ocean.cpu)
print(a)

a = ocean.ones([3,4],ocean.float,ocean.cpu)
print(a)


コード例 #5
0
import pyOcean_cpu as ocean

# This should run on a single thread
a = ocean.ones([10, 10], ocean.double)
print(ocean.sum(a, 0))

# Each thread should reduce the result for its outputs
a = ocean.ones([100, 50], ocean.double)
print(ocean.sum(a, 0))

# All threads should jointly reduce each output
a = ocean.ones([3, 10000], ocean.double)
print(ocean.sum(a, 1))