Bernoulli#
Bernoulli - 15#
Version
name: Bernoulli (GitHub)
domain: main
since_version: 15
function:
support_level: SupportType.COMMON
shape inference: True
This version of the operator has been available since version 15.
Summary
Attributes
dtype - INT : The data type for the elements of the output tensor. if not specified, we will use the data type of the input tensor.
seed - FLOAT : (Optional) Seed to the random generator, if not specified we will auto generate one.
Inputs
input (heterogeneous) - T1:
Outputs
output (heterogeneous) - T2:
Type Constraints
T1 in ( tensor(double), tensor(float), tensor(float16) ): Constrain input types to float tensors.
T2 in ( tensor(bfloat16), tensor(bool), tensor(double), tensor(float), tensor(float16), tensor(int16), tensor(int32), tensor(int64), tensor(int8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(uint8) ): Constrain output types to all numeric tensors and bool tensors.
Examples
_bernoulli_without_dtype
import numpy as np
import onnx
node = onnx.helper.make_node(
"Bernoulli",
inputs=["x"],
outputs=["y"],
)
x = np.random.uniform(0.0, 1.0, 10).astype(float)
y = bernoulli_reference_implementation(x, float)
expect(node, inputs=[x], outputs=[y], name="test_bernoulli")
_bernoulli_with_dtype
import numpy as np
import onnx
node = onnx.helper.make_node(
"Bernoulli",
inputs=["x"],
outputs=["y"],
dtype=onnx.TensorProto.DOUBLE,
)
x = np.random.uniform(0.0, 1.0, 10).astype(np.float32)
y = bernoulli_reference_implementation(x, float)
expect(node, inputs=[x], outputs=[y], name="test_bernoulli_double")
_bernoulli_with_seed
import numpy as np
import onnx
seed = float(0)
node = onnx.helper.make_node(
"Bernoulli",
inputs=["x"],
outputs=["y"],
seed=seed,
)
x = np.random.uniform(0.0, 1.0, 10).astype(np.float32)
y = bernoulli_reference_implementation(x, np.float32)
expect(node, inputs=[x], outputs=[y], name="test_bernoulli_seed")