org.nd4j.imports.tensorflow.TFImportStatus Maven / Gradle / Ivy
package org.nd4j.imports.tensorflow;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NonNull;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@AllArgsConstructor
@Data
public class TFImportStatus {
/** The paths of the model(s) that have been investigated */
private final List modelPaths;
/** The paths of the models that can't be imported, because they have 1 or more missing ops */
private final List cantImportModelPaths;
/** The paths of the models that can't be read for some reason (corruption, etc?) */
private final List readErrorModelPaths;
/** The total number of ops in all graphs */
private final int totalNumOps;
/** The number of unique ops in all graphs */
private final int numUniqueOps;
/** The (unique) names of all ops encountered in all graphs */
private final Set opNames;
/** The (unique) names of all ops that were encountered, and can be imported, in all graphs */
private final Set importSupportedOpNames;
/** The (unique) names of all ops that were encountered, and can NOT be imported (lacking import mapping) */
private final Set unsupportedOpNames;
public TFImportStatus merge(@NonNull TFImportStatus other){
List newModelPaths = new ArrayList<>(modelPaths);
newModelPaths.addAll(other.modelPaths);
List newCantImportModelPaths = new ArrayList<>(cantImportModelPaths);
newCantImportModelPaths.addAll(other.cantImportModelPaths);
List newReadErrorModelPaths = new ArrayList<>(readErrorModelPaths);
newReadErrorModelPaths.addAll(other.readErrorModelPaths);
Set newOpNames = new HashSet<>(opNames);
newOpNames.addAll(other.opNames);
Set newImportSupportedOpNames = new HashSet<>(importSupportedOpNames);
newImportSupportedOpNames.addAll(other.importSupportedOpNames);
Set newUnsupportedOpNames = new HashSet<>(unsupportedOpNames);
newUnsupportedOpNames.addAll(other.unsupportedOpNames);
int countUnique = newImportSupportedOpNames.size() + newUnsupportedOpNames.size();
return new TFImportStatus(
newModelPaths,
newCantImportModelPaths,
newReadErrorModelPaths,
totalNumOps + other.totalNumOps,
countUnique,
newOpNames,
newImportSupportedOpNames,
newUnsupportedOpNames);
}
}