[go: nahoru, domu]

Skip to content

Commit

Permalink
More changes
Browse files Browse the repository at this point in the history
  • Loading branch information
malmaud committed May 26, 2017
1 parent 11952c0 commit 4fc8533
Show file tree
Hide file tree
Showing 11 changed files with 4,118 additions and 4,070 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/ops/imported_ops.jl linguist-generated=true
9 changes: 7 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@ In particular for TensorFlow.jl:
* The order of arguments to `concat` has switched (tensors to concatenate come first, followed by the concetenation axis).


New functionality
Highlights
----------------

* `dynamic_rnn` has been added
* `while_loop` has been added, with a convenient `@tf while ... end` syntax
* Many new ops
* Support for Docker via official Docker images

Switch to 1-based indexing
Expand All @@ -34,3 +33,9 @@ legacy. This affects the following functions:

* The `axis` parameter for any operation which takes an `axis` parameter
* The `begin_` argument of `slice`

All TensorFlow operations now supported
--------------

Every operation defined by TensorFlow is now automatically wrapped in a
Julia function available in the `Ops` module.
2 changes: 1 addition & 1 deletion src/TensorFlow.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
__precompile__(true)
module TensorFlow

warn("Initial precompilation can take up to 15 minutes; subsequent usage will only take a few seconds. Please be patient.")
warn("Loading a new version of TensorFlow.jl for the first time. This initial load can take up to 15 minutes as code is precompiled; subsequent usage will only take a few seconds.")

export
Graph,
Expand Down
17 changes: 12 additions & 5 deletions src/ops.jl
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ function to_function(op::tensorflow.OpDef)
for (input_idx, input) in enumerate(op.input_arg)
sym = inputs[input_idx]
convert_target = tf.Tensor{Any}
if input.type_attr ["Index", "Tidx", "Tindices"]
if input.type_attr ["Index", "Tidx", "Tindices", "Tdim"]
diff_expr = quote
#converted = converted - 1
$sym = $sym - convert(tf.Tensor{eltype($sym)}, 1)
Expand All @@ -242,12 +242,15 @@ function to_function(op::tensorflow.OpDef)
for attr in op.attr
if attr.name == input.type_attr
if isdefined(attr, :default_value)
convert_target = Tensor{load_proto(attr.default_value)}
convert_target = tf.Tensor{load_proto(attr.default_value)}
break
end
end
end
end
if input._type > 0 && haskey(proto_type_map, input._type)
convert_target = tf.Tensor{proto_type_map[input._type]}
end
convert_expr = if isempty(input.number_attr) && isempty(input.type_list_attr) # Scalar input
:($sym=convert($(convert_target), $sym))
else # Array argument
Expand Down Expand Up @@ -294,7 +297,9 @@ function to_function(op::tensorflow.OpDef)
end
if attr.name ["axis", "begin_mask", "end_mask", "ellipsis_mask", "new_axis_mask", "shrink_axis_mask", "component_index", "concat_dim"]
push!(attr_block.args, quote
$name = $source - 1
if $name !== nothing
$name = $source - 1
end
end)
elseif attr._type == "int" && attr.minimum == 0
# info("Attribute $(op.name).$(attr.name) is likely an index and should be converted to 1-based indexing")
Expand Down Expand Up @@ -359,13 +364,15 @@ function stringify_func(opfunc::OpFunc)
s = sprint(show, opfunc.expr)
noquote = Base.split(s, "\n")[2:end-1]
docstring = replace(opfunc.docstring, "\$", "")
lines = ["\"\"\"\n$(docstring)\n\"\"\""]
doc_line = "\"\"\"\n$(docstring)\n\"\"\""
lines = []
for line in noquote
line = replace(line, r"##", "v")
line = replace(line, r"#.*$", "")
push!(lines, line[5:end])
# push!(lines, line)
end
join(lines, "\n")
"$doc_line\n$(join(lines, "\n"))"
end

stringify_func(op::tensorflow.OpDef) = stringify_func(to_function(op))
Expand Down
Loading

0 comments on commit 4fc8533

Please sign in to comment.