/** * This method sets dataType for the current JVM runtime * @param dType */ public static void setDataType(@NonNull DataBuffer.Type dType) { DataTypeUtil.setDTypeForContext(dType); }
/** * Set the allocation mode for the nd4j context * The value must be one of: heap, java cpp, or direct * or an @link{IllegalArgumentException} is thrown * @param allocationModeForContext */ public static void setDTypeForContext(DataBuffer.Type allocationModeForContext) { try { lock.writeLock().lock(); dtype = allocationModeForContext; setDTypeForContext(getDTypeForName(allocationModeForContext)); } finally { lock.writeLock().unlock(); } }
DataTypeUtil.setDTypeForContext(dtype);
/** * This method sets dataType for the current JVM runtime * @param dType */ public static void setDataType(@NonNull DataBuffer.Type dType) { DataTypeUtil.setDTypeForContext(dType); }
private Properties loadModelProperties() throws IOException { FileInputStream input = new FileInputStream(modelPath + "/config.properties"); // load a properties file Properties prop = new Properties(); prop.load(input); if (prop.getProperty("precision") != null && prop.getProperty("precision").equals("FP16")) { LOG.info("Model uses FP16 precision. Activating support."); DataTypeUtil.setDTypeForContext(DataBuffer.Type.HALF); } return prop; }
DataTypeUtil.setDTypeForContext(dtype);
@Override public void execute() { if ("FP16".equals(args().precision)) { precision = ParameterPrecision.FP16; System.out.println("Parameter precision set to FP16."); } if ("FP16".equals(args().precision)) { DataTypeUtil.setDTypeForContext(DataBuffer.Type.HALF); } if (args().getTrainingSets().length == 0) { System.err.println("You must provide training datasets."); } FeatureMapper featureMapper = null; try { featureMapper = configureFeatureMapper(args().featureMapperClassname, args().isTrio, args().getTrainingSets()); execute(featureMapper, args().getTrainingSets(), args().miniBatchSize); } catch (IOException e) { System.err.println("An exception occured. Details may be provided below"); e.printStackTrace(); } }
DataTypeUtil.setDTypeForContext(DataBuffer.Type.HALF);
public static void main(String[] args) { DataTypeUtil.setDTypeForContext(DataBuffer.Type.DOUBLE);