/** * <pre> * The default configuration for sessions that run on this server. * </pre> * * <code>.tensorflow.ConfigProto default_session_config = 4;</code> */ public org.tensorflow.framework.ConfigProto getDefaultSessionConfig() { return defaultSessionConfig_ == null ? org.tensorflow.framework.ConfigProto.getDefaultInstance() : defaultSessionConfig_; } /**
public Builder newBuilderForType() { return newBuilder(); } public static Builder newBuilder() {
public static Builder newBuilder() { return DEFAULT_INSTANCE.toBuilder(); } public static Builder newBuilder(org.tensorflow.framework.ConfigProto prototype) {
result = result && internalGetDeviceCount().equals( other.internalGetDeviceCount()); result = result && (getIntraOpParallelismThreads() == other.getIntraOpParallelismThreads()); result = result && (getInterOpParallelismThreads() == other.getInterOpParallelismThreads()); result = result && (getUsePerSessionThreads() == other.getUsePerSessionThreads()); result = result && getSessionInterOpThreadPoolList() .equals(other.getSessionInterOpThreadPoolList()); result = result && (getPlacementPeriod() == other.getPlacementPeriod()); result = result && getDeviceFiltersList() .equals(other.getDeviceFiltersList()); result = result && (hasGpuOptions() == other.hasGpuOptions()); if (hasGpuOptions()) { result = result && getGpuOptions() .equals(other.getGpuOptions()); result = result && (getAllowSoftPlacement() == other.getAllowSoftPlacement()); result = result && (getLogDevicePlacement() == other.getLogDevicePlacement()); result = result && (hasGraphOptions() == other.hasGraphOptions()); if (hasGraphOptions()) { result = result && getGraphOptions() .equals(other.getGraphOptions()); result = result && (getOperationTimeoutInMs()
: internalGetDeviceCount().getMap().entrySet()) { com.google.protobuf.MapEntry<java.lang.String, java.lang.Integer> deviceCount__ = DeviceCountDefaultEntryHolder.defaultEntry.newBuilderForType() dataSize += computeStringSizeNoTag(deviceFilters_.getRaw(i)); size += 1 * getDeviceFiltersList().size(); .computeMessageSize(6, getGpuOptions()); .computeMessageSize(10, getGraphOptions()); .computeMessageSize(13, getRpcOptions()); .computeMessageSize(14, getClusterDef()); .computeMessageSize(16, getExperimental());
.serializeStringMapTo( output, internalGetDeviceCount(), DeviceCountDefaultEntryHolder.defaultEntry, 1); output.writeMessage(6, getGpuOptions()); output.writeMessage(10, getGraphOptions()); output.writeMessage(13, getRpcOptions()); output.writeMessage(14, getClusterDef()); output.writeMessage(16, getExperimental());
/** * Convert a json string written out * by {@link com.github.os72.protobuf351.util.JsonFormat} * to a {@link org.bytedeco.javacpp.tensorflow.ConfigProto} * @param json the json to read * @return the config proto to use */ public static org.tensorflow.framework.ConfigProto fromJson(String json) { org.tensorflow.framework.ConfigProto.Builder builder = org.tensorflow.framework.ConfigProto.newBuilder(); try { JsonFormat.parser().merge(json,builder); org.tensorflow.framework.ConfigProto build = builder.build(); ByteString serialized = build.toByteString(); byte[] binaryString = serialized.toByteArray(); org.tensorflow.framework.ConfigProto configProto = org.tensorflow.framework.ConfigProto.parseFrom(binaryString); return configProto; } catch (Exception e) { e.printStackTrace(); } return null; }
public static org.tensorflow.framework.ConfigProto getAlignedWithNd4j() { org.tensorflow.framework.ConfigProto configProto = org.tensorflow.framework.ConfigProto.getDefaultInstance(); ConfigProto.Builder builder1 = configProto.toBuilder().addDeviceFilters(TensorflowConversion.defaultDeviceForThread()); try { //cuda if(Nd4j.getBackend().getClass().getName().toLowerCase().contains("jcu")) { builder1.setGpuOptions(GPUOptions.newBuilder() .setAllowGrowth(true) .setPerProcessGpuMemoryFraction(0.5) .build()); } //cpu else { } } catch (Exception e) { e.printStackTrace(); } return builder1.build(); }
/** * Note: Please use Models from zoltar-models module. * * <p>Creates a TensorFlow model based on a frozen, serialized TensorFlow {@link Graph}.</p> * * @param id model id @{link Model.Id}. * @param graphDef byte array representing the TensorFlow {@link Graph} definition. * @param config ConfigProto config for TensorFlow {@link Session}. * @param prefix a prefix that will be prepended to names in graphDef. */ public static TensorFlowGraphModel create(final Model.Id id, final byte[] graphDef, @Nullable final ConfigProto config, @Nullable final String prefix) throws IOException { final Graph graph = new Graph(); final Session session = new Session(graph, config != null ? config.toByteArray() : null); final long loadStart = System.currentTimeMillis(); if (prefix == null) { LOG.debug("Loading graph definition without prefix"); graph.importGraphDef(graphDef); } else { LOG.debug("Loading graph definition with prefix: {}", prefix); graph.importGraphDef(graphDef, prefix); } LOG.info("TensorFlow graph loaded in {} ms", System.currentTimeMillis() - loadStart); return new AutoValue_TensorFlowGraphModel(id, graph, session); }
org.tensorflow.framework.ConfigProto.Builder subBuilder = null; if (defaultSessionConfig_ != null) { subBuilder = defaultSessionConfig_.toBuilder(); defaultSessionConfig_ = input.readMessage(org.tensorflow.framework.ConfigProto.parser(), extensionRegistry); if (subBuilder != null) { subBuilder.mergeFrom(defaultSessionConfig_);
/** * <pre> * Optional list of all workers to use in this session. * </pre> * * <code>.tensorflow.ClusterDef cluster_def = 14;</code> */ public org.tensorflow.distruntime.ClusterDefOrBuilder getClusterDefOrBuilder() { return getClusterDef(); }
public org.tensorflow.framework.ConfigProto buildPartial() { org.tensorflow.framework.ConfigProto result = new org.tensorflow.framework.ConfigProto(this); int from_bitField0_ = bitField0_; int to_bitField0_ = 0;
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof org.tensorflow.distruntime.ServerDef)) { return super.equals(obj); } org.tensorflow.distruntime.ServerDef other = (org.tensorflow.distruntime.ServerDef) obj; boolean result = true; result = result && (hasCluster() == other.hasCluster()); if (hasCluster()) { result = result && getCluster() .equals(other.getCluster()); } result = result && getJobName() .equals(other.getJobName()); result = result && (getTaskIndex() == other.getTaskIndex()); result = result && (hasDefaultSessionConfig() == other.hasDefaultSessionConfig()); if (hasDefaultSessionConfig()) { result = result && getDefaultSessionConfig() .equals(other.getDefaultSessionConfig()); } result = result && getProtocol() .equals(other.getProtocol()); result = result && unknownFields.equals(other.unknownFields); return result; }
hash = (19 * hash) + getDescriptor().hashCode(); if (!internalGetDeviceCount().getMap().isEmpty()) { hash = (37 * hash) + DEVICE_COUNT_FIELD_NUMBER; hash = (53 * hash) + internalGetDeviceCount().hashCode(); hash = (53 * hash) + getIntraOpParallelismThreads(); hash = (37 * hash) + INTER_OP_PARALLELISM_THREADS_FIELD_NUMBER; hash = (53 * hash) + getInterOpParallelismThreads(); hash = (37 * hash) + USE_PER_SESSION_THREADS_FIELD_NUMBER; hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean( getUsePerSessionThreads()); if (getSessionInterOpThreadPoolCount() > 0) { hash = (37 * hash) + SESSION_INTER_OP_THREAD_POOL_FIELD_NUMBER; hash = (53 * hash) + getSessionInterOpThreadPoolList().hashCode(); hash = (53 * hash) + getPlacementPeriod(); if (getDeviceFiltersCount() > 0) { hash = (37 * hash) + DEVICE_FILTERS_FIELD_NUMBER; hash = (53 * hash) + getDeviceFiltersList().hashCode(); if (hasGpuOptions()) { hash = (37 * hash) + GPU_OPTIONS_FIELD_NUMBER; hash = (53 * hash) + getGpuOptions().hashCode(); getAllowSoftPlacement()); hash = (37 * hash) + LOG_DEVICE_PLACEMENT_FIELD_NUMBER; hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean( getLogDevicePlacement()); if (hasGraphOptions()) {
/** * Note: Please use Models from zoltar-models module. * * <p>Creates a TensorFlow model based on a frozen, serialized TensorFlow {@link Graph}. * * @param id model id @{link Model.Id}. * @param graphDef byte array representing the TensorFlow {@link Graph} definition. * @param config ConfigProto config for TensorFlow {@link Session}. * @param prefix a prefix that will be prepended to names in graphDef. */ public static TensorFlowGraphModel create( final Model.Id id, final byte[] graphDef, @Nullable final ConfigProto config, @Nullable final String prefix) throws IOException { final Graph graph = new Graph(); final Session session = new Session(graph, config != null ? config.toByteArray() : null); final long loadStart = System.currentTimeMillis(); if (prefix == null) { LOG.debug("Loading graph definition without prefix"); graph.importGraphDef(graphDef); } else { LOG.debug("Loading graph definition with prefix: {}", prefix); graph.importGraphDef(graphDef, prefix); } LOG.info("TensorFlow graph loaded in {} ms", System.currentTimeMillis() - loadStart); return new AutoValue_TensorFlowGraphModel(id, graph, session); }
public Builder mergeFrom(org.tensorflow.framework.ConfigProto other) { if (other == org.tensorflow.framework.ConfigProto.getDefaultInstance()) return this; internalGetMutableDeviceCount().mergeFrom( other.internalGetDeviceCount()); if (other.getIntraOpParallelismThreads() != 0) { setIntraOpParallelismThreads(other.getIntraOpParallelismThreads()); if (other.getInterOpParallelismThreads() != 0) { setInterOpParallelismThreads(other.getInterOpParallelismThreads()); if (other.getUsePerSessionThreads() != false) { setUsePerSessionThreads(other.getUsePerSessionThreads()); if (other.getPlacementPeriod() != 0) { setPlacementPeriod(other.getPlacementPeriod()); if (other.hasGpuOptions()) { mergeGpuOptions(other.getGpuOptions()); if (other.getAllowSoftPlacement() != false) { setAllowSoftPlacement(other.getAllowSoftPlacement()); if (other.getLogDevicePlacement() != false) { setLogDevicePlacement(other.getLogDevicePlacement()); if (other.hasGraphOptions()) { mergeGraphOptions(other.getGraphOptions()); if (other.getOperationTimeoutInMs() != 0L) { setOperationTimeoutInMs(other.getOperationTimeoutInMs());
public org.tensorflow.framework.ConfigProto getDefaultInstanceForType() { return org.tensorflow.framework.ConfigProto.getDefaultInstance(); }
private void initOptionsIfNeeded() { //setup the status object to be used for all tensorflow calls if(status == null) { status = TF_NewStatus(); } if (options == null) { options = TF_NewSessionOptions(); if(protoBufConfigProto != null) { BytePointer bytePointer = new BytePointer(protoBufConfigProto.toByteArray()); TF_SetConfig(options,bytePointer,bytePointer.getStringBytes().length,status); if (TF_GetCode(status) != TF_OK) { throw new IllegalStateException("ERROR: Unable to set value configuration:" + TF_Message(status).getString()); } } } }
public static Builder newBuilder(org.tensorflow.framework.ConfigProto prototype) { return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); } public Builder toBuilder() {
/** * <pre> * The default configuration for sessions that run on this server. * </pre> * * <code>.tensorflow.ConfigProto default_session_config = 4;</code> */ public Builder mergeDefaultSessionConfig(org.tensorflow.framework.ConfigProto value) { if (defaultSessionConfigBuilder_ == null) { if (defaultSessionConfig_ != null) { defaultSessionConfig_ = org.tensorflow.framework.ConfigProto.newBuilder(defaultSessionConfig_).mergeFrom(value).buildPartial(); } else { defaultSessionConfig_ = value; } onChanged(); } else { defaultSessionConfigBuilder_.mergeFrom(value); } return this; } /**