All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.nd4j.autodiff.samediff.internal.memory.AbstractMemoryMgr Maven / Gradle / Ivy

There is a newer version: 1.0.0-M2.1
Show newest version
package org.nd4j.autodiff.samediff.internal.memory;

import lombok.NonNull;
import org.nd4j.autodiff.samediff.internal.SessionMemMgr;
import org.nd4j.linalg.api.ndarray.INDArray;

/**
 * Abstract memory manager, that implements ulike and dup methods using the underlying allocate methods
 *
 * @author Alex Black
 */
public abstract class AbstractMemoryMgr implements SessionMemMgr {

    @Override
    public INDArray ulike(@NonNull INDArray arr) {
        return allocate(false, arr.dataType(), arr.shape());
    }

    @Override
    public INDArray dup(@NonNull INDArray arr) {
        INDArray out = ulike(arr);
        out.assign(arr);
        return out;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy