use of ai.djl.mxnet.engine.MxNDManager in project djl by deepjavalibrary.
the class FunctionInfo method invoke.
/**
* Calls an operator with the given arguments.
*
* @param manager the manager to attach the result to
* @param src the input NDArray(s) to the operator
* @param params the non-NDArray arguments to the operator. Should be a {@code PairList<String,
* String>}
* @return the error code or zero for no errors
*/
public NDArray[] invoke(NDManager manager, NDArray[] src, PairList<String, ?> params) {
checkDevices(src);
PairList<Pointer, SparseFormat> pairList = JnaUtils.imperativeInvoke(handle, src, null, params);
final MxNDManager mxManager = (MxNDManager) manager;
return pairList.stream().map(pair -> {
if (pair.getValue() != SparseFormat.DENSE) {
return mxManager.create(pair.getKey(), pair.getValue());
}
return mxManager.create(pair.getKey());
}).toArray(MxNDArray[]::new);
}
use of ai.djl.mxnet.engine.MxNDManager in project djl by deepjavalibrary.
the class MxBackendOptimizationTest method testOptimizedFor.
@Test
public void testOptimizedFor() {
// TODO: Add Customized plugin test
try (MxNDManager manager = (MxNDManager) NDManager.newBaseManager()) {
Symbol symbol = Symbol.load(manager, "../mxnet-model-zoo/src/test/resources/mlrepo/model/cv/image_classification/ai/djl/mxnet/resnet/0.0.1/resnet50_v1-symbol.json");
Symbol optimized = symbol.optimizeFor("test", manager.getDevice());
optimized.close();
}
}
Aggregations