Showing 6,111 of 13,975 total issues
Method createBufferDetachedImpl
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private static DataBuffer createBufferDetachedImpl(long length, DataType type) {
logAllocationIfNeeded(dataType(),length * type.width());
switch (type) {
case DOUBLE:
Method addDependenciesForOp
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected void addDependenciesForOp(String opName, FrameIter depFrameIter) {
SameDiffOp op = sameDiff.getOps().get(opName);
List<String> inputs = op.getInputsToOp();
List<String> cdOps = op.getControlDeps();
List<String> cdVars = op.getVarControlDeps();
Method get
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public SDVariable get(SDVariable indices) {
SDVariable initialSize = sameDiff.zerosLike(shape()).castTo(DataType.INT64);
//pull from the first slice as the starting point and concatenate each result together
SDVariable startResult = sameDiff.slice(this, initialSize.castTo(DataType.INT64), sliceEnd(this,
sameDiff.onesLike(shape()).castTo(DataType.INT64)));
Method transformSameOpClass
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public static Class<?> transformSameOpClass(int opNum) {
switch (opNum){
case 0:
return Abs.class;
case 1:
Method preUpdate
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
@Override
public void preUpdate(SameDiff sd, At at, Variable v, INDArray update) {
if(writer == null)
initalizeWriter(sd);
Method mergeFrom
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public Builder mergeFrom(org.nd4j.ir.MapperNamespace.TransformerArgs other) {
if (other == org.nd4j.ir.MapperNamespace.TransformerArgs.getDefaultInstance()) return this;
if (!other.getKey().isEmpty()) {
key_ = other.key_;
onChanged();
Method nullSafeHashCode
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public static int nullSafeHashCode(Object obj) {
if (obj == null) {
return 0;
} else {
if (obj.getClass().isArray()) {
Method toMinibatchArray
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public static INDArray toMinibatchArray(@NonNull List<? extends Writable> l) {
Preconditions.checkArgument(l.size() > 0, "Cannot convert empty list");
//Edge case: single NDArrayWritable
if(l.size() == 1 && l.get(0) instanceof NDArrayWritable){
Method doOp
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
@Override
protected Writable doOp(Writable... input) {
INDArray out = ((NDArrayWritable) input[0]).get().dup();
switch (mathOp) {
Method asMatrix
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private INDArray asMatrix(BytePointer bytes, long length) throws IOException {
PIXA pixa;
pixa = pixaReadMemMultipageTiff(bytes, length);
INDArray data;
INDArray currentD;
Method runMain
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public void runMain(String[] args) throws Exception {
JCommander.newBuilder()
.addObject(this)
.build()
.parse(args);
Method convertWritablesBatched
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private INDArray convertWritablesBatched(List<INDArray> list, SubsetDetails details) {
INDArray arr;
if (details.entireReader) {
if (list.size() == 1) {
arr = list.get(0);
Method mergeAndStoreRemainder
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected T mergeAndStoreRemainder(List<T> toMerge) {
//Could be smaller or larger
List<T> correctNum = new ArrayList<>();
List<T> remainder = new ArrayList<>();
int soFar = 0;
Method wordsNearest
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
@Override
public Collection<String> wordsNearest(INDArray words, int top) {
words = adjustRank(words);
if (lookupTable instanceof InMemoryLookupTable) {
Method accuracy
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
@Override
public Map<String, Double> accuracy(List<String> questions) {
Map<String, Double> accuracy = new HashMap<>();
Counter<String> right = new Counter<>();
String analogyType = "";
Method makeArgs
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private String[] makeArgs() {
ArgsFactory argsFactory = new ArgsFactory();
argsFactory.addOptional("cbow", cbow);
argsFactory.addOptional("skipgram", skipgram);
Method defineLayer
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
@Override
public SDVariable defineLayer(SameDiff sameDiff, SDVariable layerInput, Map<String, SDVariable> paramTable, SDVariable mask) {
final val W = paramTable.get(WEIGHT_KEY);
final val R = paramTable.get(RECURRENT_WEIGHT_KEY);
final val b = paramTable.get(BIAS_KEY);
Method activateOutput
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private INDArray activateOutput(final boolean training, boolean forBackprop, LayerWorkspaceMgr workspaceMgr) {
assertInputSet(false);
final FwdPassReturn forwardsEval;
final FwdPassReturn backwardsEval;
Method doInit
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected void doInit(){
try(MemoryWorkspace ws = Nd4j.getWorkspaceManager().scopeOutOfWorkspaces()) {
sameDiff = SameDiff.create();
//Use SingleThreadArrayHolder so we can use views (also don't need multithreading here, DL4J is not thread safe)
sameDiff.setArrayHolders(new SingleThreadArrayHolder(), new SingleThreadArrayHolder(), false);
Method doForward
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
@Override
public INDArray doForward(boolean training, LayerWorkspaceMgr workspaceMgr) {
if (!canDoForward())
throw new IllegalStateException("Cannot do forward pass: inputs not set");