Skip to content

Commit

Permalink
replace tests
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelDkhn committed Dec 1, 2023
1 parent 657106e commit 0504484
Show file tree
Hide file tree
Showing 42 changed files with 875 additions and 1,978 deletions.
146 changes: 11 additions & 135 deletions nodegen/node/and.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,153 +5,29 @@

class And(RunAll):
@staticmethod
def and_u32():
def and_bool():
def default():
x = np.random.randint(0, 6, (3, 3, 3)).astype(np.uint32)
y = np.random.randint(0, 6, (3, 3, 3)).astype(np.uint32)
x = (np.random.randn(3, 4) > 0).astype(bool)
y = (np.random.randn(3, 4) > 0).astype(bool)
z = np.logical_and(x, y)

x = Tensor(Dtype.U32, x.shape, x.flatten())
y = Tensor(Dtype.U32, y.shape, y.flatten())
x = Tensor(Dtype.BOOL, x.shape, x.flatten())
y = Tensor(Dtype.BOOL, y.shape, y.flatten())
z = Tensor(Dtype.BOOL, z.shape, z.flatten())

name = "and_u32"
name = "and_bool"
make_test([x, y], z, "input_0.and(@input_1)", name)

def broadcast():
x = np.random.randint(0, 6, (2, 2)).astype(np.uint32)
y = np.random.randint(0, 6, (1, 2)).astype(np.uint32)
x = (np.random.randn(3, 4, 5) > 0).astype(bool)
y = (np.random.randn(4, 5) > 0).astype(bool)
z = np.logical_and(x, y)

x = Tensor(Dtype.U32, x.shape, x.flatten())
y = Tensor(Dtype.U32, y.shape, y.flatten())
x = Tensor(Dtype.BOOL, x.shape, x.flatten())
y = Tensor(Dtype.BOOL, y.shape, y.flatten())
z = Tensor(Dtype.BOOL, z.shape, z.flatten())

name = "and_u32_broadcast"
make_test([x, y], z, "input_0.and(@input_1)", name)

default()
broadcast()

@staticmethod
def and_i32():
def default():
x = np.random.randint(-3, 3, (3, 3, 3)).astype(np.int32)
y = np.random.randint(-3, 3, (3, 3, 3)).astype(np.int32)
z = np.logical_and(x, y)

x = Tensor(Dtype.I32, x.shape, x.flatten())
y = Tensor(Dtype.I32, y.shape, y.flatten())
z = Tensor(Dtype.BOOL, z.shape, z.flatten())

name = "and_i32"
make_test([x, y], z, "input_0.and(@input_1)", name)

def broadcast():
x = np.random.randint(-3, 3, (2, 2)).astype(np.int32)
y = np.random.randint(-3, 3, (1, 2)).astype(np.int32)
z = np.logical_and(x, y)

x = Tensor(Dtype.I32, x.shape, x.flatten())
y = Tensor(Dtype.I32, y.shape, y.flatten())
z = Tensor(Dtype.BOOL, z.shape, z.flatten())

name = "and_i32_broadcast"
make_test([x, y], z, "input_0.and(@input_1)", name)

default()
broadcast()

@staticmethod
def and_i8():
def default():
x = np.random.randint(-3, 3, (3, 3, 3)).astype(np.int8)
y = np.random.randint(-3, 3, (3, 3, 3)).astype(np.int8)
z = np.logical_and(x, y)

x = Tensor(Dtype.I8, x.shape, x.flatten())
y = Tensor(Dtype.I8, y.shape, y.flatten())
z = Tensor(Dtype.BOOL, z.shape, z.flatten())

name = "and_i8"
make_test([x, y], z, "input_0.and(@input_1)", name)

def broadcast():
x = np.random.randint(-3, 3, (2, 2)).astype(np.int8)
y = np.random.randint(-3, 3, (1, 2)).astype(np.int8)
z = np.logical_and(x, y)

x = Tensor(Dtype.I8, x.shape, x.flatten())
y = Tensor(Dtype.I8, y.shape, y.flatten())
z = Tensor(Dtype.BOOL, z.shape, z.flatten())

name = "and_i8_broadcast"
make_test([x, y], z, "input_0.and(@input_1)", name)

default()
broadcast()

@staticmethod
def and_fp8x23():
def default():
x = np.random.randint(-3, 3, (3, 3, 3)).astype(np.float64)
y = np.random.randint(-3, 3, (3, 3, 3)).astype(np.float64)
z = np.logical_and(x, y)

x = Tensor(Dtype.FP8x23, x.shape, to_fp(
x.flatten(), FixedImpl.FP8x23))
y = Tensor(Dtype.FP8x23, y.shape, to_fp(
y.flatten(), FixedImpl.FP8x23))
z = Tensor(Dtype.BOOL, z.shape, z.flatten())

name = "and_fp8x23"
make_test([x, y], z, "input_0.and(@input_1)", name)

def broadcast():
x = np.random.randint(-3, 3, (2, 2)).astype(np.float64)
y = np.random.randint(-3, 3, (1, 2)).astype(np.float64)
z = np.logical_and(x, y)

x = Tensor(Dtype.FP8x23, x.shape, to_fp(
x.flatten(), FixedImpl.FP8x23))
y = Tensor(Dtype.FP8x23, y.shape, to_fp(
y.flatten(), FixedImpl.FP8x23))
z = Tensor(Dtype.BOOL, z.shape, z.flatten())

name = "and_fp8x23_broadcast"
make_test([x, y], z, "input_0.and(@input_1)", name)

default()
broadcast()

@staticmethod
def and_fp16x16():
def default():
x = np.random.randint(-3, 3, (3, 3, 3)).astype(np.float64)
y = np.random.randint(-3, 3, (3, 3, 3)).astype(np.float64)
z = np.logical_and(x, y)

x = Tensor(Dtype.FP16x16, x.shape, to_fp(
x.flatten(), FixedImpl.FP16x16))
y = Tensor(Dtype.FP16x16, y.shape, to_fp(
y.flatten(), FixedImpl.FP16x16))
z = Tensor(Dtype.BOOL, z.shape, z.flatten())

name = "and_fp16x16"
make_test([x, y], z, "input_0.and(@input_1)", name)

def broadcast():
x = np.random.randint(-3, 3, (2, 2)).astype(np.float64)
y = np.random.randint(-3, 3, (1, 2)).astype(np.float64)
z = np.logical_and(x, y)

x = Tensor(Dtype.FP16x16, x.shape, to_fp(
x.flatten(), FixedImpl.FP16x16))
y = Tensor(Dtype.FP16x16, y.shape, to_fp(
y.flatten(), FixedImpl.FP16x16))
z = Tensor(Dtype.BOOL, z.shape, z.flatten())

name = "and_fp16x16_broadcast"
name = "and_bool_broadcast"
make_test([x, y], z, "input_0.and(@input_1)", name)

default()
Expand Down
Loading

0 comments on commit 0504484

Please sign in to comment.