/** * <pre> * A (possibly partial) specification for the device on which this * node should be placed. * The expected syntax for this string is as follows: * DEVICE_SPEC ::= PARTIAL_SPEC * PARTIAL_SPEC ::= ("/" CONSTRAINT) * * CONSTRAINT ::= ("job:" JOB_NAME) * | ("replica:" [1-9][0-9]*) * | ("task:" [1-9][0-9]*) * | ("device:" [A-Za-z]* ":" ([1-9][0-9]* | "*") ) * Valid values for this string include: * * "/job:worker/replica:0/task:1/device:GPU:3" (full specification) * * "/job:worker/device:GPU:3" (partial specification) * * "" (no specification) * If the constraints do not resolve to a single device (or if this * field is empty or not present), the runtime will attempt to * choose a device automatically. * </pre> * * <code>string device = 4;</code> */ public Builder clearDevice() { device_ = getDefaultInstance().getDevice(); onChanged(); return this; } /**
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof org.tensorflow.framework.NodeDef)) { return super.equals(obj); } org.tensorflow.framework.NodeDef other = (org.tensorflow.framework.NodeDef) obj; boolean result = true; result = result && getName() .equals(other.getName()); result = result && getOp() .equals(other.getOp()); result = result && getInputList() .equals(other.getInputList()); result = result && getDevice() .equals(other.getDevice()); result = result && internalGetAttr().equals( other.internalGetAttr()); result = result && unknownFields.equals(other.unknownFields); return result; }
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); hash = (37 * hash) + NAME_FIELD_NUMBER; hash = (53 * hash) + getName().hashCode(); hash = (37 * hash) + OP_FIELD_NUMBER; hash = (53 * hash) + getOp().hashCode(); if (getInputCount() > 0) { hash = (37 * hash) + INPUT_FIELD_NUMBER; hash = (53 * hash) + getInputList().hashCode(); } hash = (37 * hash) + DEVICE_FIELD_NUMBER; hash = (53 * hash) + getDevice().hashCode(); if (!internalGetAttr().getMap().isEmpty()) { hash = (37 * hash) + ATTR_FIELD_NUMBER; hash = (53 * hash) + internalGetAttr().hashCode(); } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
public Builder mergeFrom(org.tensorflow.framework.NodeDef other) { if (other == org.tensorflow.framework.NodeDef.getDefaultInstance()) return this; if (!other.getName().isEmpty()) { name_ = other.name_; onChanged(); } if (!other.getOp().isEmpty()) { op_ = other.op_; onChanged(); } if (!other.input_.isEmpty()) { if (input_.isEmpty()) { input_ = other.input_; bitField0_ = (bitField0_ & ~0x00000004); } else { ensureInputIsMutable(); input_.addAll(other.input_); } onChanged(); } if (!other.getDevice().isEmpty()) { device_ = other.device_; onChanged(); } internalGetMutableAttr().mergeFrom( other.internalGetAttr()); this.mergeUnknownFields(other.unknownFields); onChanged(); return this; }
/** * <pre> * A (possibly partial) specification for the device on which this * node should be placed. * The expected syntax for this string is as follows: * DEVICE_SPEC ::= PARTIAL_SPEC * PARTIAL_SPEC ::= ("/" CONSTRAINT) * * CONSTRAINT ::= ("job:" JOB_NAME) * | ("replica:" [1-9][0-9]*) * | ("task:" [1-9][0-9]*) * | ("device:" [A-Za-z]* ":" ([1-9][0-9]* | "*") ) * Valid values for this string include: * * "/job:worker/replica:0/task:1/device:GPU:3" (full specification) * * "/job:worker/device:GPU:3" (partial specification) * * "" (no specification) * If the constraints do not resolve to a single device (or if this * field is empty or not present), the runtime will attempt to * choose a device automatically. * </pre> * * <code>string device = 4;</code> */ public Builder clearDevice() { device_ = getDefaultInstance().getDevice(); onChanged(); return this; } /**
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof org.tensorflow.framework.NodeDef)) { return super.equals(obj); } org.tensorflow.framework.NodeDef other = (org.tensorflow.framework.NodeDef) obj; boolean result = true; result = result && getName() .equals(other.getName()); result = result && getOp() .equals(other.getOp()); result = result && getInputList() .equals(other.getInputList()); result = result && getDevice() .equals(other.getDevice()); result = result && internalGetAttr().equals( other.internalGetAttr()); result = result && unknownFields.equals(other.unknownFields); return result; }
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); hash = (37 * hash) + NAME_FIELD_NUMBER; hash = (53 * hash) + getName().hashCode(); hash = (37 * hash) + OP_FIELD_NUMBER; hash = (53 * hash) + getOp().hashCode(); if (getInputCount() > 0) { hash = (37 * hash) + INPUT_FIELD_NUMBER; hash = (53 * hash) + getInputList().hashCode(); } hash = (37 * hash) + DEVICE_FIELD_NUMBER; hash = (53 * hash) + getDevice().hashCode(); if (!internalGetAttr().getMap().isEmpty()) { hash = (37 * hash) + ATTR_FIELD_NUMBER; hash = (53 * hash) + internalGetAttr().hashCode(); } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
@Procedure(value = "load.tensorflow", mode = Mode.WRITE) public Stream<LoadResult> loadTensorFlow(@Name("file") String url) throws IOException { GraphDef graphDef = GraphDef.parseFrom(new BufferedInputStream(new URL(url).openStream())); Map<String, Node> nodes = new HashMap<>(); // tod model node, layer nodes for (NodeDef nodeDef : graphDef.getNodeList()) { Node node = db.createNode(Types.Neuron); node.setProperty("name", nodeDef.getName()); if (nodeDef.getDevice() != null) node.setProperty("device", nodeDef.getDevice()); node.setProperty("op", nodeDef.getOp()); nodeDef.getAttrMap().forEach((k, v) -> { Object value = getValue(v); if (value != null) { node.setProperty(k, value); } }); nodes.put(nodeDef.getName(), node); } long rels = 0; for (NodeDef nodeDef : graphDef.getNodeList()) { Node target = nodes.get(nodeDef.getName()); nodeDef.getInputList().forEach(name -> nodes.get(name).createRelationshipTo(target, RelTypes.INPUT)); // todo weights rels += nodeDef.getInputCount(); } return Stream.of(new LoadResult(url,"tensorflow",nodes.size(), rels)); }
public Builder mergeFrom(org.tensorflow.framework.NodeDef other) { if (other == org.tensorflow.framework.NodeDef.getDefaultInstance()) return this; if (!other.getName().isEmpty()) { name_ = other.name_; onChanged(); } if (!other.getOp().isEmpty()) { op_ = other.op_; onChanged(); } if (!other.input_.isEmpty()) { if (input_.isEmpty()) { input_ = other.input_; bitField0_ = (bitField0_ & ~0x00000004); } else { ensureInputIsMutable(); input_.addAll(other.input_); } onChanged(); } if (!other.getDevice().isEmpty()) { device_ = other.device_; onChanged(); } internalGetMutableAttr().mergeFrom( other.internalGetAttr()); this.mergeUnknownFields(other.unknownFields); onChanged(); return this; }