deeplearning4j/deeplearning4j · error · IllegalArgumentException
Invalid argument for transformation
Error message
Invalid argument for transformation: ${descriptor.argType} What it means
PassThroughMultiTensorMapping.serialize() registers tensor/attribute names by ArgType; an UNRECOGNIZED argType throws this IllegalArgumentException ('Invalid argument for transformation'). The rule passes tensors through to the target op unchanged, so it cannot do anything with an argument whose type it cannot recognize. Note this rule routes DATA_TYPE to addInputDataTypeName while sibling rules route it to output — a known inconsistency worth checking when the error appears near data-type arguments.
Solutions
- Fix the descriptor's argType to a recognized ArgType value
- Regenerate/align protobuf ArgDescriptor definitions across nd4j modules
- Verify DATA_TYPE arguments are intentionally input-routed in this rule (else use another mapping rule)
- Add load-time validation of argTypes in mapping configs
Example fix
// before
OpNamespace.ArgDescriptor.ArgType.UNRECOGNIZED -> throw IllegalArgumentException("Invalid argument for transformation: ${descriptor.argType}")
// after
OpNamespace.ArgDescriptor.ArgType.UNRECOGNIZED -> error("Unrecognized ArgType for '$k'; regenerate protobuf defs or fix mapping config") Defensive patterns
Strategy: validation
Validate before calling
require(descriptor.argType != OpNamespace.ArgDescriptor.ArgType.UNRECOGNIZED) {
"PassThroughMultiTensorMapping: '$k' has UNRECOGNIZED argType"
} Type guard
fun isKnownArgType(d: OpNamespace.ArgDescriptor) = d.argType != OpNamespace.ArgDescriptor.ArgType.UNRECOGNIZED
Prevention
- Confirm data-type arguments are input-routed before choosing PassThroughMultiTensorMapping
- Keep descriptor protos and generated code version-aligned
- Validate pass-through mapping configs against the ArgType enum at load time
When it happens
Trigger: serialize() encounters descriptor.argType == ArgType.UNRECOGNIZED for key $k, from protobuf enum deserialization failure or a descriptor entry with unset/invalid type.
Common situations: Proto schema mismatch between modules; hand-written pass-through mapping config with bad argType; descriptors produced by a newer framework version not understood by the import library.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
AI-assisted analysis of deeplearning4j/deeplearning4j@4c22ac5fe4 (2026-09-07).
Data as JSON: /api/errors/e2de3b10cb316aaa.
Report an issue: GitHub.
Appendix: source
Thrown at nd4j/samediff-import/samediff-import-api/src/main/kotlin/org/nd4j/samediff/frameworkimport/rule/tensor/PassThroughMultiTensorMapping.kt:133
builder.ruleName = name()
builder.functionName = name()
builder.ruleType = "tensor"
builder.inputFrameworkOpName = inputFrameworkOpName()
for ((k, v) in transformerArgs) {
val descriptor = opDescriptor!!.argDescriptorList.filter { input -> input.name == k }[0]
when (descriptor.argType) {
OpNamespace.ArgDescriptor.ArgType.BOOL -> builder.addOutputBooleanName(k)
OpNamespace.ArgDescriptor.ArgType.INT64 -> builder.addOutputIntName(k)
OpNamespace.ArgDescriptor.ArgType.FLOAT -> builder.addOutputFloatName(k)
OpNamespace.ArgDescriptor.ArgType.DOUBLE -> builder.addOutputDoubleName(k)
OpNamespace.ArgDescriptor.ArgType.INT64 -> builder.addOutputIntName(k)
OpNamespace.ArgDescriptor.ArgType.INPUT_TENSOR -> builder.addInputTensorName(k)
OpNamespace.ArgDescriptor.ArgType.OUTPUT_TENSOR -> builder.addOutputTensorName(k)
OpNamespace.ArgDescriptor.ArgType.INT32 -> builder.addOutputIntName(k)
OpNamespace.ArgDescriptor.ArgType.DATA_TYPE -> builder.addInputDataTypeName(k)
OpNamespace.ArgDescriptor.ArgType.STRING -> builder.addOutputStringAttrName(k)
OpNamespace.ArgDescriptor.ArgType.UNRECOGNIZED -> throw IllegalArgumentException("Invalid argument for transformation: ${descriptor.argType}")
}
for (associatedInput in v) {
when (associatedInput.argType) {
OpNamespace.ArgDescriptor.ArgType.STRING -> builder.addInputStringAttrName(associatedInput.name)
OpNamespace.ArgDescriptor.ArgType.BOOL -> builder.addInputBooleanName(associatedInput.name)
OpNamespace.ArgDescriptor.ArgType.DOUBLE, OpNamespace.ArgDescriptor.ArgType.FLOAT -> builder.addInputFloatName(associatedInput.name)
OpNamespace.ArgDescriptor.ArgType.INT32, OpNamespace.ArgDescriptor.ArgType.INT64 -> builder.addInputIntName(associatedInput.name)
OpNamespace.ArgDescriptor.ArgType.INPUT_TENSOR -> builder.addInputTensorName(associatedInput.name)
OpNamespace.ArgDescriptor.ArgType.DATA_TYPE -> builder.addInputDataTypeName(associatedInput.name)
OpNamespace.ArgDescriptor.ArgType.OUTPUT_TENSOR -> builder.addOutputTensorName(associatedInput.name)
OpNamespace.ArgDescriptor.ArgType.UNRECOGNIZED -> throw IllegalArgumentException("Invalid argument for transformation: ${associatedInput.argType}")
}
}
}
View on GitHub (pinned to 4c22ac5fe4)