12 auto op_type = nodeproto.op_type();
13 if (op_type ==
"RandomNormal" || op_type ==
"RandomNormalLike")
18 std::string input_name;
20 if (nodeproto.input_size() > 0) {
21 input_name = nodeproto.input(0);
25 throw std::runtime_error(
"TMVA::SOFIE ONNX Parser Randomr op has input tensor" + input_name +
26 " but its type is not yet registered");
31 std::map<std::string, float> paramMap;
32 std::vector<size_t> shape;
33 for (
int i = 0; i < nodeproto.attribute_size(); i++) {
34 std::string attribute_name = nodeproto.attribute(i).name();
35 auto attr_type = nodeproto.attribute(i).type();
36 if (attribute_name ==
"dtype")
37 input_type =
static_cast<ETensorType>(nodeproto.attribute(i).i());
38 else if (attribute_name ==
"seed") {
39 if (attr_type == onnx::AttributeProto::FLOAT )
40 seed = nodeproto.attribute(i).f();
41 else if (attr_type == onnx::AttributeProto::INT)
42 seed = nodeproto.attribute(i).i();
44 throw std::runtime_error(
"TMVA::SOFIE ONNX Parser Random op has invalid type for attribute seed");
46 else if (attribute_name ==
"shape") {
47 if (attr_type != onnx::AttributeProto::INTS)
48 throw std::runtime_error(
"TMVA::SOFIE ONNX Parser Random op has invalid type for attribute shape");
49 shape = std::vector<size_t>(nodeproto.attribute(i).ints().begin(), nodeproto.attribute(i).ints().end());
53 if (attr_type == onnx::AttributeProto::FLOAT)
54 value = nodeproto.attribute(i).f();
55 else if (attr_type == onnx::AttributeProto::INT)
56 value = nodeproto.attribute(i).i();
58 throw std::runtime_error(
"TMVA::SOFIE ONNX Parser Random op has invalid type for attribute " + attribute_name);
59 paramMap[attribute_name] = value;
63 std::string output_name = nodeproto.output(0);
65 std::unique_ptr<ROperator> op(
new ROperator_Random(opMode, input_type, input_name, output_name, shape, paramMap, seed));