Java Code Examples for org.nd4j.autodiff.samediff.SameDiff#addPropertyToResolve()

The following examples show how to use org.nd4j.autodiff.samediff.SameDiff#addPropertyToResolve() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseIndexAccumulation.java    From nd4j with Apache License 2.0 6 votes vote down vote up
public BaseIndexAccumulation(SameDiff sameDiff,
                             SDVariable i_v,
                             int[] dimensions) {
    super(sameDiff,new Object[]{dimensions});
    if (i_v != null) {
        this.dimensions = dimensions;
        f().validateDifferentialFunctionsameDiff(i_v);
        sameDiff.addArgsFor(new SDVariable[]{i_v},this);
        if(Shape.isPlaceholderShape(i_v.getShape())) {
            sameDiff.addPropertyToResolve(this,i_v.getVarName());
        }

        this.xVertexId = i_v.getVarName();
    } else {
        throw new IllegalArgumentException("Input not null variable.");
    }
}
 
Example 2
Source File: BaseIndexAccumulation.java    From nd4j with Apache License 2.0 6 votes vote down vote up
public BaseIndexAccumulation(SameDiff sameDiff,
                             SDVariable i_v,
                             SDVariable i_v2,
                             int[] dimensions) {
    super(sameDiff,new Object[]{dimensions});
    if (i_v != null) {
        this.dimensions = dimensions;
        f().validateDifferentialFunctionsameDiff(i_v);
        f().validateDifferentialFunctionsameDiff(i_v2);
        this.xVertexId = i_v.getVarName();
        this.yVertexId = i_v2.getVarName();
        sameDiff.addArgsFor(new SDVariable[]{i_v,i_v2},this);

        if(Shape.isPlaceholderShape(i_v.getShape())) {
            sameDiff.addPropertyToResolve(this,i_v.getVarName());
        }

        if(Shape.isPlaceholderShape(i_v2.getShape())) {
            sameDiff.addPropertyToResolve(this,i_v2.getVarName());
        }
    } else {
        throw new IllegalArgumentException("Input not null variable.");
    }
}
 
Example 3
Source File: BaseBroadcastOp.java    From nd4j with Apache License 2.0 6 votes vote down vote up
public BaseBroadcastOp(SameDiff sameDiff,
                       SDVariable i_v1,
                       SDVariable i_v2,
                       boolean inPlace,
                       int[] dimension) {
    super(sameDiff, inPlace, new Object[]{i_v2});
    if (i_v1 != null && i_v2 != null) {
        f().validateDifferentialFunctionsameDiff(i_v1);
        f().validateDifferentialFunctionsameDiff(i_v2);
        this.sameDiff = sameDiff;
        this.inPlace = inPlace;
        this.dimension = dimension;
        if(Shape.isPlaceholderShape(i_v1.getShape())) {
            sameDiff.addPropertyToResolve(this,i_v1.getVarName());
        }

        if(Shape.isPlaceholderShape(i_v2.getShape())) {
            sameDiff.addPropertyToResolve(this,i_v2.getVarName());
        }
        sameDiff.addArgsFor(new SDVariable[]{i_v1,i_v2},this);

    } else {
        throw new IllegalArgumentException("Input not null variables.");
    }

}
 
Example 4
Source File: BaseTransformOp.java    From nd4j with Apache License 2.0 6 votes vote down vote up
public BaseTransformOp(SameDiff sameDiff,
                       SDVariable i_v,
                       long[] shape,
                       boolean inPlace,
                       Object[] extraArgs) {
    super(sameDiff,inPlace,extraArgs);

    if (i_v != null) {
        f().validateDifferentialFunctionsameDiff(i_v);
        this.xVertexId = i_v.getVarName();
        sameDiff.addArgsFor(new SDVariable[]{i_v},this);
        if(i_v.getShape() != null) {
            this.n = ArrayUtil.prod(i_v.getShape());
        }

        if(Shape.isPlaceholderShape(i_v.getShape())) {
            sameDiff.addPropertyToResolve(this,i_v.getVarName());
        }


    } else {
        throw new IllegalArgumentException("Input must not null variable.");
    }

}
 
Example 5
Source File: ShapeOp.java    From nd4j with Apache License 2.0 6 votes vote down vote up
public ShapeOp(SameDiff sameDiff,
               SDVariable i_v,
               long[] shape,
               boolean inPlace,
               Object[] extraArgs) {
    super(sameDiff,inPlace,extraArgs);

    if (i_v != null) {
        f().validateDifferentialFunctionsameDiff(i_v);
        this.xVertexId = i_v.getVarName();
        sameDiff.addArgsFor(new String[]{xVertexId},this);
        if(Shape.isPlaceholderShape(i_v.getShape())) {
            sameDiff.addPropertyToResolve(this,i_v.getVarName());
        }

    } else {
        throw new IllegalArgumentException("Input not null variable.");
    }
}
 
Example 6
Source File: BaseAccumulation.java    From nd4j with Apache License 2.0 6 votes vote down vote up
public BaseAccumulation(SameDiff sameDiff,
                        SDVariable i_v,
                        int[] dimensions,boolean keepDims) {
    super(sameDiff,new Object[]{dimensions});
    if (i_v != null) {
        if(dimensions == null || dimensions.length < 1)
            dimensions = new int[] {Integer.MAX_VALUE};

        this.dimensions = dimensions;
        f().validateDifferentialFunctionsameDiff(i_v);
        this.keepDims = keepDims;
        this.xVertexId = i_v.getVarName();
        sameDiff.addArgsFor(new String[]{xVertexId},this);
        if(Shape.isPlaceholderShape(i_v.getShape())) {
            sameDiff.addPropertyToResolve(this,i_v.getVarName());
        }

    } else {
        throw new IllegalArgumentException("Input not null variable.");
    }

}
 
Example 7
Source File: BaseScalarOp.java    From nd4j with Apache License 2.0 6 votes vote down vote up
public BaseScalarOp(SameDiff sameDiff,
                    SDVariable i_v,
                    Number scalar,
                    boolean inPlace,
                    Object[] extraArgs) {
    super(sameDiff,inPlace,extraArgs);
    this.scalarValue = scalar;
    if (i_v != null) {
        this.xVertexId = i_v.getVarName();
        sameDiff.addArgsFor(new String[]{xVertexId},this);
        if(Shape.isPlaceholderShape(i_v.getShape())) {
            sameDiff.addPropertyToResolve(this,i_v.getVarName());
        }
        f().validateDifferentialFunctionsameDiff(i_v);
    } else {
        throw new IllegalArgumentException("Input not null variable.");
    }

}
 
Example 8
Source File: DifferentialFunction.java    From nd4j with Apache License 2.0 5 votes vote down vote up
/**
 * Add the various arguments for
 * this function
 * @param sameDiff
 * @param inPlace
 * @param args
 */
public DifferentialFunction(SameDiff sameDiff, boolean inPlace, SDVariable[] args) {
    this.sameDiff = sameDiff;
    this.inPlace = inPlace;
    setInstanceId();
    if(sameDiff != null) {
        sameDiff.addArgsFor(args, this);
        for (int i = 0; i < args.length; i++) {
            if (args[i].isPlaceHolder()) {
                sameDiff.addPropertyToResolve(this, args[i].getVarName());
            }
        }
    }
}
 
Example 9
Source File: BaseTransformOp.java    From nd4j with Apache License 2.0 5 votes vote down vote up
public BaseTransformOp(SameDiff sameDiff,
                       SDVariable i_v1,
                       SDVariable i_v2,
                       boolean inPlace) {
    super(sameDiff,inPlace,new Object[] {i_v2});
    if (i_v1 != null && i_v2 != null) {
        f().validateDifferentialFunctionsameDiff(i_v1);
        f().validateDifferentialFunctionsameDiff(i_v2);
        this.sameDiff = sameDiff;
        this.inPlace = inPlace;
        this.xVertexId = i_v1.getVarName();
        this.yVertexId = i_v2.getVarName();
        sameDiff.addArgsFor(new SDVariable[]{i_v1,i_v2},this);
        if(Shape.isPlaceholderShape(i_v1.getShape())) {
            sameDiff.addPropertyToResolve(this,i_v1.getVarName());
        }

        if(Shape.isPlaceholderShape(i_v2.getShape())) {
            sameDiff.addPropertyToResolve(this,i_v2.getVarName());
        }
        if(i_v1.getShape() != null)
            this.n = ArrayUtil.prod(i_v1.getShape());


    } else {
        throw new IllegalArgumentException("Input not null variables.");
    }


}
 
Example 10
Source File: BaseTransformOp.java    From nd4j with Apache License 2.0 5 votes vote down vote up
public BaseTransformOp(SameDiff sameDiff,
                       SDVariable i_v1,
                       SDVariable i_v2,
                       Object[] extraArgs) {
    super(sameDiff,extraArgs);
    if (i_v1 != null && i_v2 != null) {

        f().validateDifferentialFunctionsameDiff(i_v1);
        f().validateDifferentialFunctionsameDiff(i_v2);
        this.sameDiff = sameDiff;
        this.xVertexId = i_v1.getVarName();
        this.yVertexId = i_v2.getVarName();
        sameDiff.addArgsFor(new SDVariable[]{i_v1,i_v2},this);
        if(i_v1.getShape() != null)
            this.n = ArrayUtil.prod(i_v1.getShape());

        if(Shape.isPlaceholderShape(i_v1.getShape())) {
            sameDiff.addPropertyToResolve(this,i_v1.getVarName());
        }

        if(Shape.isPlaceholderShape(i_v2.getShape())) {
            sameDiff.addPropertyToResolve(this,i_v2.getVarName());
        }

    } else {
        throw new IllegalArgumentException("Input not null variables.");
    }

}
 
Example 11
Source File: BaseRandomOp.java    From nd4j with Apache License 2.0 5 votes vote down vote up
public BaseRandomOp(SameDiff sameDiff,
                        SDVariable i_v) {
    if (i_v != null) {
        this.sameDiff = sameDiff;
        this.xVertexId = i_v.getVarName();
        sameDiff.addArgsFor(new String[]{xVertexId},this);
        if(Shape.isPlaceholderShape(i_v.getShape())) {
            sameDiff.addPropertyToResolve(this,i_v.getVarName());
        }
    } else {
        throw new IllegalArgumentException("Input can't be null.");
    }
}