text
stringlengths
1
2.05k
me) default() broadcast() @staticmethod def less_equal_i8(): def default(): x = np.random.randint(-3, 3, (2, 2)).astype(np.int8) y = np.random.randint(-3, 3, (2, 2)).astype(np.int8) z = np.less_equal(x, y) x = Tensor(Dtype.I8, x.shape, x...
y.flatten(), FixedImpl.FP8x23)) z = Tensor(Dtype.I32, z.shape, z.flatten()) name = "less_equal_fp8x23_broadcast" make_test([x, y], z, "input_0.less_equal(@input_1)", name) default() broadcast() @staticmethod def less_equal_fp16x16(): def default(): ...
import numpy as np from nodegen.node
import RunAll from ..helpers
import make_test, to_fp, Tensor, Dtype, FixedImpl, Trait from typing
import Optional def linear( i: np.ndarray, w: np.ndarray, b: Optional[np.ndarray] = None, ) -> np.ndarray: return np.dot(i, w.T) + b
class Linear(RunAll): @staticmethod def linear_i32(): i = np.random.randint(-5, 9, (3)).astype(np.int32) w = np.random.randint(-5, 9, (2, 3)).astype(np.int32) b = np.random.randint(-5, 9, (2)).astype(np.int32) y = linear(i, w, b) i = Tensor(Dtype.I32, i.shape, i.flatten...
y = linear(i, w, b) i = Tensor(Dtype.FP8x23, i.shape, to_fp( i.flatten(), FixedImpl.FP8x23)) w = Tensor(Dtype.FP8x23, w.shape, to_fp( w.flatten(), FixedImpl.FP8x23)) b = Tensor(Dtype.FP8x23, b.shape, to_fp( b.flatten(), FixedImpl.FP8x23)) y = Tensor(D...
import numpy as np from nodegen.node import RunAll from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl class Log(RunAll): @staticmethod def log_fp8x23(): x = np.random.uniform(1, 127, (2, 2)).astype(np.float64) y = np.log(x) x = Tensor(Dtype.FP8x23, x.shape, to_fp( ...
import numpy as np from nodegen.node
import RunAll from ..helpers
import make_test, to_fp, Tensor, Dtype, FixedImpl, Trait def logsoftmax(x: np.ndarray, axis: int = -1) -> np.ndarray: x_max = np.max(x, axis=axis, keepdims=True) tmp = np.exp(x - x_max) s = np.sum(tmp, axis=axis, keepdims=True) return (x - x_max) - np.log(s)
class Logsoftmax(RunAll): def logsoftmax_fp8x23(): def axis_0(): x = np.random.uniform(-3, 3, (2, 2)).astype(np.float64) y = logsoftmax(x, 0) x = Tensor(Dtype.FP8x23, x.shape, to_fp( x.flatten(), FixedImpl.FP8x23)) y = Tensor(Dtype.FP8x23, y....
axis_0() axis_1()
import numpy as np from nodegen.node
import RunAll from ..helpers
import make_test, to_fp, Tensor, Dtype, FixedImpl
class Matmul(RunAll): @staticmethod def matmul_u32(): def matmul_1D(): a = np.random.randint(0, 255, (3)).astype(np.uint32) b = np.random.randint(0, 255, (3)).astype(np.uint32) y = np.matmul(a, b).reshape((1)) a = Tensor(Dtype.U32, a.shape, a.flatten()) ...
matmul_2x1() matmul_1x2() @staticmethod def matmul_i32(): def matmul_1D(): a = np.random.randint(-127, 127, (3)).astype(np.int32) b = np.random.randint(-127, 127, (3)).astype(np.int32) y = np.matmul(a, b).reshape((1)) a = Tensor(Dtype.I32, a.shap...
matmul_1D() matmul_2x2() matmul_2x1() matmul_1x2() @staticmethod def matmul_i8(): def matmul_1D(): a = np.random.randint(-4, 5, (3)).astype(np.int8) b = np.random.randint(-4, 5, (3)).astype(np.int8) y = np.matmul(a, b).reshape((1)) ...
matmul_2x2() matmul_2x1() matmul_1x2() @staticmethod def matmul_fp8x23(): def matmul_1D(): a = np.random.randint(-3, 4, (3)).astype(np.int64) b = np.random.randint(-3, 4, (3)).astype(np.int64) y = np.matmul(a, b).reshape((1)) a = Tensor(D...
np.int64) b = np.random.randint(-3, 4, (2, 1)).astype(np.int64) y = np.matmul(a, b) a = Tensor(Dtype.FP8x23, a.shape, to_fp( a.flatten(), FixedImpl.FP8x23)) b = Tensor(Dtype.FP8x23, b.shape, to_fp( b.flatten(), FixedImpl.FP8x23)) ...
-3, 4, (1, 2)).astype(np.int64) y = np.matmul(a, b) a = Tensor(Dtype.FP16x16, a.shape, to_fp( a.flatten(), FixedImpl.FP16x16)) b = Tensor(Dtype.FP16x16, b.shape, to_fp( b.flatten(), FixedImpl.FP16x16)) y = Tensor(Dtype.FP16x16, y.shape, to...
import numpy as np from nodegen.node
import RunAll from ..helpers
import make_test, to_fp, Tensor, Dtype, FixedImpl, Trait
class Max(RunAll): @staticmethod def max_u32_two_tensors(): 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) z = np.maximum(x, y) x = Tensor(Dtype.U32, x.shape, x.flatten()) ...
st_two_tensors" make_test([x, y], z, "TensorTrait::max(array![input_0, input_1].span())", name) default() broadcast() @staticmethod def max_i8_two_tensors(): def default(): x = np.random.randint(0, 6, (3, 3, 3)).astype(np.int8) y = np.random.randint(...
(1, 2)).astype(np.float64) z = np.maximum(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.FP8x23, z.shape, to_fp( ...
om.randint(0, 6, (3, 3, 3)).astype(np.uint32) y = np.random.randint(0, 6, (3, 3, 3)).astype(np.uint32) z = np.random.randint(0, 6, (3, 3, 3)).astype(np.uint32) m = np.maximum(np.maximum(x, y), z) x = Tensor(Dtype.U32, x.shape, x.flatten()) y = Tensor(Dtype.U3...
om.randint(0, 6, (2, 2)).astype(np.int32) y = np.random.randint(0, 6, (1, 2)).astype(np.int32) z = np.random.randint(0, 6, (1, 1)).astype(np.int32) m = np.maximum(np.maximum(x, y), z) x = Tensor(Dtype.I32, x.shape, x.flatten()) y = Tensor(Dtype.I32, y.shape, ...
p8x23_three_tensors(): 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.random.randint(-3, 3, (3, 3, 3)).astype(np.float64) m = np.maximum(np.maximum(x, y), z) ...
m = np.maximum(np.maximum(x, y), z) 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.FP16x16, z.shape, to_fp( z.fla...
import numpy as np from nodegen.node
import RunAll from ..helpers
import make_test, to_fp, Tensor, Dtype, FixedImpl, Trait
class Min(RunAll): @staticmethod def min_u32_two_tensors(): 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) z = np.minimum(x, y) x = Tensor(Dtype.U32, x.shape, x.flatten()) ...
st_two_tensors" make_test([x, y], z, "TensorTrait::min(array![input_0, input_1].span())", name) default() broadcast() @staticmethod def min_i8_two_tensors(): def default(): x = np.random.randint(0, 6, (3, 3, 3)).astype(np.int8) y = np.random.randint(...
(1, 2)).astype(np.float64) z = np.minimum(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.FP8x23, z.shape, to_fp( ...
om.randint(0, 6, (3, 3, 3)).astype(np.uint32) y = np.random.randint(0, 6, (3, 3, 3)).astype(np.uint32) z = np.random.randint(0, 6, (3, 3, 3)).astype(np.uint32) m = np.minimum(np.minimum(x, y), z) x = Tensor(Dtype.U32, x.shape, x.flatten()) y = Tensor(Dtype.U3...
om.randint(0, 6, (2, 2)).astype(np.int32) y = np.random.randint(0, 6, (1, 2)).astype(np.int32) z = np.random.randint(0, 6, (1, 1)).astype(np.int32) m = np.minimum(np.minimum(x, y), z) x = Tensor(Dtype.I32, x.shape, x.flatten()) y = Tensor(Dtype.I32, y.shape, ...
p8x23_three_tensors(): 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.random.randint(-3, 3, (3, 3, 3)).astype(np.float64) m = np.minimum(np.minimum(x, y), z) ...
m = np.minimum(np.minimum(x, y), z) 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.FP16x16, z.shape, to_fp( z.fla...
import numpy as np from nodegen.node
import RunAll from ..helpers
import make_test, to_fp, Tensor, Dtype, FixedImpl
class Mul(RunAll): @staticmethod def mul_u32(): def default(): x = np.random.randint(3, 6, (3, 3, 3)).astype(np.uint32) y = np.random.randint(0, 3, (3, 3, 3)).astype(np.uint32) z = x * y x = Tensor(Dtype.U32, x.shape, x.flatten()) y = Tensor(D...
dom.randint(-3, 3, (3, 3, 3)).astype(np.int8) y = np.random.randint(-3, 3, (3, 3, 3)).astype(np.int8) z = x * y x = Tensor(Dtype.I8, x.shape, x.flatten()) y = Tensor(Dtype.I8, y.shape, y.flatten()) z = Tensor(Dtype.I8, z.shape, z.flatten()) name ...
make_test([x, y], z, "input_0 * input_1", name) default() broadcast() @staticmethod def mul_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 = x * y ...
import numpy as np from nodegen.node import RunAll from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl class Neg(RunAll): @staticmethod def neg_i32(): x = np.random.randint(-127, 127, (2, 2)).astype(np.int32) y = np.negative(x) x = Tensor(Dtype.I32, x.shape, x.flatten()) ...
import numpy as np from nodegen.node
import RunAll from ..helpers
import make_test, to_fp, Tensor, Dtype, FixedImpl
class Nonzero(RunAll): @staticmethod def nonzero_u32(): def nonzero_2D(): x = np.random.randint(0, 255, (2, 4)).astype(np.uint32) y = np.array(np.nonzero(x), dtype=np.int64) x = Tensor(Dtype.U32, x.shape, x.flatten()) y = Tensor(Dtype.U32, y.shape, y.flat...
make_test( [x], y, "input_0.nonzero()", name) def nonzero_3D(): x = np.random.randint(-127, 127, (20, 10, 5)).astype(np.int8) y = np.array(np.nonzero(x), dtype=np.int64) x = Tensor(Dtype.I8, x.shape, x.flatten()) y = Tensor(Dtype.U32, y.shape, y....
o_fp(np.random.randint(-127, 127, (20, 10, 5) ).astype(np.int64), FixedImpl.FP16x16) y = np.array(np.nonzero(x), dtype=np.int64) x = Tensor(Dtype.FP16x16, x.shape, x.flatten()) y = Tensor(Dtype.U32, y.shape, y.flatten()) name = "n...
import numpy as np from nodegen.node import RunAll from ..helpers import make_node, make_test, Tensor, Dtype class Not(RunAll): @staticmethod def not_bool(): x = np.random.uniform(True, False, (1, 1)).astype(bool) y = ~(x) x = Tensor(Dtype.Bool, x.shape, x.flatten()) y = Tensor...
import numpy as np from nodegen.node
import RunAll from ..helpers
import make_test, to_fp, Tensor, Dtype, FixedImpl
class Or(RunAll): @staticmethod def or_u32(): 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) z = np.logical_or(x, y) x = Tensor(Dtype.U32, x.shape, x.flatten()) ...
): 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_or(x, y) x = Tensor(Dtype.I8, x.shape, x.flatten()) y = Tensor(Dtype.I8, y.shape, y.flatten()) ...
t" make_test([x, y], z, "input_0.or(@input_1)", name) default() broadcast() @staticmethod def or_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) ...
import numpy as np from nodegen.node
import RunAll from ..helpers
import make_test, to_fp, Tensor, Dtype, FixedImpl
class Pow(RunAll): @staticmethod def pow_fp8x23(): def default(): x = np.array([1, 2, 3]).astype(np.float64) y = np.array([1, 2, 3]).astype(np.float64) z = np.array(pow(x, y), dtype=np.float64) x = Tensor(Dtype.FP8x23, x.shape, to_fp( x.fl...
4) z = np.array(pow(x, y), dtype=np.float64) 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.FP16x16, z.shape, to_fp( ...
import numpy as np from nodegen.node
import RunAll from ..helpers
import make_test, to_fp, Tensor, Dtype, FixedImpl, Trait def random_uniform_like(x: np.ndarray, high: int=1,low: int=0,seed: int=25) ->np.ndarray: dtype = np.float64 if seed is None or np.isnan(seed): state = np.random.RandomState() else: state = np.random.RandomState(seed=int(seed)) ...
class Random_uniform_like(RunAll): @staticmethod def fp8x23(): x = np.random.uniform(1, 10, (1, 2, 2, 4)).astype(np.float64) y = random_uniform_like(x) args = [10, 1] args_str = get_data_statement(to_fp(np.array(args).flatten(), FixedImpl.FP8x23), Dtype.FP8x23) x = Tens...
import numpy as np from nodegen.node
import RunAll from ..helpers
import make_test, to_fp, Tensor, Dtype, FixedImpl, Trait, get_data_statement
class Range(RunAll): @staticmethod def fp8x23(): args = [1, 5, 0.3] args_str = get_data_statement(to_fp(np.array(args).flatten(), FixedImpl.FP8x23), Dtype.FP8x23) y = np.arange(*args) print(y) y = Tensor(Dtype.FP8x23, y.shape, to_fp(y.flatten(), FixedI...
rgs).flatten(), Dtype.U32) y = np.arange(*args) print(y) y = Tensor(Dtype.U32, y.shape, y.flatten()) name = "range_u32" make_test( [], y, f"TensorTrait::range({','.join(args_str)})", name, ...
import numpy as np from nodegen.node
import RunAll from ..helpers
import make_test, to_fp, Tensor, Dtype, FixedImpl
import numpy as np
class Reduce_l1(RunAll): @staticmethod def reduce_l1_fp8x23(): def reduce_l1_export_do_not_keepdims(): shape = [3, 2, 2] axes = np.array([2], dtype=np.int64) keepdims = False x = np.reshape(np.arange(1, np.prod(shape) + 1, dtype=np.float32), shape).astype(...
xis_0() @staticmethod def reduce_l1_fp16x16(): def reduce_l1_export_do_not_keepdims(): shape = [3, 2, 2] axes = np.array([2], dtype=np.int64) keepdims = False x = np.reshape(np.arange(1, np.prod(shape) + 1, dtype=np.float32), shape).astype(np.int64) ...
) @staticmethod def reduce_l1_i8(): def reduce_l1_export_do_not_keepdims(): shape = [3, 2, 2] axes = np.array([2], dtype=np.int8) keepdims = False x = np.reshape(np.arange(1, np.prod(shape) + 1, dtype=np.float32), shape).astype(np.int8) y = np...
l1_export_do_not_keepdims(): shape = [3, 2, 2] axes = np.array([2], dtype=np.int32) keepdims = False x = np.reshape(np.arange(1, np.prod(shape) + 1, dtype=np.float32), shape).astype(np.int32) y = np.sum(a=np.abs(x), axis=tuple(axes), keepdims=False).astype(np....
= [3, 2, 2] axes = np.array([2], dtype=np.uint32) keepdims = False x = np.reshape(np.arange(1, np.prod(shape) + 1, dtype=np.float32), shape).astype(np.uint32) y = np.sum(a=np.abs(x), axis=tuple(axes), keepdims=False).astype(np.uint32) x = Tensor(Dtype.U32, x....
import numpy as np from nodegen.node
import RunAll from ..helpers
import make_node, make_test, to_fp, Tensor, Dtype, FixedImpl
import numpy as np
class Reduce_l2(RunAll): @staticmethod def reduce_l2_fp8x23(): def reduce_l2_export_do_not_keepdims(): shape = [3, 2, 2] axes = np.array([2], dtype=np.int64) keepdims = False x = np.reshape(np.arange(1, np.prod(shape) + 1, dtype=np.float32), shape).astype(...
e) reduce_l2_export_do_not_keepdims() reduce_l2_export_keepdims() reduce_l2_axis_0() @staticmethod def reduce_l2_fp16x16(): def reduce_l2_export_do_not_keepdims(): shape = [3, 2, 2] axes = np.array([2], dtype=np.int64) keepdims = Fal...
ake_node([x], [y], name) make_test( [x], y, "input_0.reduce_l2(0, true)", name) reduce_l2_export_do_not_keepdims() reduce_l2_export_keepdims() reduce_l2_axis_0() @staticmethod def reduce_l2_complex64(): def reduce_l2_axis_0(): ...
import numpy as np from nodegen.node
import RunAll from ..helpers
import make_test, to_fp, Tensor, Dtype, FixedImpl
class Reduce_log_sum(RunAll): @staticmethod def reduce_log_sum_fp8x23(): def reduce_log_sum_export_do_not_keepdims(): shape = [3, 2, 2] axes = np.array([2], dtype=np.int64) keepdims = False x = np.reshape(np.arange(1, np.prod(shape) + 1, dtype=np.float32),...
e_log_sum(0, true)", name) reduce_log_sum_export_do_not_keepdims() reduce_log_sum_export_keepdims() reduce_log_sum_axis_0() @staticmethod def reduce_log_sum_fp16x16(): def reduce_log_sum_export_do_not_keepdims(): shape = [3, 2, 2] axes = np.arra...
o_fp( y.flatten(), FixedImpl.FP8x23)) name = "reduce_log_sum_fp16x16_export_negative_axes_keepdims" make_test( [x], y, "input_0.reduce_log_sum(0, true)", name) reduce_log_sum_export_do_not_keepdims() reduce_log_sum_export_keepdims() ...
import numpy as np from nodegen.node