mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-20 19:12:24 +00:00
Allow creating ConstantScalarNode for double type (#16797)
### Allow creating ConstantScalarNode for double type Allow create ConstantScalarNode for double type. Looks double type is not respected when creating constant. So fix it. ``` onnxruntime::python::addObjectMethodsForTraining(pybind11::module&, onnxruntime::python::ExecutionProviderRegistrationFn)::<lambda(onnxruntime::training::OrtModuleGraphBuilder*, const onnxruntime::training::TrainingGraphTransformerConfiguration&)> [ONNXRuntimeError] : 1 : FAIL : Type Error: Type parameter (T) of Optype (Sub) bound to different types (tensor(double) and tensor(float) in node (/_original_module/_original_model/gpt_neox/layers.0/input_layernorm/Pow_Grad/Sub_1). ```
This commit is contained in:
parent
634a3f2f28
commit
a021cb1b6e
1 changed files with 7 additions and 0 deletions
|
|
@ -269,6 +269,10 @@ class GradientBuilderBase {
|
|||
return ConstantScalarNode(BFloat16(value), {1}, arg_name);
|
||||
}
|
||||
|
||||
if (elem_type == ONNX_NAMESPACE::TensorProto_DataType_DOUBLE) {
|
||||
return ConstantScalarNode(double(value), {1}, arg_name);
|
||||
}
|
||||
|
||||
#if !defined(DISABLE_FLOAT8_TYPES)
|
||||
|
||||
if (elem_type == ONNX_NAMESPACE::TensorProto_DataType_FLOAT8E4M3FN) {
|
||||
|
|
@ -289,6 +293,9 @@ class GradientBuilderBase {
|
|||
|
||||
#endif
|
||||
|
||||
ORT_ENFORCE(elem_type == ONNX_NAMESPACE::TensorProto_DataType_FLOAT,
|
||||
"Unsupported element type for constant node: ", elem_type);
|
||||
|
||||
return ConstantScalarNode(value, {1}, arg_name);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue