Importing BERT fails with Unable to find name dataType for op name: "tensorarrayv3"

I’m sorry if this is a naive question, but when I try to import the bert_mrpc_frozen.pb model with

TensorflowFrameworkImporter tensorflowFrameworkImporter = new TensorflowFrameworkImporter();
SameDiff sd = tensorflowFrameworkImporter.runImport(frozenBertPB.getAbsolutePath(), Collections.emptyMap());

I get the following exception:

Exception in thread "main" java.lang.ExceptionInInitializerError
	at org.nd4j.samediff.frameworkimport.tensorflow.importer.TensorflowFrameworkImporter.importFromGraph(TensorflowFrameworkImporter.kt:58)
	at org.nd4j.samediff.frameworkimport.tensorflow.importer.TensorflowFrameworkImporter.runImport(TensorflowFrameworkImporter.kt:64)
	at pt.ipb.erisk.data.bert.EriskBertTrainer.main(EriskBertTrainer.java:41)
Caused by: java.lang.IllegalArgumentException: Unable to find name dataType for op name: "tensorarrayv3"
argDescriptor {
  name: "outputs"
  argType: OUTPUT_TENSOR
}
.name
	at org.nd4j.samediff.frameworkimport.rule.attribute.BaseAttributeExtractionRule.argDescriptorTypesForOutputName(BaseAttributeExtractionRule.kt:153)
	at org.nd4j.samediff.frameworkimport.process.AbstractMappingProcess.<init>(AbstractMappingProcess.kt:105)
	at org.nd4j.samediff.frameworkimport.tensorflow.process.TensorflowMappingProcess.<init>(TensorflowMappingProcess.kt:49)
	at org.nd4j.samediff.frameworkimport.tensorflow.process.TensorflowMappingProcess.<init>(TensorflowMappingProcess.kt:48)
	at org.nd4j.samediff.frameworkimport.tensorflow.definitions.TensorflowOpDeclarationsKt.<clinit>(TensorflowOpDeclarations.kt:526)
	... 3 more

I do have the files nd4j-op-def.pbtxt, tensorflow-mapping-ruleset.pbtxt and tensorflow-op-def.pbtxt in the src/main/resources dir… what am I doing wrong?

Best,

/rp

@xiptos where did you grab the files for that? Are you using the files from master + 1.0.0-M1.1?

These issues usually come from the op descriptors being out of sync. I would try the version from snapshots just in case.

I believe it is the file from master:
https://github.com/eclipse/deeplearning4j/tree/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/resources
and
https://github.com/eclipse/deeplearning4j/tree/master/nd4j/samediff-import/samediff-import-tensorflow/src/main/resources

How can I try the SNAPSHOTs?

Thank you very much, @agibsonccc !

@xiptos Snapshots - Deeplearning4j

Thank you again, @agibsonccc. I believe that the -platform is out of sync, so I tried to use the nd4j-native, as suggested here: https://deeplearning4j.konduit.ai/multi-project/explanation/snapshots?_ga=2.93128093.1482849684.1643496468-1646476021.1643231843
However, even after adding openblas dependency, I’m still having dependency problems. In Apple Silicon, I get:

Caused by: java.lang.UnsatisfiedLinkError: Could not find jniopenblas_nolapack in class, module, and library paths.
	at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:1705)
	... 37 more

And in Linux x86_64:

Caused by: java.lang.UnsatisfiedLinkError: Could not find jnind4jcpu in class, module, and library paths.
	at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:1705)
	... 31 more

I cannot find the dependencies that would solve this missing libraries…

My dependency list is:

dl4j_version = "1.0.0-SNAPSHOT"

implementation "org.deeplearning4j:deeplearning4j-core:${dl4j_version}"
implementation "org.nd4j:nd4j-native:${dl4j_version}"
implementation "org.nd4j:samediff-import-tensorflow:${dl4j_version}"
implementation 'org.bytedeco:openblas-platform:0.3.13-1.5.5'
implementation 'org.bytedeco:mkl-platform:2021.1-1.5.5'

What can I try more?

Cheers!

@agibsonccc, the only way to get jnind4jcpu (or other backend - also tried cuda) is through the -platform?
I cannot find any other alternative in the snapshots repository… if it is out of sync it becomes impossible to download the dependencies, doesn’t it?

Sorry about that… :frowning:

@xiptos please ensure you’re using the new snapshots repository:
https://s01.oss.sonatype.org/

Sorry we just updated the site there. Sonatype is migrating all open source projects (not just us) to this new URL. I’ll make sure to update the docs. Could you please try again?

Thanks!

Thank you, @agibsonccc. Almost there! :slight_smile:
I believe that only the windows native library is available. Is there any way to “force” to use previous version of the linux or macOS?

Found it. Just specify the available version in the snapshots repository:

runtimeOnly "org.nd4j:nd4j-native:1.0.0-20220203.023328-127:macosx-x86_64-onednn-avx2"

Cheers!