text
stringlengths
1
2.05k
output = y, func_sig = "input_0.scatter(updates:input_1, indices:input_2, axis:Option::Some(1), reduction:Option::Some('none'))", name= name) def axis1_max(): x1 = np.zeros((3, 3)).astype(np.int8) x2 = np.arange(1, 10).re...
ter(updates:input_1, indices:input_2, axis:Option::Some(0), reduction:Option::Some('none'))", name= name) def axis1(): x1 = np.zeros((3, 3)).astype(np.int32) x2 = np.arange(1, 10).reshape((3, 3)).astype(np.int32) x3 = np.a...
scatter_3D() @staticmethod def scatter_u32(): def scatter_3D(): def default(): x1 = np.zeros((3, 3)).astype(np.uint32) x2 = np.arange(1, 10).reshape((3, 3)).astype(np.uint32) x3 = np.array( [[0,1,2], ...
x2 = np.arange(1, 10).reshape((3, 3)).astype(np.uint32) x3 = np.array( [[0,1,2], [2,0,1], [1,0,1]], ) y = scatter_elements(x1, x3, x2, 0, 'add') x1 = Tensor(Dtype.U32, x1.sha...
import numpy as np from nodegen.node
import RunAll from ..helpers
import make_test, to_fp, Tensor, Dtype, FixedImpl def scatter_nd_impl(data, indices, updates, reduction="none"): assert indices.shape[-1] <= len(data.shape) assert updates.shape == indices.shape[:-1] + data.shape[indices.shape[-1] :] output = np.copy(data) for i in np.ndindex(indices.shape...
class Scatter_nd(RunAll): @staticmethod def scatter_nd_fp16x16(): def scatter_nd_3D(): def default(): x1 = data.astype(np.int64) x2 = indices.astype(np.int64) x3 = updates.astype(np.uint32) y = scatter_nd_impl(x1, x2, x3, reduc...
eduction='mul') x1 = Tensor(Dtype.FP16x16, x1.shape, to_fp(x1.flatten(), FixedImpl.FP16x16)) x2 = Tensor(Dtype.U32, x2.shape, x2.flatten()) x3 = Tensor(Dtype.FP16x16, x3.shape, to_fp(x3.flatten(), FixedImpl.FP16x16)) y = Tensor(Dtype.FP16x16, y.shape, to...
to_fp( y.flatten(), FixedImpl.FP16x16)) name = "scatter_nd_fp16x16_3d_min" make_test( inputs = [x1, x3, x2], output = y, func_sig = "input_0.scatter_nd(updates:input_1, indices:input_2, reduction:Option::Some('min'))", name= name...
test( inputs = [x1, x3, x2], output = y, func_sig = "input_0.scatter_nd(updates:input_1, indices:input_2, reduction:Option::Some('add'))", name= name) def mul(): x1 = data.astype(np.int64) x2 = indices.astype(np.int64)...
x3 = updates.astype(np.uint32) y = scatter_nd_impl(x1, x2, x3, reduction='min') x1 = Tensor(Dtype.FP8x23, x1.shape, to_fp(x1.flatten(), FixedImpl.FP8x23)) x2 = Tensor(Dtype.U32, x2.shape, x2.flatten()) x3 = Tensor(Dtype.FP8x23, x3.shape, to_fp(x3.flatten...
, x3, reduction='add') x1 = Tensor(Dtype.U32, x1.shape, x1.flatten()) x2 = Tensor(Dtype.U32, x2.shape, x2.flatten()) x3 = Tensor(Dtype.U32, x3.shape, x3.flatten()) y = Tensor(Dtype.U32, y.shape, y.flatten()) name = "scatter_nd_u32_ad...
, x3, x2], output = y, func_sig = "input_0.scatter_nd(updates:input_1, indices:input_2, reduction:Option::Some('max'))", name= name) def min(): x1 = np.arange(0,12).reshape((4,3)).astype(np.int32) x2 = np.array([[0],[1]]).astype(np.uint3...
import numpy as np from nodegen.node
import RunAll from ..helpers
import make_test, to_fp, Tensor, Dtype, FixedImpl, Trait scalar = lambda x: Tensor(Dtype.I32, (), np.array([x]).astype(np.int32).flatten())
class Sequence_at(RunAll): @staticmethod def sequence_at_u32(): def positive_position(): sequence = [] shape = np.random.randint(1, 4, 2) for _ in range(5): values = np.random.randint(0, 6, shape).astype(np.uint32) tensor = Tensor(Dty...
es.shape, values.flatten()) sequence.append(tensor) position = scalar(-2) name = "sequence_at_i32_negative" make_test([sequence, position], sequence[-2], "SequenceTrait::sequence_at(input_0, input_1)", name, Trait.SEQUENCE) positive_position() nega...
ence[2], "SequenceTrait::sequence_at(input_0, input_1)", name, Trait.SEQUENCE) def negative_position(): sequence = [] shape = np.random.randint(1, 4, 2) for _ in range(5): values = np.random.randint(-6, 6, shape).astype(np.float64) tensor = T...
import numpy as np from nodegen.node
import RunAll from ..helpers
import make_test, to_fp, Tensor, Dtype, FixedImpl, Trait
class Sequence_construct(RunAll): @staticmethod def sequence_construct_u32(): sequence = [] tensor_cnt = np.random.randint(1, 10) shape = np.random.randint(1, 4, 2) for _ in range(tensor_cnt): values = np.random.randint(0, 6, shape).astype(np.uint32) ten...
quence_construct_fp8x23" make_test([sequence], sequence, "SequenceTrait::sequence_construct(input_0)", name, Trait.SEQUENCE) @staticmethod def sequence_construct_fp16x16(): sequence = [] tensor_cnt = np.random.randint(1, 10) shape = np.random.randint(1, 4, 2) for _ in ...
import numpy as np from nodegen.node
import RunAll from ..helpers
import make_test, Dtype, Tensor, Trait
class Sequence_empty(RunAll): @staticmethod def sequence_empty_u32(): def default(): shape=(0,) x = np.zeros(shape, dtype=np.uint32) t = Tensor(Dtype.U32, shape, x.flatten()) make_test( inputs=[], output=[t], ...
make_test( inputs=[], output=[t], func_sig="SequenceTrait::sequence_empty()", name="sequence_empty_fp16x16", trait=Trait.SEQUENCE ) default()
import numpy as np from nodegen.node
import RunAll from ..helpers
import make_test, to_fp, Tensor, Dtype, FixedImpl, Trait scalar = lambda x: Tensor(Dtype.I32, (), np.array([x]).astype(np.int32).flatten())
class Sequence_erase(RunAll): @staticmethod def sequence_erase_u32(): def positive_position(): sequence = [] shape = np.random.randint(1, 4, 2) for _ in range(5): values = np.random.randint(0, 6, shape).astype(np.uint32) tensor = Tens...
y_position() @staticmethod def sequence_erase_i32(): def positive_position(): sequence = [] shape = np.random.randint(1, 4, 2) for _ in range(5): values = np.random.randint(-6, 6, shape).astype(np.int32) tensor = Tensor(Dtype.I32, va...
sequence_erase_i8(): def positive_position(): sequence = [] shape = np.random.randint(1, 4, 2) for _ in range(5): values = np.random.randint(-6, 6, shape).astype(np.int8) tensor = Tensor(Dtype.I8, values.shape, values.flatten()) ...
ition(): sequence = [] shape = np.random.randint(1, 4, 2) for _ in range(5): values = np.random.randint(-6, 6, shape).astype(np.float64) tensor = Tensor(Dtype.FP8x23, values.shape, to_fp(values.flatten(), FixedImpl.FP8x23)) sequence.a...
thod def sequence_erase_fp16x16(): def positive_position(): sequence = [] shape = np.random.randint(1, 4, 2) for _ in range(5): values = np.random.randint(-6, 6, shape).astype(np.float64) tensor = Tensor(Dtype.FP16x16, values.shape, to_fp(...
n() negative_position() empty_position()
import numpy as np from nodegen.node
import RunAll from ..helpers
import make_test, to_fp, Tensor, Dtype, FixedImpl, Trait scalar = lambda x: Tensor(Dtype.I32, (), np.array([x]).astype(np.int32).flatten())
class Sequence_insert(RunAll): @staticmethod def sequence_insert_u32(): def default(): sequence = [] tensor_cnt = 3 shape = np.random.randint(1, 4, 2) for _ in range(tensor_cnt): val = np.random.randint(0, 6, shape).astype(np.uint32) ...
np.random.randint(0, 6, shape).astype(np.int8) t = Tensor(Dtype.I8, val.shape, val.flatten()) sequence.append(t) val = np.random.randint(0, 6, shape).astype(np.int8) tensor = Tensor(Dtype.I8, val.shape, val.flatten()) position = np.random.randint(-2...
sequence.append(t) val = np.random.randint(0, 6, shape).astype(np.float64) tensor = Tensor(Dtype.FP16x16, val.shape, to_fp( val.flatten(), FixedImpl.FP16x16)) position = np.random.randint(-2, 2) expected_sequence = sequence.copy() expected_s...
import numpy as np from nodegen.node
import RunAll from ..helpers
import make_test, to_fp, Tensor, Dtype, FixedImpl, Trait scalar = lambda x: Tensor(Dtype.U32, (), np.array([x]).astype(np.uint32).flatten())
class Sequence_length(RunAll): @staticmethod def sequence_length_u32(): def default(): sequence = [] tensor_cnt = np.random.randint(1, 10) shape = np.random.randint(1, 4, 2) for _ in range(tensor_cnt): values = np.random.randint(0, 6, shap...
tensor = Tensor(Dtype.I32, values.shape, values.flatten()) sequence.append(tensor) name = "sequence_length_i32_broadcast" make_test([sequence], scalar(len(sequence)), "input_0.sequence_length()", name, Trait.SEQUENCE) default() broadcast() @staticmethod ...
me, Trait.SEQUENCE) def broadcast(): sequence = [] tensor_cnt = np.random.randint(1, 10) for _ in range(tensor_cnt): shape = np.random.randint(1, 4, 2) values = np.random.randint(-6, 6, shape).astype(np.float64) tensor = Tenso...
import numpy as np from nodegen.node
import RunAll from ..helpers
import make_test, to_fp, Tensor, Dtype, FixedImpl def shrink(input_array: np.ndarray, bias: float, lambd: float) -> np.ndarray: output_array = np.where(input_array > lambd, input_array - bias, np.where(input_array < -lambd, input_array + bias, 0)) return output_array
class Shrink(RunAll): @staticmethod def shrink_fp8x23(): def shrink_hard(): x = np.random.uniform(-3, 3, (3, 3, 3)).astype(np.float64) bias = np.float64(0) lambd = np.float64(1) y = shrink(x, bias, lambd) x = Tensor(Dtype.FP8x23, x.shape, to...
as = np.float64(1) lambd = np.float64(1) y = shrink(x, bias, lambd) x = Tensor(Dtype.FP16x16, x.shape, to_fp( x.flatten(), FixedImpl.FP16x16)) y = Tensor(Dtype.FP16x16, y.shape, to_fp( y.flatten(), FixedImpl.FP16x16)) name = "...
import numpy as np from nodegen.node import RunAll from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl, Trait import tensorflow as tf class Sigmoid(RunAll): @staticmethod def fp8x23(): x = np.random.uniform(-3, 3, (2, 2)).astype(np.float32) y = tf.keras.activations.sigmoid(x).num...
import numpy as np from nodegen.node
import RunAll from ..helpers
import make_test, to_fp, Tensor, Dtype, FixedImpl
class Sign(RunAll): @staticmethod def sign_i8(): def sign(): x = np.array(range(-5, 6)).astype(np.int8) y = np.array([-1, -1, -1, -1, -1, 0, 1, 1, 1, 1, 1]).astype(np.int8) x = Tensor(Dtype.I8, x.shape, x.flatten()) y = Tensor(Dtype.I8, ...
1, 1, 1, 1, 1]).astype(np.int64), FixedImpl.FP8x23) x = Tensor(Dtype.FP8x23, x.shape, x.flatten()) y = Tensor(Dtype.FP8x23, y.shape, y.flatten()) name = "sign_fP8x23" make_test( [x], y, "input_0.sign()", name) sign()
import numpy as np from nodegen.node import RunAll from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl class Sin(RunAll): @staticmethod def sin_fp8x23(): x = np.random.uniform(-3, 7, (2, 2)).astype(np.float64) y = np.sin(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 class Sinh(RunAll): @staticmethod def sinh_fp8x23(): x = np.random.uniform(-3, 3, (2, 2)).astype(np.float64) y = np.sinh(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
class Slice(RunAll): @staticmethod def slice_u32(): def slice_2D(): x = np.random.randint(0, 255, (2, 4)).astype(np.uint32) y = x[0:2, 2:4] x = Tensor(Dtype.U32, x.shape, x.flatten()) y = Tensor(Dtype.U32, y.shape, y.flatten()) name = "slice_...
def slice_2D(): x = np.random.randint(-127, 127, (2, 4)).astype(np.int8) y = x[0:2, 2:4] x = Tensor(Dtype.I8, x.shape, x.flatten()) y = Tensor(Dtype.I8, y.shape, y.flatten()) name = "slice_i8_2d" make_test( [x], y, "input_0.slice(...
, 3].span()))", name) slice_2D() slice_3D() @staticmethod def slice_fp16x16(): def slice_2D(): x = to_fp(np.random.randint(-127, 127, (2, 4) ).astype(np.int64), FixedImpl.FP16x16) y = x[0:2, 2:4] x = Tensor(Dt...
import numpy as np from nodegen.node
import RunAll from ..helpers
import make_test, to_fp, Tensor, Dtype, FixedImpl, Trait def softmax(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 tmp / s
class Softmax(RunAll): @staticmethod def axis_0(): x = np.abs(np.random.randn(3, 4, 5).astype(np.float32)) y = softmax(x, axis=0) x = Tensor(Dtype.FP16x16, x.shape, to_fp( x.flatten(), FixedImpl.FP16x16)) y = Tensor(Dtype.FP16x16, y.shape, to_fp( ...
import numpy as np from nodegen.node import RunAll from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl, Trait def softmax_zero(x: np.ndarray, axis: int = -1) -> np.ndarray: x_max = np.max(x, axis=axis, keepdims=True) tmp = np.exp(x - x_max) tmp = np.where(x == 0.0, 0.0, tmp) s = np.sum(t...
import numpy as np from nodegen.node import RunAll from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl, Trait def softplus(x: np.ndarray) -> np.ndarray: return np.log(np.exp(x) + 1) class Softplus(RunAll): @staticmethod def softplus_fp(): def fp8x23(): x = np.random.uni...
import numpy as np from nodegen.node import RunAll from ..helpers import make_test, to_fp, Tensor, Dtype, FixedImpl, Trait def softsign(x: np.ndarray) -> np.ndarray: return x / (1 + np.abs(x)) class Softsign(RunAll): @staticmethod def softsign_fp(): def fp8x23(): x = np.random.unifo...
import numpy as np from nodegen.node
import RunAll from ..helpers
import make_test, to_fp, Tensor, Dtype, FixedImpl, Trait def space_to_depth(data: np.ndarray, blocksize: int = 2) -> np.ndarray: if len(data.shape) != 4: raise RuntimeError(f"Unexpected shape {data.shape!r}.") b, C, H, W = data.shape tmpshape = ( b, C, H blocksize, ...
class Space_to_depth(RunAll): @staticmethod def fp8x23(): x = np.random.uniform(-3, 3, (1, 2, 2, 4)).astype(np.float64) y = space_to_depth(x) x = Tensor(Dtype.FP8x23, x.shape, to_fp( x.flatten(), FixedImpl.FP8x23)) y = Tensor(Dtype.FP8x23, y.shape, to_fp( ...
e_to_depth_u32" make_test([x], y, "NNTrait::space_to_depth(@input_0, 2)", name, Trait.NN)
import numpy as np from nodegen.node
import RunAll from ..helpers
import make_test, to_fp, Tensor, Dtype, FixedImpl
class Split(RunAll): @staticmethod def split_u32(): def split_1D(): x = np.random.randint(0, 255, 6).astype(np.uint32) y = [ np.array(x[0:2]).astype(np.uint32), np.array(x[2:4]).astype(np.uint32), np.array(x[4:6]).astype(np.uint32)...
] _y = [ Tensor(Dtype.U32, y[0].shape, y[0].flatten()), Tensor(Dtype.U32, y[1].shape, y[1].flatten()), ] name = "split_u32_2d_variable_parts" make_test( [_x], _y, "input_0.split(1, Option::None(()), Option::Some(TensorTrait:...
None(()))", name) def split_2d_uneven(): x = np.random.randint(0, 255, (2, 8)).astype(np.uint32) y = [ np.array(x[0:2, 0:3]).astype(np.uint32), np.array(x[0:2, 3:6]).astype(np.uint32), np.array(x[0:2, 6:8]).astype(np.uint32)...
name = "split_fp16x16_1d_variable_parts" make_test( [_x], _y, "input_0.split(0, Option::None(()), Option::Some(TensorTrait::<u32>::new(shape: array![2].span(), data: array![2, 4].span(),)))", name) def split_2D(): x = to_fp(np.random.randint(-127, 127, (2, 6) ...
Tensor(Dtype.FP16x16, y[2].shape, y[2].flatten()), ] name = "split_fp16x16_zero_size" make_test( [_x], _y, "input_0.split(0, Option::None(()), Option::Some(TensorTrait::<u32>::new(shape: array![3].span(), data: array![0, 0, 0].span(),)))", name) ...
1, Option::Some(3), Option::None(()))", name) split_1D() split_2D() split_zero_size() split_1d_uneven() split_2d_uneven()
import numpy as np from nodegen.node
import RunAll from ..helpers
import make_test, to_fp, Tensor, Dtype, FixedImpl
class Split_to_sequence(RunAll): @staticmethod def split_to_sequence_u32(): def split_to_sequence_1D(): x = np.random.randint(0, 255, 6).astype(np.uint32) y = [ np.array(x[0:2]).astype(np.uint32), np.array(x[2:4]).astype(np.uint32), ...
TensorTrait::<u32>::new(shape: array![1].span(), data: array![2].span(),)))", name) y = [ np.array(x[0:2, 0:2]).astype(np.uint32), np.array(x[0:2, 2:6]).astype(np.uint32) ] _y = [ Tensor(Dtype.U32, y[0].shape, y[0].flatten()), ...
Tensor(Dtype.U32, y[2].shape, y[2].flatten()), Tensor(Dtype.U32, y[3].shape, y[3].flatten()), ] name = "split_to_sequence_u32_1d_uneven" make_test( [_x], _y, "input_0.split_to_sequence(0, 1, Option::Some(TensorTrait::<u32>::new(shape: array![1].span()...
, y[2].shape, y[2].flatten()), Tensor(Dtype.U32, y[3].shape, y[3].flatten()), Tensor(Dtype.U32, y[4].shape, y[4].flatten()), Tensor(Dtype.U32, y[5].shape, y[5].flatten()), Tensor(Dtype.U32, y[6].shape, y[6].flatten()), Tensor(Dtype.U32, y[7...
np.array(x[0:1]).astype(np.uint32), np.array(x[1:2]).astype(np.uint32), np.array(x[2:3]).astype(np.uint32), np.array(x[3:4]).astype(np.uint32), np.array(x[4:5]).astype(np.uint32), np.array(x[5:6]).astype(np.uint32), np...
Tensor(Dtype.FP16x16, y[1].shape, y[1].flatten()), Tensor(Dtype.FP16x16, y[2].shape, y[2].flatten()), ] name = "split_to_sequence_fp16x16_1d_equal_parts" make_test( [_x], _y, "input_0.split_to_sequence(0, 1, Option::Some(TensorTrait::<u32>::new(shape:...