tf
This commit is contained in:
1 parent
eb1b42a5e8
commit
458eb2aef1
1283 files changed
+323373
No files matched your search
@@ -0,0 +1,129 @@
|
||||
/* Copyright 2016 The TensorFlow Authors. All Rights Reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==============================================================================*/
|
||||
|
||||
#ifndef TENSORFLOW_CC_CLIENT_CLIENT_SESSION_H_
|
||||
#define TENSORFLOW_CC_CLIENT_CLIENT_SESSION_H_
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include "tensorflow/cc/framework/ops.h"
|
||||
#include "tensorflow/cc/framework/scope.h"
|
||||
#include "tensorflow/core/public/session_options.h"
|
||||
|
||||
namespace tensorflow {
|
||||
|
||||
/// @addtogroup core
|
||||
/// @{
|
||||
|
||||
/// A `ClientSession` object lets the caller drive the evaluation of the
|
||||
/// TensorFlow graph constructed with the C++ API.
|
||||
///
|
||||
/// Example:
|
||||
///
|
||||
/// Scope root = Scope::NewRootScope();
|
||||
/// auto a = Placeholder(root, DT_INT32);
|
||||
/// auto c = Add(root, a, {41});
|
||||
///
|
||||
/// ClientSession session(root);
|
||||
/// std::vector<Tensor> outputs;
|
||||
///
|
||||
/// Status s = session.Run({ {a, {1}} }, {c}, &outputs);
|
||||
/// if (!s.ok()) { ... }
|
||||
class ClientSession {
|
||||
public:
|
||||
/// A data type to represent feeds to a Run call.
|
||||
///
|
||||
/// This is a map of `Output` objects returned by op-constructors to the value
|
||||
/// to feed them with. See `Input::Initializer` for details on what can be
|
||||
/// used as feed values.
|
||||
typedef std::unordered_map<Output, Input::Initializer, OutputHash> FeedType;
|
||||
|
||||
/// Create a new session to evaluate the graph contained in `scope` by
|
||||
/// connecting to the TensorFlow runtime specified by `target`.
|
||||
ClientSession(const Scope& scope, const string& target);
|
||||
|
||||
/// Same as above, but use the empty string ("") as the target specification.
|
||||
ClientSession(const Scope& scope);
|
||||
|
||||
/// Create a new session, configuring it with `session_options`.
|
||||
ClientSession(const Scope& scope, const SessionOptions& session_options);
|
||||
|
||||
~ClientSession();
|
||||
|
||||
/// Evaluate the tensors in `fetch_outputs`. The values are returned as
|
||||
/// `Tensor` objects in `outputs`. The number and order of `outputs` will
|
||||
/// match `fetch_outputs`.
|
||||
Status Run(const std::vector<Output>& fetch_outputs,
|
||||
std::vector<Tensor>* outputs) const;
|
||||
|
||||
/// Same as above, but use the mapping in `inputs` as feeds.
|
||||
Status Run(const FeedType& inputs, const std::vector<Output>& fetch_outputs,
|
||||
std::vector<Tensor>* outputs) const;
|
||||
|
||||
/// Same as above. Additionally runs the operations ins `run_outputs`.
|
||||
Status Run(const FeedType& inputs, const std::vector<Output>& fetch_outputs,
|
||||
const std::vector<Operation>& run_outputs,
|
||||
std::vector<Tensor>* outputs) const;
|
||||
|
||||
/// Use `run_options` to turn on performance profiling. `run_metadata`, if not
|
||||
/// null, is filled in with the profiling results.
|
||||
Status Run(const RunOptions& run_options, const FeedType& inputs,
|
||||
const std::vector<Output>& fetch_outputs,
|
||||
const std::vector<Operation>& run_outputs,
|
||||
std::vector<Tensor>* outputs, RunMetadata* run_metadata) const;
|
||||
|
||||
/// \brief A handle to a subgraph, created with
|
||||
/// `ClientSession::MakeCallable()`.
|
||||
typedef int64 CallableHandle;
|
||||
|
||||
/// \brief Creates a `handle` for invoking the subgraph defined by
|
||||
/// `callable_options`.
|
||||
/// NOTE: This API is still experimental and may change.
|
||||
Status MakeCallable(const CallableOptions& callable_options,
|
||||
CallableHandle* out_handle);
|
||||
|
||||
/// \brief Invokes the subgraph named by `handle` with the given options and
|
||||
/// input tensors.
|
||||
///
|
||||
/// The order of tensors in `feed_tensors` must match the order of names in
|
||||
/// `CallableOptions::feed()` and the order of tensors in `fetch_tensors` will
|
||||
/// match the order of names in `CallableOptions::fetch()` when this subgraph
|
||||
/// was created.
|
||||
/// NOTE: This API is still experimental and may change.
|
||||
Status RunCallable(CallableHandle handle,
|
||||
const std::vector<Tensor>& feed_tensors,
|
||||
std::vector<Tensor>* fetch_tensors,
|
||||
RunMetadata* run_metadata);
|
||||
|
||||
/// \brief Releases resources associated with the given `handle` in this
|
||||
/// session.
|
||||
/// NOTE: This API is still experimental and may change.
|
||||
Status ReleaseCallable(CallableHandle handle);
|
||||
|
||||
private:
|
||||
class Impl;
|
||||
std::unique_ptr<Impl> impl_;
|
||||
Impl* impl() { return impl_.get(); }
|
||||
const Impl* impl() const { return impl_.get(); }
|
||||
};
|
||||
|
||||
/// @}
|
||||
|
||||
} // end namespace tensorflow
|
||||
|
||||
#endif // TENSORFLOW_CC_CLIENT_CLIENT_SESSION_H_
|
||||
@@ -0,0 +1,75 @@
|
||||
/* Copyright 2016 The TensorFlow Authors. All Rights Reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==============================================================================*/
|
||||
|
||||
#ifndef TENSORFLOW_CC_FRAMEWORK_GRAD_OP_REGISTRY_H_
|
||||
#define TENSORFLOW_CC_FRAMEWORK_GRAD_OP_REGISTRY_H_
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
#include "tensorflow/cc/framework/ops.h"
|
||||
#include "tensorflow/cc/framework/scope.h"
|
||||
|
||||
namespace tensorflow {
|
||||
namespace ops {
|
||||
|
||||
/// GradFunc is the signature for all gradient functions in GradOpRegistry.
|
||||
/// Implementations should add operations to compute the gradient outputs of
|
||||
/// 'op' (returned in 'grad_outputs') using 'scope' and 'grad_inputs'.
|
||||
typedef Status (*GradFunc)(const Scope& scope, const Operation& op,
|
||||
const std::vector<Output>& grad_inputs,
|
||||
std::vector<Output>* grad_outputs);
|
||||
|
||||
/// GradOpRegistry maintains a static registry of gradient functions.
|
||||
/// Gradient functions are indexed in the registry by the forward op name (i.e.
|
||||
/// "MatMul" -> MatMulGrad func).
|
||||
class GradOpRegistry {
|
||||
public:
|
||||
/// Registers 'func' as the gradient function for 'op'.
|
||||
/// Returns true if registration was successful, check fails otherwise.
|
||||
bool Register(const string& op, GradFunc func);
|
||||
|
||||
/// Sets 'func' to the gradient function for 'op' and returns Status OK if
|
||||
/// the gradient function for 'op' exists in the registry.
|
||||
/// Note that 'func' can be null for ops that have registered no-gradient with
|
||||
/// the registry.
|
||||
/// Returns error status otherwise.
|
||||
Status Lookup(const string& op, GradFunc* func) const;
|
||||
|
||||
/// Returns a pointer to the global gradient function registry.
|
||||
static GradOpRegistry* Global();
|
||||
|
||||
private:
|
||||
std::unordered_map<string, GradFunc> registry_;
|
||||
};
|
||||
|
||||
} // namespace ops
|
||||
|
||||
// Macros used to define gradient functions for ops.
|
||||
#define REGISTER_GRADIENT_OP(name, fn) \
|
||||
REGISTER_GRADIENT_OP_UNIQ_HELPER(__COUNTER__, name, fn)
|
||||
|
||||
#define REGISTER_NO_GRADIENT_OP(name) \
|
||||
REGISTER_GRADIENT_OP_UNIQ_HELPER(__COUNTER__, name, nullptr)
|
||||
|
||||
#define REGISTER_GRADIENT_OP_UNIQ_HELPER(ctr, name, fn) \
|
||||
REGISTER_GRADIENT_OP_UNIQ(ctr, name, fn)
|
||||
|
||||
#define REGISTER_GRADIENT_OP_UNIQ(ctr, name, fn) \
|
||||
static bool unused_ret_val_##ctr = \
|
||||
::tensorflow::ops::GradOpRegistry::Global()->Register(name, fn)
|
||||
|
||||
} // namespace tensorflow
|
||||
|
||||
#endif // TENSORFLOW_CC_FRAMEWORK_GRAD_OP_REGISTRY_H_
|
||||
@@ -0,0 +1,63 @@
|
||||
/* Copyright 2016 The TensorFlow Authors. All Rights Reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==============================================================================*/
|
||||
|
||||
#ifndef TENSORFLOW_CC_FRAMEWORK_GRADIENT_CHECKER_H_
|
||||
#define TENSORFLOW_CC_FRAMEWORK_GRADIENT_CHECKER_H_
|
||||
|
||||
#include "tensorflow/cc/framework/ops.h"
|
||||
#include "tensorflow/cc/framework/scope.h"
|
||||
#include "tensorflow/core/framework/tensor.h"
|
||||
|
||||
namespace tensorflow {
|
||||
|
||||
/// Returns in 'max_error' the maximum element-wise error for dy/dx between the
|
||||
/// computed and numeric Jacobian matrices where 'xs' and 'ys' are tensors.
|
||||
/// X_T and Y_T are the c++ types for the x and y tensors, and JAC_T is a
|
||||
/// real-valued type to store the Jacobian derivatives dy/dx.
|
||||
/// This function adds operations to the graph associated with 'scope'.
|
||||
///
|
||||
/// Examples:
|
||||
/// if y = Square(x), where x (and so y) are DT_FLOAT,
|
||||
/// <X_T, Y_T, JAC_T> should be <float, float, float>
|
||||
///
|
||||
/// if y = Square(x), where x (and so y) are DT_DOUBLE,
|
||||
/// <X_T, Y_T, JAC_T> should be <double, double, double>
|
||||
///
|
||||
/// if y = Square(x), where x (and so y) are DT_COMPLEX64,
|
||||
/// <X_T, Y_T, JAC_T> should be <complex64, complex64, float>
|
||||
/// Note that JAC_T is always real-valued, and should be an appropriate
|
||||
/// precision to host the partial derivatives for dy/dx
|
||||
///
|
||||
/// if y = ComplexAbs(x) where x is DT_COMPLEX64 (so y is DT_FLOAT)
|
||||
/// <X_T, Y_T, JAC_T> should be <complex64, float, float>
|
||||
///
|
||||
/// if y = Complex(x, x) where x is DT_FLOAT (so y is DT_COMPLEX64)
|
||||
/// <X_T, Y_T, JAC_T> should be <float, complex64, float>
|
||||
template <typename X_T, typename Y_T, typename JAC_T>
|
||||
Status ComputeGradientError(const Scope& scope, const OutputList& xs,
|
||||
const std::vector<TensorShape>& x_shapes,
|
||||
const OutputList& ys,
|
||||
const std::vector<TensorShape>& y_shapes,
|
||||
JAC_T* max_error);
|
||||
|
||||
/// Overload of ComputeGradientError which takes an initial value for 'x'.
|
||||
template <typename X_T, typename Y_T, typename JAC_T>
|
||||
Status ComputeGradientError(const Scope& scope, const Output& x,
|
||||
const Tensor& x_init_value, const Output& y,
|
||||
const TensorShape& y_shape, JAC_T* max_error);
|
||||
|
||||
} // namespace tensorflow
|
||||
|
||||
#endif // TENSORFLOW_CC_FRAMEWORK_GRADIENT_CHECKER_H_
|
||||
@@ -0,0 +1,52 @@
|
||||
/* Copyright 2015 The TensorFlow Authors. All Rights Reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==============================================================================*/
|
||||
|
||||
#ifndef TENSORFLOW_CC_FRAMEWORK_GRADIENTS_H_
|
||||
#define TENSORFLOW_CC_FRAMEWORK_GRADIENTS_H_
|
||||
|
||||
#include "tensorflow/cc/framework/ops.h"
|
||||
#include "tensorflow/cc/framework/scope.h"
|
||||
|
||||
namespace tensorflow {
|
||||
|
||||
/// NOTE: This API is a work in progress and will likely be changing frequently.
|
||||
///
|
||||
/// Given initial gradients 'grad_inputs' (which represent the symbolic partial
|
||||
/// derivatives of some loss function 'L' w.r.t 'outputs'), adds gradient nodes
|
||||
/// to the graph associated with 'scope', which compute (and return in
|
||||
/// 'grad_outputs') the symbolic partial derivatives of 'L' w.r.t 'inputs'.
|
||||
Status AddSymbolicGradients(const Scope& scope,
|
||||
const std::vector<Output>& outputs,
|
||||
const std::vector<Output>& inputs,
|
||||
const std::vector<Output>& grad_inputs,
|
||||
std::vector<Output>* grad_outputs);
|
||||
|
||||
// Same as above, but uses 'OnesLike' for all shapes in
|
||||
// 'outputs' as grad_inputs.
|
||||
Status AddSymbolicGradients(const Scope& scope,
|
||||
const std::vector<Output>& outputs,
|
||||
const std::vector<Output>& inputs,
|
||||
std::vector<Output>* grad_outputs);
|
||||
|
||||
/// Returns a sentinel Output that represents 'no gradient' (i.e. no gradient
|
||||
/// flows along some graph edge during backpropagation).
|
||||
/// Can be returned in 'grad_outputs' by an invocation of 'AddSymbolicGradients'
|
||||
/// (note that gradient flow through an Output can be stopped through the use of
|
||||
/// the StopGradient node).
|
||||
Output NoGradient();
|
||||
|
||||
} // namespace tensorflow
|
||||
|
||||
#endif // TENSORFLOW_CC_FRAMEWORK_GRADIENTS_H_
|
||||
@@ -0,0 +1,299 @@
|
||||
/* Copyright 2016 The TensorFlow Authors. All Rights Reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==============================================================================*/
|
||||
|
||||
#ifndef TENSORFLOW_CC_FRAMEWORK_OPS_H_
|
||||
#define TENSORFLOW_CC_FRAMEWORK_OPS_H_
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#include "tensorflow/core/framework/tensor.h"
|
||||
#include "tensorflow/core/framework/tensor.pb.h"
|
||||
#include "tensorflow/core/graph/graph.h"
|
||||
#include "tensorflow/core/lib/hash/hash.h"
|
||||
#include "tensorflow/core/lib/strings/strcat.h"
|
||||
|
||||
namespace tensorflow {
|
||||
|
||||
/// @defgroup core Core Tensorflow API
|
||||
|
||||
class Output;
|
||||
|
||||
/// @addtogroup core
|
||||
/// @{
|
||||
|
||||
/// Represents a node in the computation graph.
|
||||
class Operation {
|
||||
public:
|
||||
Operation() : node_(nullptr) {}
|
||||
explicit Operation(Node* n);
|
||||
|
||||
int32 num_inputs() const { return node_->num_inputs(); }
|
||||
DataType input_type(int32 o) const { return node_->input_type(o); }
|
||||
Output input(int32 i) const;
|
||||
|
||||
int32 num_outputs() const { return node_->num_outputs(); }
|
||||
DataType output_type(int32 o) const { return node_->output_type(o); }
|
||||
Output output(int32 i) const;
|
||||
|
||||
Node* node() const { return node_; }
|
||||
|
||||
uint64 hash(int32 index) const;
|
||||
|
||||
bool operator==(const Operation& other) const { return node_ == other.node_; }
|
||||
|
||||
private:
|
||||
typedef std::vector<std::pair<Node*, int32>> Inputs;
|
||||
static Inputs GetInputs(Node* node);
|
||||
|
||||
Inputs inputs_;
|
||||
Node* node_;
|
||||
};
|
||||
|
||||
/// Represents a tensor value produced by an Operation.
|
||||
class Output {
|
||||
public:
|
||||
Output() = default;
|
||||
explicit Output(Node* n) : op_(n) {}
|
||||
Output(Node* n, int32 index) : op_(n), index_(index) {}
|
||||
Output(const Operation& op, int32 index) : op_(op), index_(index) {}
|
||||
|
||||
Operation op() const { return op_; }
|
||||
Node* node() const { return op().node(); }
|
||||
int32 index() const { return index_; }
|
||||
DataType type() const { return op_.output_type(index_); }
|
||||
string name() const { return strings::StrCat(node()->name(), ":", index()); }
|
||||
bool operator==(const Output& other) const {
|
||||
return op_ == other.op_ && index_ == other.index_;
|
||||
}
|
||||
|
||||
uint64 hash() const { return op_.hash(index_); }
|
||||
|
||||
private:
|
||||
Operation op_ = Operation(nullptr);
|
||||
int32 index_ = 0;
|
||||
};
|
||||
|
||||
/// Hash class that can be used for e.g. storing Outputs in an unordered_map
|
||||
struct OutputHash {
|
||||
std::size_t operator()(const Output& output) const {
|
||||
return Hash64Combine(std::hash<Node*>()(output.node()),
|
||||
std::hash<int32>()(output.index()));
|
||||
}
|
||||
};
|
||||
|
||||
/// Represents a tensor value that can be used as an operand to an Operation.
|
||||
class Input {
|
||||
public:
|
||||
/// Initializer enables constructing an Input object from various kinds of C++
|
||||
/// constants such as simple primitive constants and nested initializer lists
|
||||
/// representing a multi-dimensional array. Initializer constructors are all
|
||||
/// templates, so the aforementioned kinds of C++ constants can be used to
|
||||
/// construct an Initializer. Initializer stores the value it got constructed
|
||||
/// with in a Tensor object.
|
||||
struct Initializer {
|
||||
/// Construct from a scalar value of an arithmetic type or a type that can
|
||||
/// be converted to a string (eg. a string literal).
|
||||
template <typename T, typename = typename std::enable_if<
|
||||
std::is_arithmetic<T>::value ||
|
||||
std::is_convertible<T, string>::value>::type>
|
||||
Initializer(const T& v) { // NOLINT(runtime/explicit)
|
||||
typedef typename RealType<T>::type RealT;
|
||||
Tensor t(DataTypeToEnum<RealT>::v(), TensorShape());
|
||||
t.flat<T>()(0) = RealT(v);
|
||||
tensor = t;
|
||||
}
|
||||
|
||||
Initializer(const Tensor& t) : tensor(t) {} // NOLINT(runtime/explicit)
|
||||
|
||||
/// Construct from a scalar value and an explicit shape
|
||||
template <typename T, typename = typename std::enable_if<
|
||||
std::is_arithmetic<T>::value ||
|
||||
std::is_convertible<T, string>::value>::type>
|
||||
Initializer(const T& v, const TensorShape& shape) {
|
||||
typedef typename RealType<T>::type RealT;
|
||||
Tensor t(DataTypeToEnum<RealT>::v(), shape);
|
||||
for (int64 i = 0; i < t.NumElements(); ++i) {
|
||||
t.flat<T>()(i) = RealT(v);
|
||||
}
|
||||
tensor = t;
|
||||
}
|
||||
|
||||
/// Construct from a initializer list of scalars (a one-dimensional tensor).
|
||||
template <typename T, typename = typename std::enable_if<
|
||||
std::is_arithmetic<T>::value ||
|
||||
std::is_convertible<T, string>::value>::type>
|
||||
Initializer(
|
||||
const std::initializer_list<T>& v) { // NOLINT(runtime/explicit)
|
||||
typedef typename RealType<T>::type RealT;
|
||||
Tensor t(DataTypeToEnum<RealT>::v(),
|
||||
TensorShape{static_cast<int>(v.size())});
|
||||
std::copy_n(v.begin(), v.size(), t.flat<RealT>().data());
|
||||
tensor = t;
|
||||
}
|
||||
|
||||
/// Construct from a initializer list of scalars and an explicit shape.
|
||||
template <typename T, typename = typename std::enable_if<
|
||||
std::is_arithmetic<T>::value ||
|
||||
std::is_convertible<T, string>::value>::type>
|
||||
Initializer(const std::initializer_list<T>& v, const TensorShape& shape) {
|
||||
typedef typename RealType<T>::type RealT;
|
||||
Tensor t(DataTypeToEnum<RealT>::v(), shape);
|
||||
if (t.NumElements() != static_cast<int64>(v.size())) {
|
||||
status = errors::InvalidArgument(
|
||||
"Cannot construct a tensor with ", t.NumElements(),
|
||||
" from an initializer list with ", v.size(), " elements");
|
||||
return;
|
||||
}
|
||||
std::copy_n(v.begin(), v.size(), t.flat<RealT>().data());
|
||||
tensor = t;
|
||||
}
|
||||
|
||||
/// Construct a multi-dimensional tensor from a nested initializer
|
||||
/// list. Note that C++ syntax allows nesting of arbitrarily typed
|
||||
/// initializer lists, so such invalid initializers cannot be disallowed at
|
||||
/// compile time. This function performs checks to make sure that the nested
|
||||
/// initializer list is indeed a valid multi-dimensional tensor.
|
||||
Initializer(const std::initializer_list<Initializer>& v);
|
||||
|
||||
// START_SKIP_DOXYGEN
|
||||
template <typename T, bool = std::is_convertible<T, string>::value>
|
||||
struct RealType {
|
||||
typedef string type;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct RealType<T, false> {
|
||||
typedef T type;
|
||||
};
|
||||
// END_SKIP_DOXYGEN
|
||||
|
||||
TensorProto AsTensorProto() {
|
||||
TensorProto tensor_proto;
|
||||
if (tensor.NumElements() > 1) {
|
||||
tensor.AsProtoTensorContent(&tensor_proto);
|
||||
} else {
|
||||
tensor.AsProtoField(&tensor_proto);
|
||||
}
|
||||
return tensor_proto;
|
||||
}
|
||||
|
||||
Status status;
|
||||
Tensor tensor;
|
||||
};
|
||||
|
||||
/// All of Input's constructors are implicit. Input can be implicitly
|
||||
/// constructed from the following objects :
|
||||
/// * Output: This is so that the output of an Operation can be directly used
|
||||
/// as the input to a op wrapper, which takes Inputs.
|
||||
/// * A scalar, or a multi-dimensional tensor specified as a recursive
|
||||
/// initializer list. This enables directly passing constants as
|
||||
/// inputs to op wrappers.
|
||||
/// * A Tensor object.
|
||||
Input(const Output& o) : output_(o) {} // NOLINT(runtime/explicit)
|
||||
|
||||
template <typename T, typename = typename std::enable_if<
|
||||
std::is_arithmetic<T>::value ||
|
||||
std::is_convertible<T, string>::value>::type>
|
||||
Input(const T& v) // NOLINT(runtime/explicit)
|
||||
: Input(Initializer(v)) {}
|
||||
|
||||
Input(const Initializer& init) // NOLINT(runtime/explicit)
|
||||
: status_(init.status),
|
||||
tensor_(init.tensor) {}
|
||||
|
||||
Input(const Tensor& t) // NOLINT(runtime/explicit)
|
||||
: status_(Status::OK()),
|
||||
tensor_(t) {}
|
||||
|
||||
Input(const std::initializer_list<Initializer>&
|
||||
init) { // NOLINT(runtime/explicit)
|
||||
for (const auto& i : init) {
|
||||
if (!i.status.ok()) {
|
||||
status_ = i.status;
|
||||
return;
|
||||
}
|
||||
}
|
||||
tensor_ = Initializer(init).tensor;
|
||||
}
|
||||
|
||||
/// Constructor specifying a node name, index and datatype. This should only
|
||||
/// be used for specifying a backward edge, needed by control flow.
|
||||
Input(const string& name, int32 i, DataType dt)
|
||||
: node_name_(name), index_(i), data_type_(dt) {}
|
||||
|
||||
Node* node() const { return output_.node(); }
|
||||
string node_name() const { return node_name_; }
|
||||
int32 index() const { return node_name_.empty() ? output_.index() : index_; }
|
||||
DataType data_type() const { return data_type_; }
|
||||
Status status() const { return status_; }
|
||||
const Tensor& tensor() const { return tensor_; }
|
||||
|
||||
private:
|
||||
Status status_;
|
||||
Output output_ = Output(Operation(nullptr), 0);
|
||||
Tensor tensor_;
|
||||
const string node_name_ = "";
|
||||
int32 index_ = 0;
|
||||
DataType data_type_ = DT_INVALID;
|
||||
};
|
||||
|
||||
/// A type for representing the output of ops that produce more than one output,
|
||||
/// or a list of tensors.
|
||||
typedef std::vector<Output> OutputList;
|
||||
|
||||
/// A type for representing the input to ops that require a list of tensors.
|
||||
class InputList {
|
||||
public:
|
||||
/// Implicitly convert a list of outputs to a list of inputs. This is useful
|
||||
/// to write code such as ops::Concat(ops::Split(x, 4)).
|
||||
InputList(const OutputList& out) { // NOLINT(runtime/explicit)
|
||||
for (auto const& x : out) {
|
||||
inputs_.push_back(x);
|
||||
}
|
||||
}
|
||||
|
||||
InputList(
|
||||
const std::initializer_list<Input>& inputs) // NOLINT(runtime/explicit)
|
||||
: inputs_(inputs.begin(), inputs.end()) {}
|
||||
|
||||
InputList(const tensorflow::gtl::ArraySlice<Input>&
|
||||
inputs) // NOLINT(runtime/explicit)
|
||||
: inputs_(inputs.begin(), inputs.end()) {}
|
||||
|
||||
InputList(
|
||||
const std::initializer_list<Output>& out) { // NOLINT(runtime/explicit)
|
||||
for (auto const& x : out) {
|
||||
inputs_.push_back(x);
|
||||
}
|
||||
}
|
||||
|
||||
typename std::vector<Input>::iterator begin() { return inputs_.begin(); }
|
||||
typename std::vector<Input>::iterator end() { return inputs_.end(); }
|
||||
typename std::vector<Input>::const_iterator begin() const {
|
||||
return inputs_.begin();
|
||||
}
|
||||
typename std::vector<Input>::const_iterator end() const {
|
||||
return inputs_.end();
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<Input> inputs_;
|
||||
};
|
||||
|
||||
/// @}
|
||||
|
||||
} // namespace tensorflow
|
||||
|
||||
#endif // TENSORFLOW_CC_FRAMEWORK_OPS_H_
|
||||
@@ -0,0 +1,249 @@
|
||||
/* Copyright 2016 The TensorFlow Authors. All Rights Reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==============================================================================*/
|
||||
|
||||
#ifndef TENSORFLOW_CC_FRAMEWORK_SCOPE_H_
|
||||
#define TENSORFLOW_CC_FRAMEWORK_SCOPE_H_
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
#include "tensorflow/cc/framework/ops.h"
|
||||
#include "tensorflow/core/lib/core/status.h"
|
||||
#include "tensorflow/core/lib/gtl/array_slice.h"
|
||||
|
||||
namespace tensorflow {
|
||||
|
||||
class Graph;
|
||||
class GraphDef;
|
||||
class NodeBuilder;
|
||||
struct CompositeOpScopes;
|
||||
|
||||
/// @addtogroup core
|
||||
/// @{
|
||||
|
||||
/// A `Scope` object represents a set of related TensorFlow ops that have the
|
||||
/// same properties such as a common name prefix.
|
||||
///
|
||||
/// A Scope object is a container for TensorFlow Op properties. Op constructors
|
||||
/// get a Scope object as a mandatory first argument and the constructed op
|
||||
/// acquires the properties in the object.
|
||||
///
|
||||
/// A simple example:
|
||||
///
|
||||
/// using namespace ops;
|
||||
/// Scope root = Scope::NewRootScope();
|
||||
/// auto c1 = Const(root, { {1, 1} });
|
||||
/// auto m = MatMul(root, c1, { {41}, {1} });
|
||||
/// GraphDef gdef;
|
||||
/// Status s = root.ToGraphDef(&gdef);
|
||||
/// if (!s.ok()) { ... }
|
||||
///
|
||||
/// Scope hierarchy:
|
||||
///
|
||||
/// The Scope class provides various With<> functions that create a new scope.
|
||||
/// The new scope typically has one property changed while other properties are
|
||||
/// inherited from the parent scope.
|
||||
/// NewSubScope(name) method appends `name` to the prefix of names for ops
|
||||
/// created within the scope, and WithOpName() changes the suffix which
|
||||
/// otherwise defaults to the type of the op.
|
||||
///
|
||||
/// Name examples:
|
||||
///
|
||||
/// Scope root = Scope::NewRootScope();
|
||||
/// Scope linear = root.NewSubScope("linear");
|
||||
/// // W will be named "linear/W"
|
||||
/// auto W = Variable(linear.WithOpName("W"),
|
||||
/// {2, 2}, DT_FLOAT);
|
||||
/// // b will be named "linear/b"
|
||||
/// auto b = Variable(linear.WithOpName("b"),
|
||||
/// {2}, DT_FLOAT);
|
||||
/// auto x = Const(linear, {...}); // name: "linear/Const"
|
||||
/// auto m = MatMul(linear, x, W); // name: "linear/MatMul"
|
||||
/// auto r = BiasAdd(linear, m, b); // name: "linear/BiasAdd"
|
||||
///
|
||||
/// Scope lifetime:
|
||||
///
|
||||
/// A new scope is created by calling Scope::NewRootScope. This creates some
|
||||
/// resources that are shared by all the child scopes that inherit from this
|
||||
/// scope, directly or transitively. For instance, a new scope creates a new
|
||||
/// Graph object to which operations are added when the new scope or its
|
||||
/// children are used by an Op constructor. The new scope also has a Status
|
||||
/// object which will be used to indicate errors by Op-constructor functions
|
||||
/// called on any child scope. The Op-constructor functions have to check the
|
||||
/// scope's status by calling the ok() method before proceeding to construct the
|
||||
/// op.
|
||||
///
|
||||
/// Thread safety:
|
||||
///
|
||||
/// A `Scope` object is NOT thread-safe. Threads cannot concurrently call
|
||||
/// op-constructor functions on the same `Scope` object.
|
||||
class Scope {
|
||||
public:
|
||||
Scope(const Scope& other);
|
||||
~Scope();
|
||||
Scope& operator=(const Scope& other);
|
||||
|
||||
// The following functions are for users making graphs. They return brand new
|
||||
// scopes, or scopes derived from an existing scope object.
|
||||
|
||||
/// Return a new scope.
|
||||
/// This creates a new graph and all operations constructed in this graph
|
||||
/// should use the returned object as the "root" scope.
|
||||
static Scope NewRootScope();
|
||||
|
||||
/// Return a new scope. Ops created with this scope will have
|
||||
/// `name/child_scope_name` as the prefix. The actual name will be unique
|
||||
/// in the current scope. All other properties are inherited from the current
|
||||
/// scope. If `child_scope_name` is empty, the `/` is elided.
|
||||
Scope NewSubScope(const string& child_scope_name) const;
|
||||
|
||||
/// Return a new scope. All ops created within the returned scope will have
|
||||
/// names of the form `name/op_name[_suffix]`.
|
||||
Scope WithOpName(const string& op_name) const;
|
||||
|
||||
/// Return a new scope. All ops created within the returned scope will have as
|
||||
/// control dependencies the union of operations in the control_deps vector
|
||||
/// and the control dependencies of the current scope.
|
||||
Scope WithControlDependencies(
|
||||
const gtl::ArraySlice<Operation>& control_deps) const;
|
||||
/// Same as above, but convenient to add control dependency on the operation
|
||||
/// producing the control_dep output.
|
||||
Scope WithControlDependencies(const Output& control_dep) const;
|
||||
|
||||
/// Return a new scope. All ops created within the returned scope will have no
|
||||
/// control dependencies on other operations.
|
||||
Scope WithNoControlDependencies() const;
|
||||
|
||||
/// Return a new scope. All ops created within the returned scope will have
|
||||
/// the device field set to 'device'.
|
||||
Scope WithDevice(const string& device) const;
|
||||
|
||||
/// Returns a new scope. All ops created within the returned scope will have
|
||||
/// their assigned device set to `assigned_device`.
|
||||
Scope WithAssignedDevice(const string& assigned_device) const;
|
||||
|
||||
/// Return a new scope. All ops created within the returned scope will be
|
||||
/// co-located on the device where op is placed.
|
||||
/// NOTE: This function is intended to be use internal libraries only for
|
||||
/// controlling placement of ops on to devices. Public use is not encouraged
|
||||
/// because the implementation of device placement is subject to change.
|
||||
Scope ColocateWith(const Operation& op) const;
|
||||
/// Convenience function for above.
|
||||
Scope ColocateWith(const Output& out) const { return ColocateWith(out.op()); }
|
||||
/// Clear all colocation constraints.
|
||||
Scope ClearColocation() const;
|
||||
|
||||
/// Return a new scope. The op-constructor functions taking the returned scope
|
||||
/// as the scope argument will exit as soon as an error is detected, instead
|
||||
/// of setting the status on the scope.
|
||||
Scope ExitOnError() const;
|
||||
|
||||
/// Return a new scope. All ops created with the new scope will have
|
||||
/// kernel_label as the value for their '_kernel' attribute;
|
||||
Scope WithKernelLabel(const string& kernel_label) const;
|
||||
|
||||
// The following functions are for scope object consumers.
|
||||
|
||||
/// Return a unique name, using default_name if an op name has not been
|
||||
/// specified.
|
||||
string GetUniqueNameForOp(const string& default_name) const;
|
||||
|
||||
/// Update the status on this scope.
|
||||
/// Note: The status object is shared between all children of this scope.
|
||||
/// If the resulting status is not Status::OK() and exit_on_error_ is set on
|
||||
/// this scope, this function exits by calling LOG(FATAL).
|
||||
void UpdateStatus(const Status s) const;
|
||||
|
||||
// START_SKIP_DOXYGEN
|
||||
|
||||
/// Update the builder with properties accumulated in this scope. Does not set
|
||||
/// status().
|
||||
// TODO(skyewm): NodeBuilder is not part of public API
|
||||
void UpdateBuilder(NodeBuilder* builder) const;
|
||||
// END_SKIP_DOXYGEN
|
||||
|
||||
CompositeOpScopes GetCompositeOpScopes(const string& composite_op_name) const;
|
||||
|
||||
bool ok() const;
|
||||
|
||||
// TODO(skyewm): Graph is not part of public API
|
||||
Graph* graph() const;
|
||||
|
||||
// TODO(skyewm): Graph is not part of public API
|
||||
std::shared_ptr<Graph> graph_as_shared_ptr() const;
|
||||
|
||||
Status status() const;
|
||||
|
||||
/// If status() is Status::OK(), convert the Graph object stored in this scope
|
||||
/// to a GraphDef proto and return Status::OK(). Otherwise, return the error
|
||||
/// status as is without performing GraphDef conversion.
|
||||
Status ToGraphDef(GraphDef* gdef) const;
|
||||
|
||||
// START_SKIP_DOXYGEN
|
||||
|
||||
/// If status() is Status::OK(), construct a Graph object using the default
|
||||
/// GraphConstructorOptions, and return Status::OK if graph construction was
|
||||
/// successful. Otherwise, return the error status.
|
||||
// TODO(josh11b, keveman): Make this faster; right now it converts
|
||||
// Graph->GraphDef->Graph. This cleans up the graph (e.g. adds
|
||||
// edges from the source and to the sink node, resolves back edges
|
||||
// by name), and makes sure the resulting graph is valid.
|
||||
Status ToGraph(Graph* g) const;
|
||||
|
||||
// Calls AddNode() using this scope's ShapeRefiner. This exists in the public
|
||||
// API to prevent custom op wrappers from needing access to shape_refiner.h or
|
||||
// scope_internal.h.
|
||||
// TODO(skyewm): remove this from public API
|
||||
Status DoShapeInference(Node* node) const;
|
||||
|
||||
// Creates a new root scope that causes all DoShapeInference() calls to return
|
||||
// Status::OK() (on the returned scope and any subscopes). Used for testing.
|
||||
// TODO(skyewm): fix tests that still require this and eventually remove, or
|
||||
// at least remove from public API
|
||||
static Scope DisabledShapeInferenceScope();
|
||||
// END_SKIP_DOXYGEN
|
||||
|
||||
const std::vector<Operation>& control_deps() const;
|
||||
|
||||
// START_SKIP_DOXYGEN
|
||||
class Impl;
|
||||
Impl* impl() { return impl_.get(); }
|
||||
const Impl* impl() const { return impl_.get(); }
|
||||
// END_SKIP_DOXYGEN
|
||||
|
||||
private:
|
||||
friend class InternalScope;
|
||||
std::unique_ptr<Impl> impl_;
|
||||
explicit Scope(Impl*);
|
||||
};
|
||||
|
||||
/// A helper struct to hold the scopes that would be used by a function
|
||||
/// constructing a composite op.
|
||||
struct CompositeOpScopes {
|
||||
/// Scope to be used for creating the local ops (primitive or other composite
|
||||
/// ops).
|
||||
Scope child;
|
||||
/// Scope to be used for creating the last op.
|
||||
Scope last;
|
||||
};
|
||||
|
||||
/// @}
|
||||
|
||||
} // namespace tensorflow
|
||||
|
||||
#endif // TENSORFLOW_CC_FRAMEWORK_SCOPE_H_
|
||||
@@ -0,0 +1,124 @@
|
||||
/* Copyright 2016 The TensorFlow Authors. All Rights Reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==============================================================================*/
|
||||
|
||||
#ifndef TENSORFLOW_CC_FRAMEWORK_SCOPE_INTERNAL_H_
|
||||
#define TENSORFLOW_CC_FRAMEWORK_SCOPE_INTERNAL_H_
|
||||
|
||||
#include "tensorflow/cc/framework/scope.h"
|
||||
|
||||
namespace tensorflow {
|
||||
|
||||
class ShapeRefiner;
|
||||
|
||||
// NewInternalScope returns a new scope which doesn't take ownership of
|
||||
// graph, status, name_map, and refiner.
|
||||
// This is intended to enable the C API (which are used by other language
|
||||
// bindings) to create a Scope and access C++ functionality (i.e. gradients).
|
||||
//
|
||||
// Shape inference is disabled if `refiner` is nullptr.
|
||||
Scope NewInternalScope(Graph* graph, Status* status, ShapeRefiner* refiner);
|
||||
|
||||
class Scope::Impl {
|
||||
public:
|
||||
// A NameMap is used to keep track of suffixes for names used in a scope. A
|
||||
// name that has not been used so far in a scope will get no suffix. Later
|
||||
// uses of the same name will get suffixes _1, _2, _3, etc. Multiple scopes
|
||||
// can share the same NameMap. For instance, a new scope created using
|
||||
// WithControlDependencies() would share the same NameMap with the parent.
|
||||
typedef std::unordered_map<string, int> NameMap;
|
||||
|
||||
Impl(const std::shared_ptr<Graph>& graph,
|
||||
const std::shared_ptr<Status>& status,
|
||||
const std::shared_ptr<NameMap>& name_map,
|
||||
const std::shared_ptr<ShapeRefiner>& refiner);
|
||||
|
||||
const string& name() const { return name_; }
|
||||
const std::vector<Operation>& control_deps() const { return control_deps_; }
|
||||
|
||||
private:
|
||||
friend class Scope;
|
||||
|
||||
// Tag types to choose the constructor to dispatch.
|
||||
struct Tags {
|
||||
enum class ScopeName;
|
||||
enum class OpName;
|
||||
enum class ControlDeps;
|
||||
enum class Device;
|
||||
enum class SingleUseScope;
|
||||
enum class ExitOnError;
|
||||
enum class KernelLabel;
|
||||
enum class Colocate;
|
||||
enum class AssignedDevice;
|
||||
};
|
||||
|
||||
Impl(Graph* graph, Status* status, NameMap* name_map, ShapeRefiner* refiner,
|
||||
bool disable_shape_inference);
|
||||
Impl(const Scope& other, Tags::ScopeName, const string& name,
|
||||
bool copy_names);
|
||||
Impl(const Scope& other, Tags::OpName, const string& name,
|
||||
const string& op_name);
|
||||
Impl(const Scope& other, Tags::ControlDeps,
|
||||
std::vector<Operation> control_deps, bool clear_control_deps);
|
||||
Impl(const Scope& other, Tags::Device, const string& device);
|
||||
Impl(const Scope& other, Tags::SingleUseScope, const string& op_name);
|
||||
Impl(const Scope& other, Tags::ExitOnError);
|
||||
Impl(const Scope& other, Tags::KernelLabel, const string& kernel_label);
|
||||
Impl(const Scope& other, Tags::Colocate, const Operation& colocate_with_op,
|
||||
bool clear_colocations);
|
||||
Impl(const Scope& other, Tags::AssignedDevice, const string& assigned_device);
|
||||
|
||||
std::unordered_set<string> GetColocationConstraints(
|
||||
const Operation& colocate_with_op) const;
|
||||
|
||||
// Helper functions to get a unique names.
|
||||
string GetUniqueName(const string& prefix, bool check_single_use) const;
|
||||
string GetNameForOp(const string& default_name) const;
|
||||
|
||||
bool single_use_scope() const { return scope_used_ != nullptr; }
|
||||
|
||||
// The graph, status, and name maps are shared by all child scopes
|
||||
// created from a single 'root' scope. A root scope is created by calling the
|
||||
// Scope::NewRootScope function, which creates a new graph, a new status and
|
||||
// the name maps.
|
||||
std::shared_ptr<Graph> graph_ = nullptr;
|
||||
std::shared_ptr<Status> status_ = nullptr;
|
||||
std::shared_ptr<NameMap> name_map_ = nullptr;
|
||||
std::shared_ptr<ShapeRefiner> refiner_ = nullptr;
|
||||
|
||||
// If scope_used_ is not nullptr, op_name_ should be empty and
|
||||
// GetUniqueNameForOp can only be called once on this scope. More calls to
|
||||
// GetUniqueNameForOp will cause an error status to be set on this scope.
|
||||
std::shared_ptr<bool> scope_used_ = nullptr;
|
||||
|
||||
const std::vector<Operation> control_deps_;
|
||||
|
||||
// The fully-qualified name of this scope (i.e. includes any parent scope
|
||||
// names).
|
||||
const string name_ = "";
|
||||
const string op_name_ = "";
|
||||
const bool exit_on_error_ = false;
|
||||
const string kernel_label_ = "";
|
||||
const string device_ = "";
|
||||
const string assigned_device_ = "";
|
||||
const std::unordered_set<string> colocation_constraints_;
|
||||
|
||||
// If true, Scope::DoShapeInference() always returns Status:OK().
|
||||
// TODO(skyewm): remove this when possible
|
||||
const bool disable_shape_inference_;
|
||||
};
|
||||
|
||||
} // namespace tensorflow
|
||||
|
||||
#endif // TENSORFLOW_CC_FRAMEWORK_SCOPE_INTERNAL_H_
|
||||
@@ -0,0 +1,40 @@
|
||||
/* Copyright 2017 The TensorFlow Authors. All Rights Reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==============================================================================*/
|
||||
|
||||
#ifndef TENSORFLOW_CC_FRAMEWORK_WHILE_GRADIENTS_H_
|
||||
#define TENSORFLOW_CC_FRAMEWORK_WHILE_GRADIENTS_H_
|
||||
|
||||
#include "tensorflow/cc/framework/ops.h"
|
||||
#include "tensorflow/cc/framework/scope.h"
|
||||
#include "tensorflow/core/graph/while_context.h"
|
||||
|
||||
// Utility functions for constructing while loop gradients
|
||||
|
||||
namespace tensorflow {
|
||||
|
||||
// Adds the gradient computation for the while loop associated with
|
||||
// `while_ctx`. `grad_inputs` are the partial derivatives w.r.t. the loop
|
||||
// outputs, i.e. the exit nodes. The partial derivatives w.r.t. the loop
|
||||
// inputs, i.e. the input loop vars, are returned in `grad_outputs`.
|
||||
// `grad_inputs` and `grad_outputs` are both in loop-variable order, as defined
|
||||
// by the original inputs to BuildWhileLoop().
|
||||
// TODO(skyewm): maybe comment on NoGradient once it's supported
|
||||
Status AddWhileLoopGradient(WhileContext* while_ctx, const Scope& scope,
|
||||
const std::vector<Output>& grad_inputs,
|
||||
std::vector<Output>* grad_outputs);
|
||||
|
||||
} // namespace tensorflow
|
||||
|
||||
#endif // TENSORFLOW_CC_FRAMEWORK_WHILE_GRADIENTS_H_
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,226 @@
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#ifndef TENSORFLOW_CC_OPS_ARRAY_OPS_INTERNAL_H_
|
||||
#define TENSORFLOW_CC_OPS_ARRAY_OPS_INTERNAL_H_
|
||||
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#include "tensorflow/cc/framework/ops.h"
|
||||
#include "tensorflow/cc/framework/scope.h"
|
||||
#include "tensorflow/core/framework/tensor.h"
|
||||
#include "tensorflow/core/framework/tensor_shape.h"
|
||||
#include "tensorflow/core/framework/types.h"
|
||||
#include "tensorflow/core/lib/gtl/array_slice.h"
|
||||
|
||||
namespace tensorflow {
|
||||
namespace ops {
|
||||
namespace internal {
|
||||
// NOTE: This namespace has internal TensorFlow details that
|
||||
// are not part of TensorFlow's public API.
|
||||
|
||||
/// @defgroup array_ops_internal Array Ops Internal
|
||||
/// @{
|
||||
|
||||
/// Return the reduction indices for computing gradients of s0 op s1 with broadcast.
|
||||
///
|
||||
/// This is typically used by gradient computations for a broadcasting operation.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output` r0
|
||||
/// * `Output` r1
|
||||
class BroadcastGradientArgs {
|
||||
public:
|
||||
BroadcastGradientArgs(const ::tensorflow::Scope& scope, ::tensorflow::Input s0,
|
||||
::tensorflow::Input s1);
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output r0;
|
||||
::tensorflow::Output r1;
|
||||
};
|
||||
|
||||
/// Applies lower_bound(sorted_search_values, values) along each row.
|
||||
///
|
||||
/// Each set of rows with the same index in (sorted_inputs, values) is treated
|
||||
/// independently. The resulting row is the equivalent of calling
|
||||
/// `np.searchsorted(sorted_inputs, values, side='left')`.
|
||||
///
|
||||
/// The result is not a global index to the entire
|
||||
/// `Tensor`, but rather just the index in the last dimension.
|
||||
///
|
||||
/// A 2-D example:
|
||||
/// sorted_sequence = [[0, 3, 9, 9, 10],
|
||||
/// [1, 2, 3, 4, 5]]
|
||||
/// values = [[2, 4, 9],
|
||||
/// [0, 2, 6]]
|
||||
///
|
||||
/// result = LowerBound(sorted_sequence, values)
|
||||
///
|
||||
/// result == [[1, 2, 2],
|
||||
/// [0, 1, 5]]
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * sorted_inputs: 2-D Tensor where each row is ordered.
|
||||
/// * values: 2-D Tensor with the same numbers of rows as `sorted_search_values`. Contains
|
||||
/// the values that will be searched for in `sorted_search_values`.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: A `Tensor` with the same shape as `values`. It contains the first scalar index
|
||||
/// into the last dimension where values can be inserted without changing the
|
||||
/// ordered property.
|
||||
class LowerBound {
|
||||
public:
|
||||
/// Optional attribute setters for LowerBound
|
||||
struct Attrs {
|
||||
/// Defaults to DT_INT32
|
||||
TF_MUST_USE_RESULT Attrs OutType(DataType x) {
|
||||
Attrs ret = *this;
|
||||
ret.out_type_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
DataType out_type_ = DT_INT32;
|
||||
};
|
||||
LowerBound(const ::tensorflow::Scope& scope, ::tensorflow::Input sorted_inputs,
|
||||
::tensorflow::Input values);
|
||||
LowerBound(const ::tensorflow::Scope& scope, ::tensorflow::Input sorted_inputs,
|
||||
::tensorflow::Input values, const LowerBound::Attrs& attrs);
|
||||
operator ::tensorflow::Output() const { return output; }
|
||||
operator ::tensorflow::Input() const { return output; }
|
||||
::tensorflow::Node* node() const { return output.node(); }
|
||||
|
||||
static Attrs OutType(DataType x) {
|
||||
return Attrs().OutType(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output;
|
||||
};
|
||||
|
||||
/// Gradient op for `MirrorPad` op. This op folds a mirror-padded tensor.
|
||||
///
|
||||
/// This operation folds the padded areas of `input` by `MirrorPad` according to the
|
||||
/// `paddings` you specify. `paddings` must be the same as `paddings` argument
|
||||
/// given to the corresponding `MirrorPad` op.
|
||||
///
|
||||
/// The folded size of each dimension D of the output is:
|
||||
///
|
||||
/// `input.dim_size(D) - paddings(D, 0) - paddings(D, 1)`
|
||||
///
|
||||
/// For example:
|
||||
///
|
||||
/// ```
|
||||
/// # 't' is [[1, 2, 3], [4, 5, 6], [7, 8, 9]].
|
||||
/// # 'paddings' is [[0, 1]], [0, 1]].
|
||||
/// # 'mode' is SYMMETRIC.
|
||||
/// # rank of 't' is 2.
|
||||
/// pad(t, paddings) ==> [[ 1, 5]
|
||||
/// [11, 28]]
|
||||
/// ```
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * input: The input tensor to be folded.
|
||||
/// * paddings: A two-column matrix specifying the padding sizes. The number of
|
||||
/// rows must be the same as the rank of `input`.
|
||||
/// * mode: The mode used in the `MirrorPad` op.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: The folded tensor.
|
||||
class MirrorPadGrad {
|
||||
public:
|
||||
MirrorPadGrad(const ::tensorflow::Scope& scope, ::tensorflow::Input input,
|
||||
::tensorflow::Input paddings, StringPiece mode);
|
||||
operator ::tensorflow::Output() const { return output; }
|
||||
operator ::tensorflow::Input() const { return output; }
|
||||
::tensorflow::Node* node() const { return output.node(); }
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output;
|
||||
};
|
||||
|
||||
/// Return the same ref tensor as the input ref tensor.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: The output tensor.
|
||||
class RefIdentity {
|
||||
public:
|
||||
RefIdentity(const ::tensorflow::Scope& scope, ::tensorflow::Input input);
|
||||
operator ::tensorflow::Output() const { return output; }
|
||||
operator ::tensorflow::Input() const { return output; }
|
||||
::tensorflow::Node* node() const { return output.node(); }
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output;
|
||||
};
|
||||
|
||||
/// Applies upper_bound(sorted_search_values, values) along each row.
|
||||
///
|
||||
/// Each set of rows with the same index in (sorted_inputs, values) is treated
|
||||
/// independently. The resulting row is the equivalent of calling
|
||||
/// `np.searchsorted(sorted_inputs, values, side='right')`.
|
||||
///
|
||||
/// The result is not a global index to the entire
|
||||
/// `Tensor`, but rather just the index in the last dimension.
|
||||
///
|
||||
/// A 2-D example:
|
||||
/// sorted_sequence = [[0, 3, 9, 9, 10],
|
||||
/// [1, 2, 3, 4, 5]]
|
||||
/// values = [[2, 4, 9],
|
||||
/// [0, 2, 6]]
|
||||
///
|
||||
/// result = UpperBound(sorted_sequence, values)
|
||||
///
|
||||
/// result == [[1, 2, 4],
|
||||
/// [0, 2, 5]]
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * sorted_inputs: 2-D Tensor where each row is ordered.
|
||||
/// * values: 2-D Tensor with the same numbers of rows as `sorted_search_values`. Contains
|
||||
/// the values that will be searched for in `sorted_search_values`.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: A `Tensor` with the same shape as `values`. It contains the last scalar index
|
||||
/// into the last dimension where values can be inserted without changing the
|
||||
/// ordered property.
|
||||
class UpperBound {
|
||||
public:
|
||||
/// Optional attribute setters for UpperBound
|
||||
struct Attrs {
|
||||
/// Defaults to DT_INT32
|
||||
TF_MUST_USE_RESULT Attrs OutType(DataType x) {
|
||||
Attrs ret = *this;
|
||||
ret.out_type_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
DataType out_type_ = DT_INT32;
|
||||
};
|
||||
UpperBound(const ::tensorflow::Scope& scope, ::tensorflow::Input sorted_inputs,
|
||||
::tensorflow::Input values);
|
||||
UpperBound(const ::tensorflow::Scope& scope, ::tensorflow::Input sorted_inputs,
|
||||
::tensorflow::Input values, const UpperBound::Attrs& attrs);
|
||||
operator ::tensorflow::Output() const { return output; }
|
||||
operator ::tensorflow::Input() const { return output; }
|
||||
::tensorflow::Node* node() const { return output.node(); }
|
||||
|
||||
static Attrs OutType(DataType x) {
|
||||
return Attrs().OutType(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output;
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
} // namespace ops
|
||||
} // namespace tensorflow
|
||||
|
||||
#endif // TENSORFLOW_CC_OPS_ARRAY_OPS_INTERNAL_H_
|
||||
@@ -0,0 +1,295 @@
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#ifndef TENSORFLOW_CC_OPS_AUDIO_OPS_H_
|
||||
#define TENSORFLOW_CC_OPS_AUDIO_OPS_H_
|
||||
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#include "tensorflow/cc/framework/ops.h"
|
||||
#include "tensorflow/cc/framework/scope.h"
|
||||
#include "tensorflow/core/framework/tensor.h"
|
||||
#include "tensorflow/core/framework/tensor_shape.h"
|
||||
#include "tensorflow/core/framework/types.h"
|
||||
#include "tensorflow/core/lib/gtl/array_slice.h"
|
||||
|
||||
namespace tensorflow {
|
||||
namespace ops {
|
||||
|
||||
/// @defgroup audio_ops Audio Ops
|
||||
/// @{
|
||||
|
||||
/// Produces a visualization of audio data over time.
|
||||
///
|
||||
/// Spectrograms are a standard way of representing audio information as a series of
|
||||
/// slices of frequency information, one slice for each window of time. By joining
|
||||
/// these together into a sequence, they form a distinctive fingerprint of the sound
|
||||
/// over time.
|
||||
///
|
||||
/// This op expects to receive audio data as an input, stored as floats in the range
|
||||
/// -1 to 1, together with a window width in samples, and a stride specifying how
|
||||
/// far to move the window between slices. From this it generates a three
|
||||
/// dimensional output. The lowest dimension has an amplitude value for each
|
||||
/// frequency during that time slice. The next dimension is time, with successive
|
||||
/// frequency slices. The final dimension is for the channels in the input, so a
|
||||
/// stereo audio input would have two here for example.
|
||||
///
|
||||
/// This means the layout when converted and saved as an image is rotated 90 degrees
|
||||
/// clockwise from a typical spectrogram. Time is descending down the Y axis, and
|
||||
/// the frequency decreases from left to right.
|
||||
///
|
||||
/// Each value in the result represents the square root of the sum of the real and
|
||||
/// imaginary parts of an FFT on the current window of samples. In this way, the
|
||||
/// lowest dimension represents the power of each frequency in the current window,
|
||||
/// and adjacent windows are concatenated in the next dimension.
|
||||
///
|
||||
/// To get a more intuitive and visual look at what this operation does, you can run
|
||||
/// tensorflow/examples/wav_to_spectrogram to read in an audio file and save out the
|
||||
/// resulting spectrogram as a PNG image.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * input: Float representation of audio data.
|
||||
/// * window_size: How wide the input window is in samples. For the highest efficiency
|
||||
/// this should be a power of two, but other values are accepted.
|
||||
/// * stride: How widely apart the center of adjacent sample windows should be.
|
||||
///
|
||||
/// Optional attributes (see `Attrs`):
|
||||
/// * magnitude_squared: Whether to return the squared magnitude or just the
|
||||
/// magnitude. Using squared magnitude can avoid extra calculations.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: 3D representation of the audio frequencies as an image.
|
||||
class AudioSpectrogram {
|
||||
public:
|
||||
/// Optional attribute setters for AudioSpectrogram
|
||||
struct Attrs {
|
||||
/// Whether to return the squared magnitude or just the
|
||||
/// magnitude. Using squared magnitude can avoid extra calculations.
|
||||
///
|
||||
/// Defaults to false
|
||||
TF_MUST_USE_RESULT Attrs MagnitudeSquared(bool x) {
|
||||
Attrs ret = *this;
|
||||
ret.magnitude_squared_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool magnitude_squared_ = false;
|
||||
};
|
||||
AudioSpectrogram(const ::tensorflow::Scope& scope, ::tensorflow::Input input,
|
||||
int64 window_size, int64 stride);
|
||||
AudioSpectrogram(const ::tensorflow::Scope& scope, ::tensorflow::Input input,
|
||||
int64 window_size, int64 stride, const
|
||||
AudioSpectrogram::Attrs& attrs);
|
||||
operator ::tensorflow::Output() const { return spectrogram; }
|
||||
operator ::tensorflow::Input() const { return spectrogram; }
|
||||
::tensorflow::Node* node() const { return spectrogram.node(); }
|
||||
|
||||
static Attrs MagnitudeSquared(bool x) {
|
||||
return Attrs().MagnitudeSquared(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output spectrogram;
|
||||
};
|
||||
|
||||
/// Decode a 16-bit PCM WAV file to a float tensor.
|
||||
///
|
||||
/// The -32768 to 32767 signed 16-bit values will be scaled to -1.0 to 1.0 in float.
|
||||
///
|
||||
/// When desired_channels is set, if the input contains fewer channels than this
|
||||
/// then the last channel will be duplicated to give the requested number, else if
|
||||
/// the input has more channels than requested then the additional channels will be
|
||||
/// ignored.
|
||||
///
|
||||
/// If desired_samples is set, then the audio will be cropped or padded with zeroes
|
||||
/// to the requested length.
|
||||
///
|
||||
/// The first output contains a Tensor with the content of the audio samples. The
|
||||
/// lowest dimension will be the number of channels, and the second will be the
|
||||
/// number of samples. For example, a ten-sample-long stereo WAV file should give an
|
||||
/// output shape of [10, 2].
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * contents: The WAV-encoded audio, usually from a file.
|
||||
///
|
||||
/// Optional attributes (see `Attrs`):
|
||||
/// * desired_channels: Number of sample channels wanted.
|
||||
/// * desired_samples: Length of audio requested.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output` audio: 2-D with shape `[length, channels]`.
|
||||
/// * `Output` sample_rate: Scalar holding the sample rate found in the WAV header.
|
||||
class DecodeWav {
|
||||
public:
|
||||
/// Optional attribute setters for DecodeWav
|
||||
struct Attrs {
|
||||
/// Number of sample channels wanted.
|
||||
///
|
||||
/// Defaults to -1
|
||||
TF_MUST_USE_RESULT Attrs DesiredChannels(int64 x) {
|
||||
Attrs ret = *this;
|
||||
ret.desired_channels_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// Length of audio requested.
|
||||
///
|
||||
/// Defaults to -1
|
||||
TF_MUST_USE_RESULT Attrs DesiredSamples(int64 x) {
|
||||
Attrs ret = *this;
|
||||
ret.desired_samples_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int64 desired_channels_ = -1;
|
||||
int64 desired_samples_ = -1;
|
||||
};
|
||||
DecodeWav(const ::tensorflow::Scope& scope, ::tensorflow::Input contents);
|
||||
DecodeWav(const ::tensorflow::Scope& scope, ::tensorflow::Input contents, const
|
||||
DecodeWav::Attrs& attrs);
|
||||
|
||||
static Attrs DesiredChannels(int64 x) {
|
||||
return Attrs().DesiredChannels(x);
|
||||
}
|
||||
static Attrs DesiredSamples(int64 x) {
|
||||
return Attrs().DesiredSamples(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output audio;
|
||||
::tensorflow::Output sample_rate;
|
||||
};
|
||||
|
||||
/// Encode audio data using the WAV file format.
|
||||
///
|
||||
/// This operation will generate a string suitable to be saved out to create a .wav
|
||||
/// audio file. It will be encoded in the 16-bit PCM format. It takes in float
|
||||
/// values in the range -1.0f to 1.0f, and any outside that value will be clamped to
|
||||
/// that range.
|
||||
///
|
||||
/// `audio` is a 2-D float Tensor of shape `[length, channels]`.
|
||||
/// `sample_rate` is a scalar Tensor holding the rate to use (e.g. 44100).
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * audio: 2-D with shape `[length, channels]`.
|
||||
/// * sample_rate: Scalar containing the sample frequency.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: 0-D. WAV-encoded file contents.
|
||||
class EncodeWav {
|
||||
public:
|
||||
EncodeWav(const ::tensorflow::Scope& scope, ::tensorflow::Input audio,
|
||||
::tensorflow::Input sample_rate);
|
||||
operator ::tensorflow::Output() const { return contents; }
|
||||
operator ::tensorflow::Input() const { return contents; }
|
||||
::tensorflow::Node* node() const { return contents.node(); }
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output contents;
|
||||
};
|
||||
|
||||
/// Transforms a spectrogram into a form that's useful for speech recognition.
|
||||
///
|
||||
/// Mel Frequency Cepstral Coefficients are a way of representing audio data that's
|
||||
/// been effective as an input feature for machine learning. They are created by
|
||||
/// taking the spectrum of a spectrogram (a 'cepstrum'), and discarding some of the
|
||||
/// higher frequencies that are less significant to the human ear. They have a long
|
||||
/// history in the speech recognition world, and https://en.wikipedia.org/wiki/Mel-frequency_cepstrum
|
||||
/// is a good resource to learn more.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * spectrogram: Typically produced by the Spectrogram op, with magnitude_squared
|
||||
/// set to true.
|
||||
/// * sample_rate: How many samples per second the source audio used.
|
||||
///
|
||||
/// Optional attributes (see `Attrs`):
|
||||
/// * upper_frequency_limit: The highest frequency to use when calculating the
|
||||
/// ceptstrum.
|
||||
/// * lower_frequency_limit: The lowest frequency to use when calculating the
|
||||
/// ceptstrum.
|
||||
/// * filterbank_channel_count: Resolution of the Mel bank used internally.
|
||||
/// * dct_coefficient_count: How many output channels to produce per time slice.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: The output tensor.
|
||||
class Mfcc {
|
||||
public:
|
||||
/// Optional attribute setters for Mfcc
|
||||
struct Attrs {
|
||||
/// The highest frequency to use when calculating the
|
||||
/// ceptstrum.
|
||||
///
|
||||
/// Defaults to 4000
|
||||
TF_MUST_USE_RESULT Attrs UpperFrequencyLimit(float x) {
|
||||
Attrs ret = *this;
|
||||
ret.upper_frequency_limit_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// The lowest frequency to use when calculating the
|
||||
/// ceptstrum.
|
||||
///
|
||||
/// Defaults to 20
|
||||
TF_MUST_USE_RESULT Attrs LowerFrequencyLimit(float x) {
|
||||
Attrs ret = *this;
|
||||
ret.lower_frequency_limit_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// Resolution of the Mel bank used internally.
|
||||
///
|
||||
/// Defaults to 40
|
||||
TF_MUST_USE_RESULT Attrs FilterbankChannelCount(int64 x) {
|
||||
Attrs ret = *this;
|
||||
ret.filterbank_channel_count_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// How many output channels to produce per time slice.
|
||||
///
|
||||
/// Defaults to 13
|
||||
TF_MUST_USE_RESULT Attrs DctCoefficientCount(int64 x) {
|
||||
Attrs ret = *this;
|
||||
ret.dct_coefficient_count_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
float upper_frequency_limit_ = 4000.0f;
|
||||
float lower_frequency_limit_ = 20.0f;
|
||||
int64 filterbank_channel_count_ = 40;
|
||||
int64 dct_coefficient_count_ = 13;
|
||||
};
|
||||
Mfcc(const ::tensorflow::Scope& scope, ::tensorflow::Input spectrogram,
|
||||
::tensorflow::Input sample_rate);
|
||||
Mfcc(const ::tensorflow::Scope& scope, ::tensorflow::Input spectrogram,
|
||||
::tensorflow::Input sample_rate, const Mfcc::Attrs& attrs);
|
||||
operator ::tensorflow::Output() const { return output; }
|
||||
operator ::tensorflow::Input() const { return output; }
|
||||
::tensorflow::Node* node() const { return output.node(); }
|
||||
|
||||
static Attrs UpperFrequencyLimit(float x) {
|
||||
return Attrs().UpperFrequencyLimit(x);
|
||||
}
|
||||
static Attrs LowerFrequencyLimit(float x) {
|
||||
return Attrs().LowerFrequencyLimit(x);
|
||||
}
|
||||
static Attrs FilterbankChannelCount(int64 x) {
|
||||
return Attrs().FilterbankChannelCount(x);
|
||||
}
|
||||
static Attrs DctCoefficientCount(int64 x) {
|
||||
return Attrs().DctCoefficientCount(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output;
|
||||
};
|
||||
|
||||
/// @}
|
||||
|
||||
} // namespace ops
|
||||
} // namespace tensorflow
|
||||
|
||||
#endif // TENSORFLOW_CC_OPS_AUDIO_OPS_H_
|
||||
@@ -0,0 +1,28 @@
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#ifndef TENSORFLOW_CC_OPS_AUDIO_OPS_INTERNAL_H_
|
||||
#define TENSORFLOW_CC_OPS_AUDIO_OPS_INTERNAL_H_
|
||||
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#include "tensorflow/cc/framework/ops.h"
|
||||
#include "tensorflow/cc/framework/scope.h"
|
||||
#include "tensorflow/core/framework/tensor.h"
|
||||
#include "tensorflow/core/framework/tensor_shape.h"
|
||||
#include "tensorflow/core/framework/types.h"
|
||||
#include "tensorflow/core/lib/gtl/array_slice.h"
|
||||
|
||||
namespace tensorflow {
|
||||
namespace ops {
|
||||
namespace internal {
|
||||
// NOTE: This namespace has internal TensorFlow details that
|
||||
// are not part of TensorFlow's public API.
|
||||
|
||||
/// @defgroup audio_ops_internal Audio Ops Internal
|
||||
/// @{
|
||||
|
||||
} // namespace internal
|
||||
} // namespace ops
|
||||
} // namespace tensorflow
|
||||
|
||||
#endif // TENSORFLOW_CC_OPS_AUDIO_OPS_INTERNAL_H_
|
||||
@@ -0,0 +1,657 @@
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#ifndef TENSORFLOW_CC_OPS_CANDIDATE_SAMPLING_OPS_H_
|
||||
#define TENSORFLOW_CC_OPS_CANDIDATE_SAMPLING_OPS_H_
|
||||
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#include "tensorflow/cc/framework/ops.h"
|
||||
#include "tensorflow/cc/framework/scope.h"
|
||||
#include "tensorflow/core/framework/tensor.h"
|
||||
#include "tensorflow/core/framework/tensor_shape.h"
|
||||
#include "tensorflow/core/framework/types.h"
|
||||
#include "tensorflow/core/lib/gtl/array_slice.h"
|
||||
|
||||
namespace tensorflow {
|
||||
namespace ops {
|
||||
|
||||
/// @defgroup candidate_sampling_ops Candidate Sampling Ops
|
||||
/// @{
|
||||
|
||||
/// Generates labels for candidate sampling with a learned unigram distribution.
|
||||
///
|
||||
/// See explanations of candidate sampling and the data formats at
|
||||
/// go/candidate-sampling.
|
||||
///
|
||||
/// For each batch, this op picks a single set of sampled candidate labels.
|
||||
///
|
||||
/// The advantages of sampling candidates per-batch are simplicity and the
|
||||
/// possibility of efficient dense matrix multiplication. The disadvantage is that
|
||||
/// the sampled candidates must be chosen independently of the context and of the
|
||||
/// true labels.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * true_classes: A batch_size * num_true matrix, in which each row contains the
|
||||
/// IDs of the num_true target_classes in the corresponding original label.
|
||||
/// * num_true: Number of true labels per context.
|
||||
/// * num_sampled: Number of candidates to produce.
|
||||
/// * unique: If unique is true, we sample with rejection, so that all sampled
|
||||
/// candidates in a batch are unique. This requires some approximation to
|
||||
/// estimate the post-rejection sampling probabilities.
|
||||
///
|
||||
/// Optional attributes (see `Attrs`):
|
||||
/// * seed: If either seed or seed2 are set to be non-zero, the random number
|
||||
/// generator is seeded by the given seed. Otherwise, it is seeded by a
|
||||
/// random seed.
|
||||
/// * seed2: An second seed to avoid seed collision.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output` sampled_candidates: A vector of length num_sampled, in which each element is
|
||||
/// the ID of a sampled candidate.
|
||||
/// * `Output` true_expected_count: A batch_size * num_true matrix, representing
|
||||
/// the number of times each candidate is expected to occur in a batch
|
||||
/// of sampled candidates. If unique=true, then this is a probability.
|
||||
/// * `Output` sampled_expected_count: A vector of length num_sampled, for each sampled
|
||||
/// candidate representing the number of times the candidate is expected
|
||||
/// to occur in a batch of sampled candidates. If unique=true, then this is a
|
||||
/// probability.
|
||||
class AllCandidateSampler {
|
||||
public:
|
||||
/// Optional attribute setters for AllCandidateSampler
|
||||
struct Attrs {
|
||||
/// If either seed or seed2 are set to be non-zero, the random number
|
||||
/// generator is seeded by the given seed. Otherwise, it is seeded by a
|
||||
/// random seed.
|
||||
///
|
||||
/// Defaults to 0
|
||||
TF_MUST_USE_RESULT Attrs Seed(int64 x) {
|
||||
Attrs ret = *this;
|
||||
ret.seed_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// An second seed to avoid seed collision.
|
||||
///
|
||||
/// Defaults to 0
|
||||
TF_MUST_USE_RESULT Attrs Seed2(int64 x) {
|
||||
Attrs ret = *this;
|
||||
ret.seed2_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int64 seed_ = 0;
|
||||
int64 seed2_ = 0;
|
||||
};
|
||||
AllCandidateSampler(const ::tensorflow::Scope& scope, ::tensorflow::Input
|
||||
true_classes, int64 num_true, int64 num_sampled, bool
|
||||
unique);
|
||||
AllCandidateSampler(const ::tensorflow::Scope& scope, ::tensorflow::Input
|
||||
true_classes, int64 num_true, int64 num_sampled, bool
|
||||
unique, const AllCandidateSampler::Attrs& attrs);
|
||||
|
||||
static Attrs Seed(int64 x) {
|
||||
return Attrs().Seed(x);
|
||||
}
|
||||
static Attrs Seed2(int64 x) {
|
||||
return Attrs().Seed2(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output sampled_candidates;
|
||||
::tensorflow::Output true_expected_count;
|
||||
::tensorflow::Output sampled_expected_count;
|
||||
};
|
||||
|
||||
/// Computes the ids of the positions in sampled_candidates that match true_labels.
|
||||
///
|
||||
/// When doing log-odds NCE, the result of this op should be passed through a
|
||||
/// SparseToDense op, then added to the logits of the sampled candidates. This has
|
||||
/// the effect of 'removing' the sampled labels that match the true labels by
|
||||
/// making the classifier sure that they are sampled labels.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * true_classes: The true_classes output of UnpackSparseLabels.
|
||||
/// * sampled_candidates: The sampled_candidates output of CandidateSampler.
|
||||
/// * num_true: Number of true labels per context.
|
||||
///
|
||||
/// Optional attributes (see `Attrs`):
|
||||
/// * seed: If either seed or seed2 are set to be non-zero, the random number
|
||||
/// generator is seeded by the given seed. Otherwise, it is seeded by a
|
||||
/// random seed.
|
||||
/// * seed2: An second seed to avoid seed collision.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output` indices: A vector of indices corresponding to rows of true_candidates.
|
||||
/// * `Output` ids: A vector of IDs of positions in sampled_candidates that match a true_label
|
||||
/// for the row with the corresponding index in indices.
|
||||
/// * `Output` weights: A vector of the same length as indices and ids, in which each element
|
||||
/// is -FLOAT_MAX.
|
||||
class ComputeAccidentalHits {
|
||||
public:
|
||||
/// Optional attribute setters for ComputeAccidentalHits
|
||||
struct Attrs {
|
||||
/// If either seed or seed2 are set to be non-zero, the random number
|
||||
/// generator is seeded by the given seed. Otherwise, it is seeded by a
|
||||
/// random seed.
|
||||
///
|
||||
/// Defaults to 0
|
||||
TF_MUST_USE_RESULT Attrs Seed(int64 x) {
|
||||
Attrs ret = *this;
|
||||
ret.seed_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// An second seed to avoid seed collision.
|
||||
///
|
||||
/// Defaults to 0
|
||||
TF_MUST_USE_RESULT Attrs Seed2(int64 x) {
|
||||
Attrs ret = *this;
|
||||
ret.seed2_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int64 seed_ = 0;
|
||||
int64 seed2_ = 0;
|
||||
};
|
||||
ComputeAccidentalHits(const ::tensorflow::Scope& scope, ::tensorflow::Input
|
||||
true_classes, ::tensorflow::Input sampled_candidates,
|
||||
int64 num_true);
|
||||
ComputeAccidentalHits(const ::tensorflow::Scope& scope, ::tensorflow::Input
|
||||
true_classes, ::tensorflow::Input sampled_candidates,
|
||||
int64 num_true, const ComputeAccidentalHits::Attrs&
|
||||
attrs);
|
||||
|
||||
static Attrs Seed(int64 x) {
|
||||
return Attrs().Seed(x);
|
||||
}
|
||||
static Attrs Seed2(int64 x) {
|
||||
return Attrs().Seed2(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output indices;
|
||||
::tensorflow::Output ids;
|
||||
::tensorflow::Output weights;
|
||||
};
|
||||
|
||||
/// Generates labels for candidate sampling with a learned unigram distribution.
|
||||
///
|
||||
/// A unigram sampler could use a fixed unigram distribution read from a
|
||||
/// file or passed in as an in-memory array instead of building up the distribution
|
||||
/// from data on the fly. There is also an option to skew the distribution by
|
||||
/// applying a distortion power to the weights.
|
||||
///
|
||||
/// The vocabulary file should be in CSV-like format, with the last field
|
||||
/// being the weight associated with the word.
|
||||
///
|
||||
/// For each batch, this op picks a single set of sampled candidate labels.
|
||||
///
|
||||
/// The advantages of sampling candidates per-batch are simplicity and the
|
||||
/// possibility of efficient dense matrix multiplication. The disadvantage is that
|
||||
/// the sampled candidates must be chosen independently of the context and of the
|
||||
/// true labels.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * true_classes: A batch_size * num_true matrix, in which each row contains the
|
||||
/// IDs of the num_true target_classes in the corresponding original label.
|
||||
/// * num_true: Number of true labels per context.
|
||||
/// * num_sampled: Number of candidates to randomly sample.
|
||||
/// * unique: If unique is true, we sample with rejection, so that all sampled
|
||||
/// candidates in a batch are unique. This requires some approximation to
|
||||
/// estimate the post-rejection sampling probabilities.
|
||||
/// * range_max: The sampler will sample integers from the interval [0, range_max).
|
||||
///
|
||||
/// Optional attributes (see `Attrs`):
|
||||
/// * vocab_file: Each valid line in this file (which should have a CSV-like format)
|
||||
/// corresponds to a valid word ID. IDs are in sequential order, starting from
|
||||
/// num_reserved_ids. The last entry in each line is expected to be a value
|
||||
/// corresponding to the count or relative probability. Exactly one of vocab_file
|
||||
/// and unigrams needs to be passed to this op.
|
||||
/// * distortion: The distortion is used to skew the unigram probability distribution.
|
||||
/// Each weight is first raised to the distortion's power before adding to the
|
||||
/// internal unigram distribution. As a result, distortion = 1.0 gives regular
|
||||
/// unigram sampling (as defined by the vocab file), and distortion = 0.0 gives
|
||||
/// a uniform distribution.
|
||||
/// * num_reserved_ids: Optionally some reserved IDs can be added in the range [0,
|
||||
/// ..., num_reserved_ids) by the users. One use case is that a special unknown
|
||||
/// word token is used as ID 0. These IDs will have a sampling probability of 0.
|
||||
/// * num_shards: A sampler can be used to sample from a subset of the original range
|
||||
/// in order to speed up the whole computation through parallelism. This parameter
|
||||
/// (together with 'shard') indicates the number of partitions that are being
|
||||
/// used in the overall computation.
|
||||
/// * shard: A sampler can be used to sample from a subset of the original range
|
||||
/// in order to speed up the whole computation through parallelism. This parameter
|
||||
/// (together with 'num_shards') indicates the particular partition number of a
|
||||
/// sampler op, when partitioning is being used.
|
||||
/// * unigrams: A list of unigram counts or probabilities, one per ID in sequential
|
||||
/// order. Exactly one of vocab_file and unigrams should be passed to this op.
|
||||
/// * seed: If either seed or seed2 are set to be non-zero, the random number
|
||||
/// generator is seeded by the given seed. Otherwise, it is seeded by a
|
||||
/// random seed.
|
||||
/// * seed2: An second seed to avoid seed collision.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output` sampled_candidates: A vector of length num_sampled, in which each element is
|
||||
/// the ID of a sampled candidate.
|
||||
/// * `Output` true_expected_count: A batch_size * num_true matrix, representing
|
||||
/// the number of times each candidate is expected to occur in a batch
|
||||
/// of sampled candidates. If unique=true, then this is a probability.
|
||||
/// * `Output` sampled_expected_count: A vector of length num_sampled, for each sampled
|
||||
/// candidate representing the number of times the candidate is expected
|
||||
/// to occur in a batch of sampled candidates. If unique=true, then this is a
|
||||
/// probability.
|
||||
class FixedUnigramCandidateSampler {
|
||||
public:
|
||||
/// Optional attribute setters for FixedUnigramCandidateSampler
|
||||
struct Attrs {
|
||||
/// Each valid line in this file (which should have a CSV-like format)
|
||||
/// corresponds to a valid word ID. IDs are in sequential order, starting from
|
||||
/// num_reserved_ids. The last entry in each line is expected to be a value
|
||||
/// corresponding to the count or relative probability. Exactly one of vocab_file
|
||||
/// and unigrams needs to be passed to this op.
|
||||
///
|
||||
/// Defaults to ""
|
||||
TF_MUST_USE_RESULT Attrs VocabFile(StringPiece x) {
|
||||
Attrs ret = *this;
|
||||
ret.vocab_file_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// The distortion is used to skew the unigram probability distribution.
|
||||
/// Each weight is first raised to the distortion's power before adding to the
|
||||
/// internal unigram distribution. As a result, distortion = 1.0 gives regular
|
||||
/// unigram sampling (as defined by the vocab file), and distortion = 0.0 gives
|
||||
/// a uniform distribution.
|
||||
///
|
||||
/// Defaults to 1
|
||||
TF_MUST_USE_RESULT Attrs Distortion(float x) {
|
||||
Attrs ret = *this;
|
||||
ret.distortion_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// Optionally some reserved IDs can be added in the range [0,
|
||||
/// ..., num_reserved_ids) by the users. One use case is that a special unknown
|
||||
/// word token is used as ID 0. These IDs will have a sampling probability of 0.
|
||||
///
|
||||
/// Defaults to 0
|
||||
TF_MUST_USE_RESULT Attrs NumReservedIds(int64 x) {
|
||||
Attrs ret = *this;
|
||||
ret.num_reserved_ids_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// A sampler can be used to sample from a subset of the original range
|
||||
/// in order to speed up the whole computation through parallelism. This parameter
|
||||
/// (together with 'shard') indicates the number of partitions that are being
|
||||
/// used in the overall computation.
|
||||
///
|
||||
/// Defaults to 1
|
||||
TF_MUST_USE_RESULT Attrs NumShards(int64 x) {
|
||||
Attrs ret = *this;
|
||||
ret.num_shards_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// A sampler can be used to sample from a subset of the original range
|
||||
/// in order to speed up the whole computation through parallelism. This parameter
|
||||
/// (together with 'num_shards') indicates the particular partition number of a
|
||||
/// sampler op, when partitioning is being used.
|
||||
///
|
||||
/// Defaults to 0
|
||||
TF_MUST_USE_RESULT Attrs Shard(int64 x) {
|
||||
Attrs ret = *this;
|
||||
ret.shard_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// A list of unigram counts or probabilities, one per ID in sequential
|
||||
/// order. Exactly one of vocab_file and unigrams should be passed to this op.
|
||||
///
|
||||
/// Defaults to []
|
||||
TF_MUST_USE_RESULT Attrs Unigrams(const gtl::ArraySlice<float>& x) {
|
||||
Attrs ret = *this;
|
||||
ret.unigrams_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// If either seed or seed2 are set to be non-zero, the random number
|
||||
/// generator is seeded by the given seed. Otherwise, it is seeded by a
|
||||
/// random seed.
|
||||
///
|
||||
/// Defaults to 0
|
||||
TF_MUST_USE_RESULT Attrs Seed(int64 x) {
|
||||
Attrs ret = *this;
|
||||
ret.seed_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// An second seed to avoid seed collision.
|
||||
///
|
||||
/// Defaults to 0
|
||||
TF_MUST_USE_RESULT Attrs Seed2(int64 x) {
|
||||
Attrs ret = *this;
|
||||
ret.seed2_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
StringPiece vocab_file_ = "";
|
||||
float distortion_ = 1.0f;
|
||||
int64 num_reserved_ids_ = 0;
|
||||
int64 num_shards_ = 1;
|
||||
int64 shard_ = 0;
|
||||
gtl::ArraySlice<float> unigrams_ = {};
|
||||
int64 seed_ = 0;
|
||||
int64 seed2_ = 0;
|
||||
};
|
||||
FixedUnigramCandidateSampler(const ::tensorflow::Scope& scope,
|
||||
::tensorflow::Input true_classes, int64 num_true,
|
||||
int64 num_sampled, bool unique, int64 range_max);
|
||||
FixedUnigramCandidateSampler(const ::tensorflow::Scope& scope,
|
||||
::tensorflow::Input true_classes, int64 num_true,
|
||||
int64 num_sampled, bool unique, int64 range_max,
|
||||
const FixedUnigramCandidateSampler::Attrs& attrs);
|
||||
|
||||
static Attrs VocabFile(StringPiece x) {
|
||||
return Attrs().VocabFile(x);
|
||||
}
|
||||
static Attrs Distortion(float x) {
|
||||
return Attrs().Distortion(x);
|
||||
}
|
||||
static Attrs NumReservedIds(int64 x) {
|
||||
return Attrs().NumReservedIds(x);
|
||||
}
|
||||
static Attrs NumShards(int64 x) {
|
||||
return Attrs().NumShards(x);
|
||||
}
|
||||
static Attrs Shard(int64 x) {
|
||||
return Attrs().Shard(x);
|
||||
}
|
||||
static Attrs Unigrams(const gtl::ArraySlice<float>& x) {
|
||||
return Attrs().Unigrams(x);
|
||||
}
|
||||
static Attrs Seed(int64 x) {
|
||||
return Attrs().Seed(x);
|
||||
}
|
||||
static Attrs Seed2(int64 x) {
|
||||
return Attrs().Seed2(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output sampled_candidates;
|
||||
::tensorflow::Output true_expected_count;
|
||||
::tensorflow::Output sampled_expected_count;
|
||||
};
|
||||
|
||||
/// Generates labels for candidate sampling with a learned unigram distribution.
|
||||
///
|
||||
/// See explanations of candidate sampling and the data formats at
|
||||
/// go/candidate-sampling.
|
||||
///
|
||||
/// For each batch, this op picks a single set of sampled candidate labels.
|
||||
///
|
||||
/// The advantages of sampling candidates per-batch are simplicity and the
|
||||
/// possibility of efficient dense matrix multiplication. The disadvantage is that
|
||||
/// the sampled candidates must be chosen independently of the context and of the
|
||||
/// true labels.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * true_classes: A batch_size * num_true matrix, in which each row contains the
|
||||
/// IDs of the num_true target_classes in the corresponding original label.
|
||||
/// * num_true: Number of true labels per context.
|
||||
/// * num_sampled: Number of candidates to randomly sample.
|
||||
/// * unique: If unique is true, we sample with rejection, so that all sampled
|
||||
/// candidates in a batch are unique. This requires some approximation to
|
||||
/// estimate the post-rejection sampling probabilities.
|
||||
/// * range_max: The sampler will sample integers from the interval [0, range_max).
|
||||
///
|
||||
/// Optional attributes (see `Attrs`):
|
||||
/// * seed: If either seed or seed2 are set to be non-zero, the random number
|
||||
/// generator is seeded by the given seed. Otherwise, it is seeded by a
|
||||
/// random seed.
|
||||
/// * seed2: An second seed to avoid seed collision.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output` sampled_candidates: A vector of length num_sampled, in which each element is
|
||||
/// the ID of a sampled candidate.
|
||||
/// * `Output` true_expected_count: A batch_size * num_true matrix, representing
|
||||
/// the number of times each candidate is expected to occur in a batch
|
||||
/// of sampled candidates. If unique=true, then this is a probability.
|
||||
/// * `Output` sampled_expected_count: A vector of length num_sampled, for each sampled
|
||||
/// candidate representing the number of times the candidate is expected
|
||||
/// to occur in a batch of sampled candidates. If unique=true, then this is a
|
||||
/// probability.
|
||||
class LearnedUnigramCandidateSampler {
|
||||
public:
|
||||
/// Optional attribute setters for LearnedUnigramCandidateSampler
|
||||
struct Attrs {
|
||||
/// If either seed or seed2 are set to be non-zero, the random number
|
||||
/// generator is seeded by the given seed. Otherwise, it is seeded by a
|
||||
/// random seed.
|
||||
///
|
||||
/// Defaults to 0
|
||||
TF_MUST_USE_RESULT Attrs Seed(int64 x) {
|
||||
Attrs ret = *this;
|
||||
ret.seed_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// An second seed to avoid seed collision.
|
||||
///
|
||||
/// Defaults to 0
|
||||
TF_MUST_USE_RESULT Attrs Seed2(int64 x) {
|
||||
Attrs ret = *this;
|
||||
ret.seed2_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int64 seed_ = 0;
|
||||
int64 seed2_ = 0;
|
||||
};
|
||||
LearnedUnigramCandidateSampler(const ::tensorflow::Scope& scope,
|
||||
::tensorflow::Input true_classes, int64
|
||||
num_true, int64 num_sampled, bool unique, int64
|
||||
range_max);
|
||||
LearnedUnigramCandidateSampler(const ::tensorflow::Scope& scope,
|
||||
::tensorflow::Input true_classes, int64
|
||||
num_true, int64 num_sampled, bool unique, int64
|
||||
range_max, const
|
||||
LearnedUnigramCandidateSampler::Attrs& attrs);
|
||||
|
||||
static Attrs Seed(int64 x) {
|
||||
return Attrs().Seed(x);
|
||||
}
|
||||
static Attrs Seed2(int64 x) {
|
||||
return Attrs().Seed2(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output sampled_candidates;
|
||||
::tensorflow::Output true_expected_count;
|
||||
::tensorflow::Output sampled_expected_count;
|
||||
};
|
||||
|
||||
/// Generates labels for candidate sampling with a log-uniform distribution.
|
||||
///
|
||||
/// See explanations of candidate sampling and the data formats at
|
||||
/// go/candidate-sampling.
|
||||
///
|
||||
/// For each batch, this op picks a single set of sampled candidate labels.
|
||||
///
|
||||
/// The advantages of sampling candidates per-batch are simplicity and the
|
||||
/// possibility of efficient dense matrix multiplication. The disadvantage is that
|
||||
/// the sampled candidates must be chosen independently of the context and of the
|
||||
/// true labels.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * true_classes: A batch_size * num_true matrix, in which each row contains the
|
||||
/// IDs of the num_true target_classes in the corresponding original label.
|
||||
/// * num_true: Number of true labels per context.
|
||||
/// * num_sampled: Number of candidates to randomly sample.
|
||||
/// * unique: If unique is true, we sample with rejection, so that all sampled
|
||||
/// candidates in a batch are unique. This requires some approximation to
|
||||
/// estimate the post-rejection sampling probabilities.
|
||||
/// * range_max: The sampler will sample integers from the interval [0, range_max).
|
||||
///
|
||||
/// Optional attributes (see `Attrs`):
|
||||
/// * seed: If either seed or seed2 are set to be non-zero, the random number
|
||||
/// generator is seeded by the given seed. Otherwise, it is seeded by a
|
||||
/// random seed.
|
||||
/// * seed2: An second seed to avoid seed collision.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output` sampled_candidates: A vector of length num_sampled, in which each element is
|
||||
/// the ID of a sampled candidate.
|
||||
/// * `Output` true_expected_count: A batch_size * num_true matrix, representing
|
||||
/// the number of times each candidate is expected to occur in a batch
|
||||
/// of sampled candidates. If unique=true, then this is a probability.
|
||||
/// * `Output` sampled_expected_count: A vector of length num_sampled, for each sampled
|
||||
/// candidate representing the number of times the candidate is expected
|
||||
/// to occur in a batch of sampled candidates. If unique=true, then this is a
|
||||
/// probability.
|
||||
class LogUniformCandidateSampler {
|
||||
public:
|
||||
/// Optional attribute setters for LogUniformCandidateSampler
|
||||
struct Attrs {
|
||||
/// If either seed or seed2 are set to be non-zero, the random number
|
||||
/// generator is seeded by the given seed. Otherwise, it is seeded by a
|
||||
/// random seed.
|
||||
///
|
||||
/// Defaults to 0
|
||||
TF_MUST_USE_RESULT Attrs Seed(int64 x) {
|
||||
Attrs ret = *this;
|
||||
ret.seed_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// An second seed to avoid seed collision.
|
||||
///
|
||||
/// Defaults to 0
|
||||
TF_MUST_USE_RESULT Attrs Seed2(int64 x) {
|
||||
Attrs ret = *this;
|
||||
ret.seed2_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int64 seed_ = 0;
|
||||
int64 seed2_ = 0;
|
||||
};
|
||||
LogUniformCandidateSampler(const ::tensorflow::Scope& scope,
|
||||
::tensorflow::Input true_classes, int64 num_true,
|
||||
int64 num_sampled, bool unique, int64 range_max);
|
||||
LogUniformCandidateSampler(const ::tensorflow::Scope& scope,
|
||||
::tensorflow::Input true_classes, int64 num_true,
|
||||
int64 num_sampled, bool unique, int64 range_max,
|
||||
const LogUniformCandidateSampler::Attrs& attrs);
|
||||
|
||||
static Attrs Seed(int64 x) {
|
||||
return Attrs().Seed(x);
|
||||
}
|
||||
static Attrs Seed2(int64 x) {
|
||||
return Attrs().Seed2(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output sampled_candidates;
|
||||
::tensorflow::Output true_expected_count;
|
||||
::tensorflow::Output sampled_expected_count;
|
||||
};
|
||||
|
||||
/// Generates labels for candidate sampling with a uniform distribution.
|
||||
///
|
||||
/// See explanations of candidate sampling and the data formats at
|
||||
/// go/candidate-sampling.
|
||||
///
|
||||
/// For each batch, this op picks a single set of sampled candidate labels.
|
||||
///
|
||||
/// The advantages of sampling candidates per-batch are simplicity and the
|
||||
/// possibility of efficient dense matrix multiplication. The disadvantage is that
|
||||
/// the sampled candidates must be chosen independently of the context and of the
|
||||
/// true labels.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * true_classes: A batch_size * num_true matrix, in which each row contains the
|
||||
/// IDs of the num_true target_classes in the corresponding original label.
|
||||
/// * num_true: Number of true labels per context.
|
||||
/// * num_sampled: Number of candidates to randomly sample.
|
||||
/// * unique: If unique is true, we sample with rejection, so that all sampled
|
||||
/// candidates in a batch are unique. This requires some approximation to
|
||||
/// estimate the post-rejection sampling probabilities.
|
||||
/// * range_max: The sampler will sample integers from the interval [0, range_max).
|
||||
///
|
||||
/// Optional attributes (see `Attrs`):
|
||||
/// * seed: If either seed or seed2 are set to be non-zero, the random number
|
||||
/// generator is seeded by the given seed. Otherwise, it is seeded by a
|
||||
/// random seed.
|
||||
/// * seed2: An second seed to avoid seed collision.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output` sampled_candidates: A vector of length num_sampled, in which each element is
|
||||
/// the ID of a sampled candidate.
|
||||
/// * `Output` true_expected_count: A batch_size * num_true matrix, representing
|
||||
/// the number of times each candidate is expected to occur in a batch
|
||||
/// of sampled candidates. If unique=true, then this is a probability.
|
||||
/// * `Output` sampled_expected_count: A vector of length num_sampled, for each sampled
|
||||
/// candidate representing the number of times the candidate is expected
|
||||
/// to occur in a batch of sampled candidates. If unique=true, then this is a
|
||||
/// probability.
|
||||
class UniformCandidateSampler {
|
||||
public:
|
||||
/// Optional attribute setters for UniformCandidateSampler
|
||||
struct Attrs {
|
||||
/// If either seed or seed2 are set to be non-zero, the random number
|
||||
/// generator is seeded by the given seed. Otherwise, it is seeded by a
|
||||
/// random seed.
|
||||
///
|
||||
/// Defaults to 0
|
||||
TF_MUST_USE_RESULT Attrs Seed(int64 x) {
|
||||
Attrs ret = *this;
|
||||
ret.seed_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// An second seed to avoid seed collision.
|
||||
///
|
||||
/// Defaults to 0
|
||||
TF_MUST_USE_RESULT Attrs Seed2(int64 x) {
|
||||
Attrs ret = *this;
|
||||
ret.seed2_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int64 seed_ = 0;
|
||||
int64 seed2_ = 0;
|
||||
};
|
||||
UniformCandidateSampler(const ::tensorflow::Scope& scope, ::tensorflow::Input
|
||||
true_classes, int64 num_true, int64 num_sampled, bool
|
||||
unique, int64 range_max);
|
||||
UniformCandidateSampler(const ::tensorflow::Scope& scope, ::tensorflow::Input
|
||||
true_classes, int64 num_true, int64 num_sampled, bool
|
||||
unique, int64 range_max, const
|
||||
UniformCandidateSampler::Attrs& attrs);
|
||||
|
||||
static Attrs Seed(int64 x) {
|
||||
return Attrs().Seed(x);
|
||||
}
|
||||
static Attrs Seed2(int64 x) {
|
||||
return Attrs().Seed2(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output sampled_candidates;
|
||||
::tensorflow::Output true_expected_count;
|
||||
::tensorflow::Output sampled_expected_count;
|
||||
};
|
||||
|
||||
/// @}
|
||||
|
||||
} // namespace ops
|
||||
} // namespace tensorflow
|
||||
|
||||
#endif // TENSORFLOW_CC_OPS_CANDIDATE_SAMPLING_OPS_H_
|
||||
@@ -0,0 +1,28 @@
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#ifndef TENSORFLOW_CC_OPS_CANDIDATE_SAMPLING_OPS_INTERNAL_H_
|
||||
#define TENSORFLOW_CC_OPS_CANDIDATE_SAMPLING_OPS_INTERNAL_H_
|
||||
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#include "tensorflow/cc/framework/ops.h"
|
||||
#include "tensorflow/cc/framework/scope.h"
|
||||
#include "tensorflow/core/framework/tensor.h"
|
||||
#include "tensorflow/core/framework/tensor_shape.h"
|
||||
#include "tensorflow/core/framework/types.h"
|
||||
#include "tensorflow/core/lib/gtl/array_slice.h"
|
||||
|
||||
namespace tensorflow {
|
||||
namespace ops {
|
||||
namespace internal {
|
||||
// NOTE: This namespace has internal TensorFlow details that
|
||||
// are not part of TensorFlow's public API.
|
||||
|
||||
/// @defgroup candidate_sampling_ops_internal Candidate Sampling Ops Internal
|
||||
/// @{
|
||||
|
||||
} // namespace internal
|
||||
} // namespace ops
|
||||
} // namespace tensorflow
|
||||
|
||||
#endif // TENSORFLOW_CC_OPS_CANDIDATE_SAMPLING_OPS_INTERNAL_H_
|
||||
@@ -0,0 +1,85 @@
|
||||
/* Copyright 2016 The TensorFlow Authors. All Rights Reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==============================================================================*/
|
||||
|
||||
#ifndef TENSORFLOW_CC_OPS_CONST_OP_H_
|
||||
#define TENSORFLOW_CC_OPS_CONST_OP_H_
|
||||
|
||||
#include "tensorflow/cc/framework/ops.h"
|
||||
#include "tensorflow/cc/framework/scope.h"
|
||||
#include "tensorflow/core/graph/node_builder.h"
|
||||
|
||||
namespace tensorflow {
|
||||
namespace ops {
|
||||
|
||||
/// @defgroup const_op Const Op
|
||||
/// @{
|
||||
|
||||
Output Const(const Scope& scope, const Input::Initializer& val);
|
||||
|
||||
Output ConstFromProto(const Scope& scope, const TensorProto& proto);
|
||||
|
||||
NodeBuilder::NodeOut AsNodeOut(const Scope& scope, const Input& inp);
|
||||
|
||||
template <typename T>
|
||||
Output Const(const Scope& scope, const Input::Initializer& val) {
|
||||
auto orig_const_output = Const(scope, val);
|
||||
if (!scope.ok()) return Output();
|
||||
|
||||
typedef typename Input::Initializer::RealType<T>::type DstT;
|
||||
|
||||
if (val.tensor.dtype() == DataTypeToEnum<DstT>::v()) {
|
||||
return orig_const_output;
|
||||
}
|
||||
if (val.tensor.NumElements() == 0) {
|
||||
Tensor t(DataTypeToEnum<DstT>::v(), val.tensor.shape());
|
||||
return Const(scope, Input::Initializer(t));
|
||||
}
|
||||
|
||||
// TODO(keveman): Refactor Cast op's kernel implementation such that the code
|
||||
// can be directly called here instead of adding the Cast op to the graph.
|
||||
auto orig_const = AsNodeOut(scope, orig_const_output);
|
||||
const auto cast_op_name = scope.GetUniqueNameForOp("Cast");
|
||||
|
||||
auto cast_builder = NodeBuilder(cast_op_name, "Cast")
|
||||
.Input(orig_const)
|
||||
.Attr("DstT", DataTypeToEnum<DstT>::v());
|
||||
scope.UpdateBuilder(&cast_builder);
|
||||
Node* ret;
|
||||
scope.UpdateStatus(cast_builder.Finalize(scope.graph(), &ret));
|
||||
if (!scope.ok()) return Output();
|
||||
scope.UpdateStatus(scope.DoShapeInference(ret));
|
||||
return Output(ret, 0);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Output Const(const Scope& scope, const T& v, const TensorShape shape) {
|
||||
return Const(scope, Input::Initializer(v, shape));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Output Const(const Scope& scope, const std::initializer_list<T>& v,
|
||||
const TensorShape shape) {
|
||||
return Const(scope, Input::Initializer(v, shape));
|
||||
}
|
||||
|
||||
std::vector<NodeBuilder::NodeOut> AsNodeOutList(const Scope& scope,
|
||||
const InputList& inp);
|
||||
|
||||
/// }@
|
||||
|
||||
} // namespace ops
|
||||
} // namespace tensorflow
|
||||
|
||||
#endif // TENSORFLOW_CC_OPS_CONST_OP_H_
|
||||
@@ -0,0 +1,250 @@
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#ifndef TENSORFLOW_CC_OPS_CONTROL_FLOW_OPS_H_
|
||||
#define TENSORFLOW_CC_OPS_CONTROL_FLOW_OPS_H_
|
||||
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#include "tensorflow/cc/framework/ops.h"
|
||||
#include "tensorflow/cc/framework/scope.h"
|
||||
#include "tensorflow/core/framework/tensor.h"
|
||||
#include "tensorflow/core/framework/tensor_shape.h"
|
||||
#include "tensorflow/core/framework/types.h"
|
||||
#include "tensorflow/core/lib/gtl/array_slice.h"
|
||||
|
||||
namespace tensorflow {
|
||||
namespace ops {
|
||||
|
||||
/// @defgroup control_flow_ops Control Flow Ops
|
||||
/// @{
|
||||
|
||||
/// Raise a exception to abort the process when called.
|
||||
///
|
||||
/// If exit_without_error is true, the process will exit normally,
|
||||
/// otherwise it will exit with a SIGABORT signal.
|
||||
///
|
||||
/// Returns nothing but an exception.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
///
|
||||
/// Optional attributes (see `Attrs`):
|
||||
/// * error_msg: A string which is the message associated with the exception.
|
||||
///
|
||||
/// Returns:
|
||||
/// * the created `Operation`
|
||||
class Abort {
|
||||
public:
|
||||
/// Optional attribute setters for Abort
|
||||
struct Attrs {
|
||||
/// A string which is the message associated with the exception.
|
||||
///
|
||||
/// Defaults to ""
|
||||
TF_MUST_USE_RESULT Attrs ErrorMsg(StringPiece x) {
|
||||
Attrs ret = *this;
|
||||
ret.error_msg_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// Defaults to false
|
||||
TF_MUST_USE_RESULT Attrs ExitWithoutError(bool x) {
|
||||
Attrs ret = *this;
|
||||
ret.exit_without_error_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
StringPiece error_msg_ = "";
|
||||
bool exit_without_error_ = false;
|
||||
};
|
||||
Abort(const ::tensorflow::Scope& scope);
|
||||
Abort(const ::tensorflow::Scope& scope, const Abort::Attrs& attrs);
|
||||
operator ::tensorflow::Operation() const { return operation; }
|
||||
|
||||
static Attrs ErrorMsg(StringPiece x) {
|
||||
return Attrs().ErrorMsg(x);
|
||||
}
|
||||
static Attrs ExitWithoutError(bool x) {
|
||||
return Attrs().ExitWithoutError(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
};
|
||||
|
||||
/// Does nothing. Serves as a control trigger for scheduling.
|
||||
///
|
||||
/// Only useful as a placeholder for control edges.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
///
|
||||
/// Returns:
|
||||
/// * the created `Operation`
|
||||
class ControlTrigger {
|
||||
public:
|
||||
ControlTrigger(const ::tensorflow::Scope& scope);
|
||||
operator ::tensorflow::Operation() const { return operation; }
|
||||
|
||||
Operation operation;
|
||||
};
|
||||
|
||||
/// Forwards the input to the output.
|
||||
///
|
||||
/// This operator represents the loop termination condition used by the
|
||||
/// "pivot" switches of a loop.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * input: A boolean scalar, representing the branch predicate of the Switch op.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: The same tensor as `input`.
|
||||
class LoopCond {
|
||||
public:
|
||||
LoopCond(const ::tensorflow::Scope& scope, ::tensorflow::Input input);
|
||||
operator ::tensorflow::Output() const { return output; }
|
||||
operator ::tensorflow::Input() const { return output; }
|
||||
::tensorflow::Node* node() const { return output.node(); }
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output;
|
||||
};
|
||||
|
||||
/// Forwards the value of an available tensor from `inputs` to `output`.
|
||||
///
|
||||
/// `Merge` waits for at least one of the tensors in `inputs` to become available.
|
||||
/// It is usually combined with `Switch` to implement branching.
|
||||
///
|
||||
/// `Merge` forwards the first tensor to become available to `output`, and sets
|
||||
/// `value_index` to its index in `inputs`.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * inputs: The input tensors, exactly one of which will become available.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output` output: Will be set to the available input tensor.
|
||||
/// * `Output` value_index: The index of the chosen input tensor in `inputs`.
|
||||
class Merge {
|
||||
public:
|
||||
Merge(const ::tensorflow::Scope& scope, ::tensorflow::InputList inputs);
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output;
|
||||
::tensorflow::Output value_index;
|
||||
};
|
||||
|
||||
/// Makes its input available to the next iteration.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * data: The tensor to be made available to the next iteration.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: The same tensor as `data`.
|
||||
class NextIteration {
|
||||
public:
|
||||
NextIteration(const ::tensorflow::Scope& scope, ::tensorflow::Input data);
|
||||
operator ::tensorflow::Output() const { return output; }
|
||||
operator ::tensorflow::Input() const { return output; }
|
||||
::tensorflow::Node* node() const { return output.node(); }
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output;
|
||||
};
|
||||
|
||||
/// Makes its input available to the next iteration.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * data: The tensor to be made available to the next iteration.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: The same tensor as `data`.
|
||||
class RefNextIteration {
|
||||
public:
|
||||
RefNextIteration(const ::tensorflow::Scope& scope, ::tensorflow::Input data);
|
||||
operator ::tensorflow::Output() const { return output; }
|
||||
operator ::tensorflow::Input() const { return output; }
|
||||
::tensorflow::Node* node() const { return output.node(); }
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output;
|
||||
};
|
||||
|
||||
/// Forwards the `index`th element of `inputs` to `output`.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * index: A scalar that determines the input that gets selected.
|
||||
/// * inputs: A list of ref tensors, one of which will be forwarded to `output`.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: The forwarded tensor.
|
||||
class RefSelect {
|
||||
public:
|
||||
RefSelect(const ::tensorflow::Scope& scope, ::tensorflow::Input index,
|
||||
::tensorflow::InputList inputs);
|
||||
operator ::tensorflow::Output() const { return output; }
|
||||
operator ::tensorflow::Input() const { return output; }
|
||||
::tensorflow::Node* node() const { return output.node(); }
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output;
|
||||
};
|
||||
|
||||
/// Forwards the ref tensor `data` to the output port determined by `pred`.
|
||||
///
|
||||
/// If `pred` is true, the `data` input is forwarded to `output_true`. Otherwise,
|
||||
/// the data goes to `output_false`.
|
||||
///
|
||||
/// See also `Switch` and `Merge`.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * data: The ref tensor to be forwarded to the appropriate output.
|
||||
/// * pred: A scalar that specifies which output port will receive data.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output` output_false: If `pred` is false, data will be forwarded to this output.
|
||||
/// * `Output` output_true: If `pred` is true, data will be forwarded to this output.
|
||||
class RefSwitch {
|
||||
public:
|
||||
RefSwitch(const ::tensorflow::Scope& scope, ::tensorflow::Input data,
|
||||
::tensorflow::Input pred);
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output_false;
|
||||
::tensorflow::Output output_true;
|
||||
};
|
||||
|
||||
/// Forwards `data` to the output port determined by `pred`.
|
||||
///
|
||||
/// If `pred` is true, the `data` input is forwarded to `output_true`. Otherwise,
|
||||
/// the data goes to `output_false`.
|
||||
///
|
||||
/// See also `RefSwitch` and `Merge`.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * data: The tensor to be forwarded to the appropriate output.
|
||||
/// * pred: A scalar that specifies which output port will receive data.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output` output_false: If `pred` is false, data will be forwarded to this output.
|
||||
/// * `Output` output_true: If `pred` is true, data will be forwarded to this output.
|
||||
class Switch {
|
||||
public:
|
||||
Switch(const ::tensorflow::Scope& scope, ::tensorflow::Input data,
|
||||
::tensorflow::Input pred);
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output_false;
|
||||
::tensorflow::Output output_true;
|
||||
};
|
||||
|
||||
/// @}
|
||||
|
||||
} // namespace ops
|
||||
} // namespace tensorflow
|
||||
|
||||
#endif // TENSORFLOW_CC_OPS_CONTROL_FLOW_OPS_H_
|
||||
@@ -0,0 +1,219 @@
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#ifndef TENSORFLOW_CC_OPS_CONTROL_FLOW_OPS_INTERNAL_H_
|
||||
#define TENSORFLOW_CC_OPS_CONTROL_FLOW_OPS_INTERNAL_H_
|
||||
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#include "tensorflow/cc/framework/ops.h"
|
||||
#include "tensorflow/cc/framework/scope.h"
|
||||
#include "tensorflow/core/framework/tensor.h"
|
||||
#include "tensorflow/core/framework/tensor_shape.h"
|
||||
#include "tensorflow/core/framework/types.h"
|
||||
#include "tensorflow/core/lib/gtl/array_slice.h"
|
||||
|
||||
namespace tensorflow {
|
||||
namespace ops {
|
||||
namespace internal {
|
||||
// NOTE: This namespace has internal TensorFlow details that
|
||||
// are not part of TensorFlow's public API.
|
||||
|
||||
/// @defgroup control_flow_ops_internal Control Flow Ops Internal
|
||||
/// @{
|
||||
|
||||
/// Creates or finds a child frame, and makes `data` available to the child frame.
|
||||
///
|
||||
/// This op is used together with `Exit` to create loops in the graph.
|
||||
/// The unique `frame_name` is used by the `Executor` to identify frames. If
|
||||
/// `is_constant` is true, `output` is a constant in the child frame; otherwise
|
||||
/// it may be changed in the child frame. At most `parallel_iterations` iterations
|
||||
/// are run in parallel in the child frame.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * data: The tensor to be made available to the child frame.
|
||||
/// * frame_name: The name of the child frame.
|
||||
///
|
||||
/// Optional attributes (see `Attrs`):
|
||||
/// * is_constant: If true, the output is constant within the child frame.
|
||||
/// * parallel_iterations: The number of iterations allowed to run in parallel.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: The same tensor as `data`.
|
||||
class Enter {
|
||||
public:
|
||||
/// Optional attribute setters for Enter
|
||||
struct Attrs {
|
||||
/// If true, the output is constant within the child frame.
|
||||
///
|
||||
/// Defaults to false
|
||||
TF_MUST_USE_RESULT Attrs IsConstant(bool x) {
|
||||
Attrs ret = *this;
|
||||
ret.is_constant_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// The number of iterations allowed to run in parallel.
|
||||
///
|
||||
/// Defaults to 10
|
||||
TF_MUST_USE_RESULT Attrs ParallelIterations(int64 x) {
|
||||
Attrs ret = *this;
|
||||
ret.parallel_iterations_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool is_constant_ = false;
|
||||
int64 parallel_iterations_ = 10;
|
||||
};
|
||||
Enter(const ::tensorflow::Scope& scope, ::tensorflow::Input data, StringPiece
|
||||
frame_name);
|
||||
Enter(const ::tensorflow::Scope& scope, ::tensorflow::Input data, StringPiece
|
||||
frame_name, const Enter::Attrs& attrs);
|
||||
operator ::tensorflow::Output() const { return output; }
|
||||
operator ::tensorflow::Input() const { return output; }
|
||||
::tensorflow::Node* node() const { return output.node(); }
|
||||
|
||||
static Attrs IsConstant(bool x) {
|
||||
return Attrs().IsConstant(x);
|
||||
}
|
||||
static Attrs ParallelIterations(int64 x) {
|
||||
return Attrs().ParallelIterations(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output;
|
||||
};
|
||||
|
||||
/// Exits the current frame to its parent frame.
|
||||
///
|
||||
/// Exit makes its input `data` available to the parent frame.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * data: The tensor to be made available to the parent frame.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: The same tensor as `data`.
|
||||
class Exit {
|
||||
public:
|
||||
Exit(const ::tensorflow::Scope& scope, ::tensorflow::Input data);
|
||||
operator ::tensorflow::Output() const { return output; }
|
||||
operator ::tensorflow::Input() const { return output; }
|
||||
::tensorflow::Node* node() const { return output.node(); }
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output;
|
||||
};
|
||||
|
||||
/// Creates or finds a child frame, and makes `data` available to the child frame.
|
||||
///
|
||||
/// The unique `frame_name` is used by the `Executor` to identify frames. If
|
||||
/// `is_constant` is true, `output` is a constant in the child frame; otherwise
|
||||
/// it may be changed in the child frame. At most `parallel_iterations` iterations
|
||||
/// are run in parallel in the child frame.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * data: The tensor to be made available to the child frame.
|
||||
/// * frame_name: The name of the child frame.
|
||||
///
|
||||
/// Optional attributes (see `Attrs`):
|
||||
/// * is_constant: If true, the output is constant within the child frame.
|
||||
/// * parallel_iterations: The number of iterations allowed to run in parallel.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: The same tensor as `data`.
|
||||
class RefEnter {
|
||||
public:
|
||||
/// Optional attribute setters for RefEnter
|
||||
struct Attrs {
|
||||
/// If true, the output is constant within the child frame.
|
||||
///
|
||||
/// Defaults to false
|
||||
TF_MUST_USE_RESULT Attrs IsConstant(bool x) {
|
||||
Attrs ret = *this;
|
||||
ret.is_constant_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// The number of iterations allowed to run in parallel.
|
||||
///
|
||||
/// Defaults to 10
|
||||
TF_MUST_USE_RESULT Attrs ParallelIterations(int64 x) {
|
||||
Attrs ret = *this;
|
||||
ret.parallel_iterations_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool is_constant_ = false;
|
||||
int64 parallel_iterations_ = 10;
|
||||
};
|
||||
RefEnter(const ::tensorflow::Scope& scope, ::tensorflow::Input data,
|
||||
StringPiece frame_name);
|
||||
RefEnter(const ::tensorflow::Scope& scope, ::tensorflow::Input data,
|
||||
StringPiece frame_name, const RefEnter::Attrs& attrs);
|
||||
operator ::tensorflow::Output() const { return output; }
|
||||
operator ::tensorflow::Input() const { return output; }
|
||||
::tensorflow::Node* node() const { return output.node(); }
|
||||
|
||||
static Attrs IsConstant(bool x) {
|
||||
return Attrs().IsConstant(x);
|
||||
}
|
||||
static Attrs ParallelIterations(int64 x) {
|
||||
return Attrs().ParallelIterations(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output;
|
||||
};
|
||||
|
||||
/// Exits the current frame to its parent frame.
|
||||
///
|
||||
/// Exit makes its input `data` available to the parent frame.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * data: The tensor to be made available to the parent frame.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: The same tensor as `data`.
|
||||
class RefExit {
|
||||
public:
|
||||
RefExit(const ::tensorflow::Scope& scope, ::tensorflow::Input data);
|
||||
operator ::tensorflow::Output() const { return output; }
|
||||
operator ::tensorflow::Input() const { return output; }
|
||||
::tensorflow::Node* node() const { return output.node(); }
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output;
|
||||
};
|
||||
|
||||
/// Forwards the value of an available tensor from `inputs` to `output`.
|
||||
///
|
||||
/// `Merge` waits for at least one of the tensors in `inputs` to become available.
|
||||
/// It is usually combined with `Switch` to implement branching.
|
||||
///
|
||||
/// `Merge` forwards the first tensor for become available to `output`, and sets
|
||||
/// `value_index` to its index in `inputs`.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * inputs: The input tensors, exactly one of which will become available.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output` output: Will be set to the available input tensor.
|
||||
/// * `Output` value_index: The index of the chosen input tensor in `inputs`.
|
||||
class RefMerge {
|
||||
public:
|
||||
RefMerge(const ::tensorflow::Scope& scope, ::tensorflow::InputList inputs);
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output;
|
||||
::tensorflow::Output value_index;
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
} // namespace ops
|
||||
} // namespace tensorflow
|
||||
|
||||
#endif // TENSORFLOW_CC_OPS_CONTROL_FLOW_OPS_INTERNAL_H_
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,28 @@
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#ifndef TENSORFLOW_CC_OPS_DATA_FLOW_OPS_INTERNAL_H_
|
||||
#define TENSORFLOW_CC_OPS_DATA_FLOW_OPS_INTERNAL_H_
|
||||
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#include "tensorflow/cc/framework/ops.h"
|
||||
#include "tensorflow/cc/framework/scope.h"
|
||||
#include "tensorflow/core/framework/tensor.h"
|
||||
#include "tensorflow/core/framework/tensor_shape.h"
|
||||
#include "tensorflow/core/framework/types.h"
|
||||
#include "tensorflow/core/lib/gtl/array_slice.h"
|
||||
|
||||
namespace tensorflow {
|
||||
namespace ops {
|
||||
namespace internal {
|
||||
// NOTE: This namespace has internal TensorFlow details that
|
||||
// are not part of TensorFlow's public API.
|
||||
|
||||
/// @defgroup data_flow_ops_internal Data Flow Ops Internal
|
||||
/// @{
|
||||
|
||||
} // namespace internal
|
||||
} // namespace ops
|
||||
} // namespace tensorflow
|
||||
|
||||
#endif // TENSORFLOW_CC_OPS_DATA_FLOW_OPS_INTERNAL_H_
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,174 @@
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#ifndef TENSORFLOW_CC_OPS_IMAGE_OPS_INTERNAL_H_
|
||||
#define TENSORFLOW_CC_OPS_IMAGE_OPS_INTERNAL_H_
|
||||
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#include "tensorflow/cc/framework/ops.h"
|
||||
#include "tensorflow/cc/framework/scope.h"
|
||||
#include "tensorflow/core/framework/tensor.h"
|
||||
#include "tensorflow/core/framework/tensor_shape.h"
|
||||
#include "tensorflow/core/framework/types.h"
|
||||
#include "tensorflow/core/lib/gtl/array_slice.h"
|
||||
|
||||
namespace tensorflow {
|
||||
namespace ops {
|
||||
namespace internal {
|
||||
// NOTE: This namespace has internal TensorFlow details that
|
||||
// are not part of TensorFlow's public API.
|
||||
|
||||
/// @defgroup image_ops_internal Image Ops Internal
|
||||
/// @{
|
||||
|
||||
/// Computes the gradient of bicubic interpolation.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * grads: 4-D with shape `[batch, height, width, channels]`.
|
||||
/// * original_image: 4-D with shape `[batch, orig_height, orig_width, channels]`,
|
||||
/// The image tensor that was resized.
|
||||
///
|
||||
/// Optional attributes (see `Attrs`):
|
||||
/// * align_corners: If true, the centers of the 4 corner pixels of the input and grad tensors are
|
||||
/// aligned. Defaults to false.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: 4-D with shape `[batch, orig_height, orig_width, channels]`.
|
||||
/// Gradients with respect to the input image. Input image must have been
|
||||
/// float or double.
|
||||
class ResizeBicubicGrad {
|
||||
public:
|
||||
/// Optional attribute setters for ResizeBicubicGrad
|
||||
struct Attrs {
|
||||
/// If true, the centers of the 4 corner pixels of the input and grad tensors are
|
||||
/// aligned. Defaults to false.
|
||||
///
|
||||
/// Defaults to false
|
||||
TF_MUST_USE_RESULT Attrs AlignCorners(bool x) {
|
||||
Attrs ret = *this;
|
||||
ret.align_corners_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool align_corners_ = false;
|
||||
};
|
||||
ResizeBicubicGrad(const ::tensorflow::Scope& scope, ::tensorflow::Input grads,
|
||||
::tensorflow::Input original_image);
|
||||
ResizeBicubicGrad(const ::tensorflow::Scope& scope, ::tensorflow::Input grads,
|
||||
::tensorflow::Input original_image, const
|
||||
ResizeBicubicGrad::Attrs& attrs);
|
||||
operator ::tensorflow::Output() const { return output; }
|
||||
operator ::tensorflow::Input() const { return output; }
|
||||
::tensorflow::Node* node() const { return output.node(); }
|
||||
|
||||
static Attrs AlignCorners(bool x) {
|
||||
return Attrs().AlignCorners(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output;
|
||||
};
|
||||
|
||||
/// Computes the gradient of bilinear interpolation.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * grads: 4-D with shape `[batch, height, width, channels]`.
|
||||
/// * original_image: 4-D with shape `[batch, orig_height, orig_width, channels]`,
|
||||
/// The image tensor that was resized.
|
||||
///
|
||||
/// Optional attributes (see `Attrs`):
|
||||
/// * align_corners: If true, the centers of the 4 corner pixels of the input and grad tensors are
|
||||
/// aligned. Defaults to false.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: 4-D with shape `[batch, orig_height, orig_width, channels]`.
|
||||
/// Gradients with respect to the input image. Input image must have been
|
||||
/// float or double.
|
||||
class ResizeBilinearGrad {
|
||||
public:
|
||||
/// Optional attribute setters for ResizeBilinearGrad
|
||||
struct Attrs {
|
||||
/// If true, the centers of the 4 corner pixels of the input and grad tensors are
|
||||
/// aligned. Defaults to false.
|
||||
///
|
||||
/// Defaults to false
|
||||
TF_MUST_USE_RESULT Attrs AlignCorners(bool x) {
|
||||
Attrs ret = *this;
|
||||
ret.align_corners_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool align_corners_ = false;
|
||||
};
|
||||
ResizeBilinearGrad(const ::tensorflow::Scope& scope, ::tensorflow::Input grads,
|
||||
::tensorflow::Input original_image);
|
||||
ResizeBilinearGrad(const ::tensorflow::Scope& scope, ::tensorflow::Input grads,
|
||||
::tensorflow::Input original_image, const
|
||||
ResizeBilinearGrad::Attrs& attrs);
|
||||
operator ::tensorflow::Output() const { return output; }
|
||||
operator ::tensorflow::Input() const { return output; }
|
||||
::tensorflow::Node* node() const { return output.node(); }
|
||||
|
||||
static Attrs AlignCorners(bool x) {
|
||||
return Attrs().AlignCorners(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output;
|
||||
};
|
||||
|
||||
/// Computes the gradient of nearest neighbor interpolation.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * grads: 4-D with shape `[batch, height, width, channels]`.
|
||||
/// * size: = A 1-D int32 Tensor of 2 elements: `orig_height, orig_width`. The
|
||||
/// original input size.
|
||||
///
|
||||
/// Optional attributes (see `Attrs`):
|
||||
/// * align_corners: If true, the centers of the 4 corner pixels of the input and grad tensors are
|
||||
/// aligned. Defaults to false.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: 4-D with shape `[batch, orig_height, orig_width, channels]`. Gradients
|
||||
/// with respect to the input image.
|
||||
class ResizeNearestNeighborGrad {
|
||||
public:
|
||||
/// Optional attribute setters for ResizeNearestNeighborGrad
|
||||
struct Attrs {
|
||||
/// If true, the centers of the 4 corner pixels of the input and grad tensors are
|
||||
/// aligned. Defaults to false.
|
||||
///
|
||||
/// Defaults to false
|
||||
TF_MUST_USE_RESULT Attrs AlignCorners(bool x) {
|
||||
Attrs ret = *this;
|
||||
ret.align_corners_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool align_corners_ = false;
|
||||
};
|
||||
ResizeNearestNeighborGrad(const ::tensorflow::Scope& scope, ::tensorflow::Input
|
||||
grads, ::tensorflow::Input size);
|
||||
ResizeNearestNeighborGrad(const ::tensorflow::Scope& scope, ::tensorflow::Input
|
||||
grads, ::tensorflow::Input size, const
|
||||
ResizeNearestNeighborGrad::Attrs& attrs);
|
||||
operator ::tensorflow::Output() const { return output; }
|
||||
operator ::tensorflow::Input() const { return output; }
|
||||
::tensorflow::Node* node() const { return output.node(); }
|
||||
|
||||
static Attrs AlignCorners(bool x) {
|
||||
return Attrs().AlignCorners(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output;
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
} // namespace ops
|
||||
} // namespace tensorflow
|
||||
|
||||
#endif // TENSORFLOW_CC_OPS_IMAGE_OPS_INTERNAL_H_
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,28 @@
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#ifndef TENSORFLOW_CC_OPS_IO_OPS_INTERNAL_H_
|
||||
#define TENSORFLOW_CC_OPS_IO_OPS_INTERNAL_H_
|
||||
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#include "tensorflow/cc/framework/ops.h"
|
||||
#include "tensorflow/cc/framework/scope.h"
|
||||
#include "tensorflow/core/framework/tensor.h"
|
||||
#include "tensorflow/core/framework/tensor_shape.h"
|
||||
#include "tensorflow/core/framework/types.h"
|
||||
#include "tensorflow/core/lib/gtl/array_slice.h"
|
||||
|
||||
namespace tensorflow {
|
||||
namespace ops {
|
||||
namespace internal {
|
||||
// NOTE: This namespace has internal TensorFlow details that
|
||||
// are not part of TensorFlow's public API.
|
||||
|
||||
/// @defgroup io_ops_internal Io Ops Internal
|
||||
/// @{
|
||||
|
||||
} // namespace internal
|
||||
} // namespace ops
|
||||
} // namespace tensorflow
|
||||
|
||||
#endif // TENSORFLOW_CC_OPS_IO_OPS_INTERNAL_H_
|
||||
@@ -0,0 +1,601 @@
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#ifndef TENSORFLOW_CC_OPS_LINALG_OPS_H_
|
||||
#define TENSORFLOW_CC_OPS_LINALG_OPS_H_
|
||||
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#include "tensorflow/cc/framework/ops.h"
|
||||
#include "tensorflow/cc/framework/scope.h"
|
||||
#include "tensorflow/core/framework/tensor.h"
|
||||
#include "tensorflow/core/framework/tensor_shape.h"
|
||||
#include "tensorflow/core/framework/types.h"
|
||||
#include "tensorflow/core/lib/gtl/array_slice.h"
|
||||
|
||||
namespace tensorflow {
|
||||
namespace ops {
|
||||
|
||||
/// @defgroup linalg_ops Linalg Ops
|
||||
/// @{
|
||||
|
||||
/// Computes the Cholesky decomposition of one or more square matrices.
|
||||
///
|
||||
/// The input is a tensor of shape `[..., M, M]` whose inner-most 2 dimensions
|
||||
/// form square matrices.
|
||||
///
|
||||
/// The input has to be symmetric and positive definite. Only the lower-triangular
|
||||
/// part of the input will be used for this operation. The upper-triangular part
|
||||
/// will not be read.
|
||||
///
|
||||
/// The output is a tensor of the same shape as the input
|
||||
/// containing the Cholesky decompositions for all input submatrices `[..., :, :]`.
|
||||
///
|
||||
/// **Note**: The gradient computation on GPU is faster for large matrices but
|
||||
/// not for large batch dimensions when the submatrices are small. In this
|
||||
/// case it might be faster to use the CPU.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * input: Shape is `[..., M, M]`.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: Shape is `[..., M, M]`.
|
||||
class Cholesky {
|
||||
public:
|
||||
Cholesky(const ::tensorflow::Scope& scope, ::tensorflow::Input input);
|
||||
operator ::tensorflow::Output() const { return output; }
|
||||
operator ::tensorflow::Input() const { return output; }
|
||||
::tensorflow::Node* node() const { return output.node(); }
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output;
|
||||
};
|
||||
|
||||
/// Computes the reverse mode backpropagated gradient of the Cholesky algorithm.
|
||||
///
|
||||
/// For an explanation see "Differentiation of the Cholesky algorithm" by
|
||||
/// Iain Murray http://arxiv.org/abs/1602.07527.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * l: Output of batch Cholesky algorithm l = cholesky(A). Shape is `[..., M, M]`.
|
||||
/// Algorithm depends only on lower triangular part of the innermost matrices of
|
||||
/// this tensor.
|
||||
/// * grad: df/dl where f is some scalar function. Shape is `[..., M, M]`.
|
||||
/// Algorithm depends only on lower triangular part of the innermost matrices of
|
||||
/// this tensor.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: Symmetrized version of df/dA . Shape is `[..., M, M]`
|
||||
class CholeskyGrad {
|
||||
public:
|
||||
CholeskyGrad(const ::tensorflow::Scope& scope, ::tensorflow::Input l,
|
||||
::tensorflow::Input grad);
|
||||
operator ::tensorflow::Output() const { return output; }
|
||||
operator ::tensorflow::Input() const { return output; }
|
||||
::tensorflow::Node* node() const { return output.node(); }
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output;
|
||||
};
|
||||
|
||||
/// Computes the sign and the log of the absolute value of the determinant of
|
||||
///
|
||||
/// one or more square matrices.
|
||||
///
|
||||
/// The input is a tensor of shape `[N, M, M]` whose inner-most 2 dimensions
|
||||
/// form square matrices. The outputs are two tensors containing the signs and
|
||||
/// absolute values of the log determinants for all N input submatrices
|
||||
/// `[..., :, :]` such that the determinant = sign*exp(log_abs_determinant).
|
||||
/// The log_abs_determinant is computed as det(P)*sum(log(diag(LU))) where LU
|
||||
/// is the LU decomposition of the input and P is the corresponding
|
||||
/// permutation matrix.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * input: Shape is `[N, M, M]`.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output` sign: The signs of the log determinants of the inputs. Shape is `[N]`.
|
||||
/// * `Output` log_abs_determinant: The logs of the absolute values of the determinants
|
||||
/// of the N input matrices. Shape is `[N]`.
|
||||
class LogMatrixDeterminant {
|
||||
public:
|
||||
LogMatrixDeterminant(const ::tensorflow::Scope& scope, ::tensorflow::Input
|
||||
input);
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output sign;
|
||||
::tensorflow::Output log_abs_determinant;
|
||||
};
|
||||
|
||||
/// Computes the determinant of one or more square matrices.
|
||||
///
|
||||
/// The input is a tensor of shape `[..., M, M]` whose inner-most 2 dimensions
|
||||
/// form square matrices. The output is a tensor containing the determinants
|
||||
/// for all input submatrices `[..., :, :]`.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * input: Shape is `[..., M, M]`.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: Shape is `[...]`.
|
||||
class MatrixDeterminant {
|
||||
public:
|
||||
MatrixDeterminant(const ::tensorflow::Scope& scope, ::tensorflow::Input input);
|
||||
operator ::tensorflow::Output() const { return output; }
|
||||
operator ::tensorflow::Input() const { return output; }
|
||||
::tensorflow::Node* node() const { return output.node(); }
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output;
|
||||
};
|
||||
|
||||
/// Computes the inverse of one or more square invertible matrices or their
|
||||
///
|
||||
/// adjoints (conjugate transposes).
|
||||
///
|
||||
/// The input is a tensor of shape `[..., M, M]` whose inner-most 2 dimensions
|
||||
/// form square matrices. The output is a tensor of the same shape as the input
|
||||
/// containing the inverse for all input submatrices `[..., :, :]`.
|
||||
///
|
||||
/// The op uses LU decomposition with partial pivoting to compute the inverses.
|
||||
///
|
||||
/// If a matrix is not invertible there is no guarantee what the op does. It
|
||||
/// may detect the condition and raise an exception or it may simply return a
|
||||
/// garbage result.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * input: Shape is `[..., M, M]`.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: Shape is `[..., M, M]`.
|
||||
///
|
||||
/// @compatibility(numpy)
|
||||
/// Equivalent to np.linalg.inv
|
||||
/// @end_compatibility
|
||||
class MatrixInverse {
|
||||
public:
|
||||
/// Optional attribute setters for MatrixInverse
|
||||
struct Attrs {
|
||||
/// Defaults to false
|
||||
TF_MUST_USE_RESULT Attrs Adjoint(bool x) {
|
||||
Attrs ret = *this;
|
||||
ret.adjoint_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool adjoint_ = false;
|
||||
};
|
||||
MatrixInverse(const ::tensorflow::Scope& scope, ::tensorflow::Input input);
|
||||
MatrixInverse(const ::tensorflow::Scope& scope, ::tensorflow::Input input,
|
||||
const MatrixInverse::Attrs& attrs);
|
||||
operator ::tensorflow::Output() const { return output; }
|
||||
operator ::tensorflow::Input() const { return output; }
|
||||
::tensorflow::Node* node() const { return output.node(); }
|
||||
|
||||
static Attrs Adjoint(bool x) {
|
||||
return Attrs().Adjoint(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output;
|
||||
};
|
||||
|
||||
/// Solves systems of linear equations.
|
||||
///
|
||||
/// `Matrix` is a tensor of shape `[..., M, M]` whose inner-most 2 dimensions
|
||||
/// form square matrices. `Rhs` is a tensor of shape `[..., M, K]`. The `output` is
|
||||
/// a tensor shape `[..., M, K]`. If `adjoint` is `False` then each output matrix
|
||||
/// satisfies `matrix[..., :, :] * output[..., :, :] = rhs[..., :, :]`.
|
||||
/// If `adjoint` is `True` then each output matrix satisfies
|
||||
/// `adjoint(matrix[..., :, :]) * output[..., :, :] = rhs[..., :, :]`.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * matrix: Shape is `[..., M, M]`.
|
||||
/// * rhs: Shape is `[..., M, K]`.
|
||||
///
|
||||
/// Optional attributes (see `Attrs`):
|
||||
/// * adjoint: Boolean indicating whether to solve with `matrix` or its (block-wise)
|
||||
/// adjoint.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: Shape is `[..., M, K]`.
|
||||
class MatrixSolve {
|
||||
public:
|
||||
/// Optional attribute setters for MatrixSolve
|
||||
struct Attrs {
|
||||
/// Boolean indicating whether to solve with `matrix` or its (block-wise)
|
||||
/// adjoint.
|
||||
///
|
||||
/// Defaults to false
|
||||
TF_MUST_USE_RESULT Attrs Adjoint(bool x) {
|
||||
Attrs ret = *this;
|
||||
ret.adjoint_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool adjoint_ = false;
|
||||
};
|
||||
MatrixSolve(const ::tensorflow::Scope& scope, ::tensorflow::Input matrix,
|
||||
::tensorflow::Input rhs);
|
||||
MatrixSolve(const ::tensorflow::Scope& scope, ::tensorflow::Input matrix,
|
||||
::tensorflow::Input rhs, const MatrixSolve::Attrs& attrs);
|
||||
operator ::tensorflow::Output() const { return output; }
|
||||
operator ::tensorflow::Input() const { return output; }
|
||||
::tensorflow::Node* node() const { return output.node(); }
|
||||
|
||||
static Attrs Adjoint(bool x) {
|
||||
return Attrs().Adjoint(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output;
|
||||
};
|
||||
|
||||
/// Solves one or more linear least-squares problems.
|
||||
///
|
||||
/// `matrix` is a tensor of shape `[..., M, N]` whose inner-most 2 dimensions
|
||||
/// form real or complex matrices of size `[M, N]`. `Rhs` is a tensor of the same
|
||||
/// type as `matrix` and shape `[..., M, K]`.
|
||||
/// The output is a tensor shape `[..., N, K]` where each output matrix solves
|
||||
/// each of the equations
|
||||
/// `matrix[..., :, :]` * `output[..., :, :]` = `rhs[..., :, :]`
|
||||
/// in the least squares sense.
|
||||
///
|
||||
/// We use the following notation for (complex) matrix and right-hand sides
|
||||
/// in the batch:
|
||||
///
|
||||
/// `matrix`=\\(A \in \mathbb{C}^{m \times n}\\),
|
||||
/// `rhs`=\\(B \in \mathbb{C}^{m \times k}\\),
|
||||
/// `output`=\\(X \in \mathbb{C}^{n \times k}\\),
|
||||
/// `l2_regularizer`=\\(\lambda \in \mathbb{R}\\).
|
||||
///
|
||||
/// If `fast` is `True`, then the solution is computed by solving the normal
|
||||
/// equations using Cholesky decomposition. Specifically, if \\(m \ge n\\) then
|
||||
/// \\(X = (A^H A + \lambda I)^{-1} A^H B\\), which solves the least-squares
|
||||
/// problem \\(X = \mathrm{argmin}_{Z \in \Re^{n \times k} } ||A Z - B||_F^2 + \lambda ||Z||_F^2\\).
|
||||
/// If \\(m \lt n\\) then `output` is computed as
|
||||
/// \\(X = A^H (A A^H + \lambda I)^{-1} B\\), which (for \\(\lambda = 0\\)) is the
|
||||
/// minimum-norm solution to the under-determined linear system, i.e.
|
||||
/// \\(X = \mathrm{argmin}_{Z \in \mathbb{C}^{n \times k} } ||Z||_F^2 \\),
|
||||
/// subject to \\(A Z = B\\). Notice that the fast path is only numerically stable
|
||||
/// when \\(A\\) is numerically full rank and has a condition number
|
||||
/// \\(\mathrm{cond}(A) \lt \frac{1}{\sqrt{\epsilon_{mach} } }\\) or \\(\lambda\\) is
|
||||
/// sufficiently large.
|
||||
///
|
||||
/// If `fast` is `False` an algorithm based on the numerically robust complete
|
||||
/// orthogonal decomposition is used. This computes the minimum-norm
|
||||
/// least-squares solution, even when \\(A\\) is rank deficient. This path is
|
||||
/// typically 6-7 times slower than the fast path. If `fast` is `False` then
|
||||
/// `l2_regularizer` is ignored.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * matrix: Shape is `[..., M, N]`.
|
||||
/// * rhs: Shape is `[..., M, K]`.
|
||||
/// * l2_regularizer: Scalar tensor.
|
||||
///
|
||||
/// @compatibility(numpy)
|
||||
/// Equivalent to np.linalg.lstsq
|
||||
/// @end_compatibility
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: Shape is `[..., N, K]`.
|
||||
class MatrixSolveLs {
|
||||
public:
|
||||
/// Optional attribute setters for MatrixSolveLs
|
||||
struct Attrs {
|
||||
/// Defaults to true
|
||||
TF_MUST_USE_RESULT Attrs Fast(bool x) {
|
||||
Attrs ret = *this;
|
||||
ret.fast_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool fast_ = true;
|
||||
};
|
||||
MatrixSolveLs(const ::tensorflow::Scope& scope, ::tensorflow::Input matrix,
|
||||
::tensorflow::Input rhs, ::tensorflow::Input l2_regularizer);
|
||||
MatrixSolveLs(const ::tensorflow::Scope& scope, ::tensorflow::Input matrix,
|
||||
::tensorflow::Input rhs, ::tensorflow::Input l2_regularizer,
|
||||
const MatrixSolveLs::Attrs& attrs);
|
||||
operator ::tensorflow::Output() const { return output; }
|
||||
operator ::tensorflow::Input() const { return output; }
|
||||
::tensorflow::Node* node() const { return output.node(); }
|
||||
|
||||
static Attrs Fast(bool x) {
|
||||
return Attrs().Fast(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output;
|
||||
};
|
||||
|
||||
/// Solves systems of linear equations with upper or lower triangular matrices by
|
||||
///
|
||||
/// backsubstitution.
|
||||
///
|
||||
/// `matrix` is a tensor of shape `[..., M, M]` whose inner-most 2 dimensions form
|
||||
/// square matrices. If `lower` is `True` then the strictly upper triangular part
|
||||
/// of each inner-most matrix is assumed to be zero and not accessed.
|
||||
/// If `lower` is False then the strictly lower triangular part of each inner-most
|
||||
/// matrix is assumed to be zero and not accessed.
|
||||
/// `rhs` is a tensor of shape `[..., M, K]`.
|
||||
///
|
||||
/// The output is a tensor of shape `[..., M, K]`. If `adjoint` is
|
||||
/// `True` then the innermost matrices in `output` satisfy matrix equations
|
||||
/// `matrix[..., :, :] * output[..., :, :] = rhs[..., :, :]`.
|
||||
/// If `adjoint` is `False` then the strictly then the innermost matrices in
|
||||
/// `output` satisfy matrix equations
|
||||
/// `adjoint(matrix[..., i, k]) * output[..., k, j] = rhs[..., i, j]`.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * matrix: Shape is `[..., M, M]`.
|
||||
/// * rhs: Shape is `[..., M, K]`.
|
||||
///
|
||||
/// Optional attributes (see `Attrs`):
|
||||
/// * lower: Boolean indicating whether the innermost matrices in `matrix` are
|
||||
/// lower or upper triangular.
|
||||
/// * adjoint: Boolean indicating whether to solve with `matrix` or its (block-wise)
|
||||
/// adjoint.
|
||||
///
|
||||
/// @compatibility(numpy)
|
||||
/// Equivalent to scipy.linalg.solve_triangular
|
||||
/// @end_compatibility
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: Shape is `[..., M, K]`.
|
||||
class MatrixTriangularSolve {
|
||||
public:
|
||||
/// Optional attribute setters for MatrixTriangularSolve
|
||||
struct Attrs {
|
||||
/// Boolean indicating whether the innermost matrices in `matrix` are
|
||||
/// lower or upper triangular.
|
||||
///
|
||||
/// Defaults to true
|
||||
TF_MUST_USE_RESULT Attrs Lower(bool x) {
|
||||
Attrs ret = *this;
|
||||
ret.lower_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// Boolean indicating whether to solve with `matrix` or its (block-wise)
|
||||
/// adjoint.
|
||||
///
|
||||
/// @compatibility(numpy)
|
||||
/// Equivalent to scipy.linalg.solve_triangular
|
||||
/// @end_compatibility
|
||||
///
|
||||
/// Defaults to false
|
||||
TF_MUST_USE_RESULT Attrs Adjoint(bool x) {
|
||||
Attrs ret = *this;
|
||||
ret.adjoint_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool lower_ = true;
|
||||
bool adjoint_ = false;
|
||||
};
|
||||
MatrixTriangularSolve(const ::tensorflow::Scope& scope, ::tensorflow::Input
|
||||
matrix, ::tensorflow::Input rhs);
|
||||
MatrixTriangularSolve(const ::tensorflow::Scope& scope, ::tensorflow::Input
|
||||
matrix, ::tensorflow::Input rhs, const
|
||||
MatrixTriangularSolve::Attrs& attrs);
|
||||
operator ::tensorflow::Output() const { return output; }
|
||||
operator ::tensorflow::Input() const { return output; }
|
||||
::tensorflow::Node* node() const { return output.node(); }
|
||||
|
||||
static Attrs Lower(bool x) {
|
||||
return Attrs().Lower(x);
|
||||
}
|
||||
static Attrs Adjoint(bool x) {
|
||||
return Attrs().Adjoint(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output;
|
||||
};
|
||||
|
||||
/// Computes the QR decompositions of one or more matrices.
|
||||
///
|
||||
/// Computes the QR decomposition of each inner matrix in `tensor` such that
|
||||
/// `tensor[..., :, :] = q[..., :, :] * r[..., :,:])`
|
||||
///
|
||||
/// ```python
|
||||
/// # a is a tensor.
|
||||
/// # q is a tensor of orthonormal matrices.
|
||||
/// # r is a tensor of upper triangular matrices.
|
||||
/// q, r = qr(a)
|
||||
/// q_full, r_full = qr(a, full_matrices=True)
|
||||
/// ```
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * input: A tensor of shape `[..., M, N]` whose inner-most 2 dimensions
|
||||
/// form matrices of size `[M, N]`. Let `P` be the minimum of `M` and `N`.
|
||||
///
|
||||
/// Optional attributes (see `Attrs`):
|
||||
/// * full_matrices: If true, compute full-sized `q` and `r`. If false
|
||||
/// (the default), compute only the leading `P` columns of `q`.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output` q: Orthonormal basis for range of `a`. If `full_matrices` is `False` then
|
||||
/// shape is `[..., M, P]`; if `full_matrices` is `True` then shape is
|
||||
/// `[..., M, M]`.
|
||||
/// * `Output` r: Triangular factor. If `full_matrices` is `False` then shape is
|
||||
/// `[..., P, N]`. If `full_matrices` is `True` then shape is `[..., M, N]`.
|
||||
class Qr {
|
||||
public:
|
||||
/// Optional attribute setters for Qr
|
||||
struct Attrs {
|
||||
/// If true, compute full-sized `q` and `r`. If false
|
||||
/// (the default), compute only the leading `P` columns of `q`.
|
||||
///
|
||||
/// Defaults to false
|
||||
TF_MUST_USE_RESULT Attrs FullMatrices(bool x) {
|
||||
Attrs ret = *this;
|
||||
ret.full_matrices_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool full_matrices_ = false;
|
||||
};
|
||||
Qr(const ::tensorflow::Scope& scope, ::tensorflow::Input input);
|
||||
Qr(const ::tensorflow::Scope& scope, ::tensorflow::Input input, const
|
||||
Qr::Attrs& attrs);
|
||||
|
||||
static Attrs FullMatrices(bool x) {
|
||||
return Attrs().FullMatrices(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output q;
|
||||
::tensorflow::Output r;
|
||||
};
|
||||
|
||||
/// Computes the eigen decomposition of one or more square self-adjoint matrices.
|
||||
///
|
||||
/// Computes the eigenvalues and (optionally) eigenvectors of each inner matrix in
|
||||
/// `input` such that `input[..., :, :] = v[..., :, :] * diag(e[..., :])`. The eigenvalues
|
||||
/// are sorted in non-decreasing order.
|
||||
///
|
||||
/// ```python
|
||||
/// # a is a tensor.
|
||||
/// # e is a tensor of eigenvalues.
|
||||
/// # v is a tensor of eigenvectors.
|
||||
/// e, v = self_adjoint_eig(a)
|
||||
/// e = self_adjoint_eig(a, compute_v=False)
|
||||
/// ```
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * input: `Tensor` input of shape `[N, N]`.
|
||||
///
|
||||
/// Optional attributes (see `Attrs`):
|
||||
/// * compute_v: If `True` then eigenvectors will be computed and returned in `v`.
|
||||
/// Otherwise, only the eigenvalues will be computed.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output` e: Eigenvalues. Shape is `[N]`.
|
||||
/// * `Output` v: Eigenvectors. Shape is `[N, N]`.
|
||||
class SelfAdjointEig {
|
||||
public:
|
||||
/// Optional attribute setters for SelfAdjointEig
|
||||
struct Attrs {
|
||||
/// If `True` then eigenvectors will be computed and returned in `v`.
|
||||
/// Otherwise, only the eigenvalues will be computed.
|
||||
///
|
||||
/// Defaults to true
|
||||
TF_MUST_USE_RESULT Attrs ComputeV(bool x) {
|
||||
Attrs ret = *this;
|
||||
ret.compute_v_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool compute_v_ = true;
|
||||
};
|
||||
SelfAdjointEig(const ::tensorflow::Scope& scope, ::tensorflow::Input input);
|
||||
SelfAdjointEig(const ::tensorflow::Scope& scope, ::tensorflow::Input input,
|
||||
const SelfAdjointEig::Attrs& attrs);
|
||||
|
||||
static Attrs ComputeV(bool x) {
|
||||
return Attrs().ComputeV(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output e;
|
||||
::tensorflow::Output v;
|
||||
};
|
||||
|
||||
/// Computes the singular value decompositions of one or more matrices.
|
||||
///
|
||||
/// Computes the SVD of each inner matrix in `input` such that
|
||||
/// `input[..., :, :] = u[..., :, :] * diag(s[..., :, :]) * transpose(v[..., :, :])`
|
||||
///
|
||||
/// ```python
|
||||
/// # a is a tensor containing a batch of matrices.
|
||||
/// # s is a tensor of singular values for each matrix.
|
||||
/// # u is the tensor containing of left singular vectors for each matrix.
|
||||
/// # v is the tensor containing of right singular vectors for each matrix.
|
||||
/// s, u, v = svd(a)
|
||||
/// s, _, _ = svd(a, compute_uv=False)
|
||||
/// ```
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * input: A tensor of shape `[..., M, N]` whose inner-most 2 dimensions
|
||||
/// form matrices of size `[M, N]`. Let `P` be the minimum of `M` and `N`.
|
||||
///
|
||||
/// Optional attributes (see `Attrs`):
|
||||
/// * compute_uv: If true, left and right singular vectors will be
|
||||
/// computed and returned in `u` and `v`, respectively.
|
||||
/// If false, `u` and `v` are not set and should never referenced.
|
||||
/// * full_matrices: If true, compute full-sized `u` and `v`. If false
|
||||
/// (the default), compute only the leading `P` singular vectors.
|
||||
/// Ignored if `compute_uv` is `False`.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output` s: Singular values. Shape is `[..., P]`.
|
||||
/// * `Output` u: Left singular vectors. If `full_matrices` is `False` then shape is
|
||||
/// `[..., M, P]`; if `full_matrices` is `True` then shape is
|
||||
/// `[..., M, M]`. Undefined if `compute_uv` is `False`.
|
||||
/// * `Output` v: Left singular vectors. If `full_matrices` is `False` then shape is
|
||||
/// `[..., N, P]`. If `full_matrices` is `True` then shape is `[..., N, N]`.
|
||||
/// Undefined if `compute_uv` is false.
|
||||
class Svd {
|
||||
public:
|
||||
/// Optional attribute setters for Svd
|
||||
struct Attrs {
|
||||
/// If true, left and right singular vectors will be
|
||||
/// computed and returned in `u` and `v`, respectively.
|
||||
/// If false, `u` and `v` are not set and should never referenced.
|
||||
///
|
||||
/// Defaults to true
|
||||
TF_MUST_USE_RESULT Attrs ComputeUv(bool x) {
|
||||
Attrs ret = *this;
|
||||
ret.compute_uv_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// If true, compute full-sized `u` and `v`. If false
|
||||
/// (the default), compute only the leading `P` singular vectors.
|
||||
/// Ignored if `compute_uv` is `False`.
|
||||
///
|
||||
/// Defaults to false
|
||||
TF_MUST_USE_RESULT Attrs FullMatrices(bool x) {
|
||||
Attrs ret = *this;
|
||||
ret.full_matrices_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool compute_uv_ = true;
|
||||
bool full_matrices_ = false;
|
||||
};
|
||||
Svd(const ::tensorflow::Scope& scope, ::tensorflow::Input input);
|
||||
Svd(const ::tensorflow::Scope& scope, ::tensorflow::Input input, const
|
||||
Svd::Attrs& attrs);
|
||||
|
||||
static Attrs ComputeUv(bool x) {
|
||||
return Attrs().ComputeUv(x);
|
||||
}
|
||||
static Attrs FullMatrices(bool x) {
|
||||
return Attrs().FullMatrices(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output s;
|
||||
::tensorflow::Output u;
|
||||
::tensorflow::Output v;
|
||||
};
|
||||
|
||||
/// @}
|
||||
|
||||
} // namespace ops
|
||||
} // namespace tensorflow
|
||||
|
||||
#endif // TENSORFLOW_CC_OPS_LINALG_OPS_H_
|
||||
@@ -0,0 +1,67 @@
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#ifndef TENSORFLOW_CC_OPS_LINALG_OPS_INTERNAL_H_
|
||||
#define TENSORFLOW_CC_OPS_LINALG_OPS_INTERNAL_H_
|
||||
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#include "tensorflow/cc/framework/ops.h"
|
||||
#include "tensorflow/cc/framework/scope.h"
|
||||
#include "tensorflow/core/framework/tensor.h"
|
||||
#include "tensorflow/core/framework/tensor_shape.h"
|
||||
#include "tensorflow/core/framework/types.h"
|
||||
#include "tensorflow/core/lib/gtl/array_slice.h"
|
||||
|
||||
namespace tensorflow {
|
||||
namespace ops {
|
||||
namespace internal {
|
||||
// NOTE: This namespace has internal TensorFlow details that
|
||||
// are not part of TensorFlow's public API.
|
||||
|
||||
/// @defgroup linalg_ops_internal Linalg Ops Internal
|
||||
/// @{
|
||||
|
||||
/// Computes the matrix logarithm of one or more square matrices:
|
||||
///
|
||||
///
|
||||
/// \\(log(exp(A)) = A\\)
|
||||
///
|
||||
/// This op is only defined for complex matrices. If A is positive-definite and
|
||||
/// real, then casting to a complex matrix, taking the logarithm and casting back
|
||||
/// to a real matrix will give the correct result.
|
||||
///
|
||||
/// This function computes the matrix logarithm using the Schur-Parlett algorithm.
|
||||
/// Details of the algorithm can be found in Section 11.6.2 of:
|
||||
/// Nicholas J. Higham, Functions of Matrices: Theory and Computation, SIAM 2008.
|
||||
/// ISBN 978-0-898716-46-7.
|
||||
///
|
||||
/// The input is a tensor of shape `[..., M, M]` whose inner-most 2 dimensions
|
||||
/// form square matrices. The output is a tensor of the same shape as the input
|
||||
/// containing the exponential for all input submatrices `[..., :, :]`.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * input: Shape is `[..., M, M]`.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: Shape is `[..., M, M]`.
|
||||
///
|
||||
/// @compatibility(scipy)
|
||||
/// Equivalent to scipy.linalg.logm
|
||||
/// @end_compatibility
|
||||
class MatrixLogarithm {
|
||||
public:
|
||||
MatrixLogarithm(const ::tensorflow::Scope& scope, ::tensorflow::Input input);
|
||||
operator ::tensorflow::Output() const { return output; }
|
||||
operator ::tensorflow::Input() const { return output; }
|
||||
::tensorflow::Node* node() const { return output.node(); }
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output;
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
} // namespace ops
|
||||
} // namespace tensorflow
|
||||
|
||||
#endif // TENSORFLOW_CC_OPS_LINALG_OPS_INTERNAL_H_
|
||||
@@ -0,0 +1,530 @@
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#ifndef TENSORFLOW_CC_OPS_LOGGING_OPS_H_
|
||||
#define TENSORFLOW_CC_OPS_LOGGING_OPS_H_
|
||||
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#include "tensorflow/cc/framework/ops.h"
|
||||
#include "tensorflow/cc/framework/scope.h"
|
||||
#include "tensorflow/core/framework/tensor.h"
|
||||
#include "tensorflow/core/framework/tensor_shape.h"
|
||||
#include "tensorflow/core/framework/types.h"
|
||||
#include "tensorflow/core/lib/gtl/array_slice.h"
|
||||
|
||||
namespace tensorflow {
|
||||
namespace ops {
|
||||
|
||||
/// @defgroup logging_ops Logging Ops
|
||||
/// @{
|
||||
|
||||
/// Asserts that the given condition is true.
|
||||
///
|
||||
/// If `condition` evaluates to false, print the list of tensors in `data`.
|
||||
/// `summarize` determines how many entries of the tensors to print.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * condition: The condition to evaluate.
|
||||
/// * data: The tensors to print out when condition is false.
|
||||
///
|
||||
/// Optional attributes (see `Attrs`):
|
||||
/// * summarize: Print this many entries of each tensor.
|
||||
///
|
||||
/// Returns:
|
||||
/// * the created `Operation`
|
||||
class Assert {
|
||||
public:
|
||||
/// Optional attribute setters for Assert
|
||||
struct Attrs {
|
||||
/// Print this many entries of each tensor.
|
||||
///
|
||||
/// Defaults to 3
|
||||
TF_MUST_USE_RESULT Attrs Summarize(int64 x) {
|
||||
Attrs ret = *this;
|
||||
ret.summarize_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int64 summarize_ = 3;
|
||||
};
|
||||
Assert(const ::tensorflow::Scope& scope, ::tensorflow::Input condition,
|
||||
::tensorflow::InputList data);
|
||||
Assert(const ::tensorflow::Scope& scope, ::tensorflow::Input condition,
|
||||
::tensorflow::InputList data, const Assert::Attrs& attrs);
|
||||
operator ::tensorflow::Operation() const { return operation; }
|
||||
|
||||
static Attrs Summarize(int64 x) {
|
||||
return Attrs().Summarize(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
};
|
||||
|
||||
/// Outputs a `Summary` protocol buffer with audio.
|
||||
///
|
||||
/// The summary has up to `max_outputs` summary values containing audio. The
|
||||
/// audio is built from `tensor` which must be 3-D with shape `[batch_size,
|
||||
/// frames, channels]` or 2-D with shape `[batch_size, frames]`. The values are
|
||||
/// assumed to be in the range of `[-1.0, 1.0]` with a sample rate of `sample_rate`.
|
||||
///
|
||||
/// The `tag` argument is a scalar `Tensor` of type `string`. It is used to
|
||||
/// build the `tag` of the summary values:
|
||||
///
|
||||
/// * If `max_outputs` is 1, the summary value tag is '*tag*/audio'.
|
||||
/// * If `max_outputs` is greater than 1, the summary value tags are
|
||||
/// generated sequentially as '*tag*/audio/0', '*tag*/audio/1', etc.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * tag: Scalar. Used to build the `tag` attribute of the summary values.
|
||||
/// * tensor: 2-D of shape `[batch_size, frames]`.
|
||||
/// * sample_rate: The sample rate of the signal in hertz.
|
||||
///
|
||||
/// Optional attributes (see `Attrs`):
|
||||
/// * max_outputs: Max number of batch elements to generate audio for.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: Scalar. Serialized `Summary` protocol buffer.
|
||||
class AudioSummary {
|
||||
public:
|
||||
/// Optional attribute setters for AudioSummary
|
||||
struct Attrs {
|
||||
/// Max number of batch elements to generate audio for.
|
||||
///
|
||||
/// Defaults to 3
|
||||
TF_MUST_USE_RESULT Attrs MaxOutputs(int64 x) {
|
||||
Attrs ret = *this;
|
||||
ret.max_outputs_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int64 max_outputs_ = 3;
|
||||
};
|
||||
AudioSummary(const ::tensorflow::Scope& scope, ::tensorflow::Input tag,
|
||||
::tensorflow::Input tensor, ::tensorflow::Input sample_rate);
|
||||
AudioSummary(const ::tensorflow::Scope& scope, ::tensorflow::Input tag,
|
||||
::tensorflow::Input tensor, ::tensorflow::Input sample_rate, const
|
||||
AudioSummary::Attrs& attrs);
|
||||
operator ::tensorflow::Output() const { return summary; }
|
||||
operator ::tensorflow::Input() const { return summary; }
|
||||
::tensorflow::Node* node() const { return summary.node(); }
|
||||
|
||||
static Attrs MaxOutputs(int64 x) {
|
||||
return Attrs().MaxOutputs(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output summary;
|
||||
};
|
||||
|
||||
/// Outputs a `Summary` protocol buffer with a histogram.
|
||||
///
|
||||
/// The generated
|
||||
/// [`Summary`](https://www.tensorflow.org/code/tensorflow/core/framework/summary.proto)
|
||||
/// has one summary value containing a histogram for `values`.
|
||||
///
|
||||
/// This op reports an `InvalidArgument` error if any value is not finite.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * tag: Scalar. Tag to use for the `Summary.Value`.
|
||||
/// * values: Any shape. Values to use to build the histogram.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: Scalar. Serialized `Summary` protocol buffer.
|
||||
class HistogramSummary {
|
||||
public:
|
||||
HistogramSummary(const ::tensorflow::Scope& scope, ::tensorflow::Input tag,
|
||||
::tensorflow::Input values);
|
||||
operator ::tensorflow::Output() const { return summary; }
|
||||
operator ::tensorflow::Input() const { return summary; }
|
||||
::tensorflow::Node* node() const { return summary.node(); }
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output summary;
|
||||
};
|
||||
|
||||
/// Outputs a `Summary` protocol buffer with images.
|
||||
///
|
||||
/// The summary has up to `max_images` summary values containing images. The
|
||||
/// images are built from `tensor` which must be 4-D with shape `[batch_size,
|
||||
/// height, width, channels]` and where `channels` can be:
|
||||
///
|
||||
/// * 1: `tensor` is interpreted as Grayscale.
|
||||
/// * 3: `tensor` is interpreted as RGB.
|
||||
/// * 4: `tensor` is interpreted as RGBA.
|
||||
///
|
||||
/// The images have the same number of channels as the input tensor. For float
|
||||
/// input, the values are normalized one image at a time to fit in the range
|
||||
/// `[0, 255]`. `uint8` values are unchanged. The op uses two different
|
||||
/// normalization algorithms:
|
||||
///
|
||||
/// * If the input values are all positive, they are rescaled so the largest one
|
||||
/// is 255.
|
||||
///
|
||||
/// * If any input value is negative, the values are shifted so input value 0.0
|
||||
/// is at 127. They are then rescaled so that either the smallest value is 0,
|
||||
/// or the largest one is 255.
|
||||
///
|
||||
/// The `tag` argument is a scalar `Tensor` of type `string`. It is used to
|
||||
/// build the `tag` of the summary values:
|
||||
///
|
||||
/// * If `max_images` is 1, the summary value tag is '*tag*/image'.
|
||||
/// * If `max_images` is greater than 1, the summary value tags are
|
||||
/// generated sequentially as '*tag*/image/0', '*tag*/image/1', etc.
|
||||
///
|
||||
/// The `bad_color` argument is the color to use in the generated images for
|
||||
/// non-finite input values. It is a `uint8` 1-D tensor of length `channels`.
|
||||
/// Each element must be in the range `[0, 255]` (It represents the value of a
|
||||
/// pixel in the output image). Non-finite values in the input tensor are
|
||||
/// replaced by this tensor in the output image. The default value is the color
|
||||
/// red.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * tag: Scalar. Used to build the `tag` attribute of the summary values.
|
||||
/// * tensor: 4-D of shape `[batch_size, height, width, channels]` where
|
||||
/// `channels` is 1, 3, or 4.
|
||||
///
|
||||
/// Optional attributes (see `Attrs`):
|
||||
/// * max_images: Max number of batch elements to generate images for.
|
||||
/// * bad_color: Color to use for pixels with non-finite values.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: Scalar. Serialized `Summary` protocol buffer.
|
||||
class ImageSummary {
|
||||
public:
|
||||
/// Optional attribute setters for ImageSummary
|
||||
struct Attrs {
|
||||
/// Max number of batch elements to generate images for.
|
||||
///
|
||||
/// Defaults to 3
|
||||
TF_MUST_USE_RESULT Attrs MaxImages(int64 x) {
|
||||
Attrs ret = *this;
|
||||
ret.max_images_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// Color to use for pixels with non-finite values.
|
||||
///
|
||||
/// Defaults to Tensor<type: uint8 shape: [4] values: 255 0 0...>
|
||||
TF_MUST_USE_RESULT Attrs BadColor(const TensorProto& x) {
|
||||
Attrs ret = *this;
|
||||
ret.bad_color_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int64 max_images_ = 3;
|
||||
TensorProto bad_color_ = Input::Initializer({255, 0, 0, 255}, {4}).AsTensorProto();
|
||||
};
|
||||
ImageSummary(const ::tensorflow::Scope& scope, ::tensorflow::Input tag,
|
||||
::tensorflow::Input tensor);
|
||||
ImageSummary(const ::tensorflow::Scope& scope, ::tensorflow::Input tag,
|
||||
::tensorflow::Input tensor, const ImageSummary::Attrs& attrs);
|
||||
operator ::tensorflow::Output() const { return summary; }
|
||||
operator ::tensorflow::Input() const { return summary; }
|
||||
::tensorflow::Node* node() const { return summary.node(); }
|
||||
|
||||
static Attrs MaxImages(int64 x) {
|
||||
return Attrs().MaxImages(x);
|
||||
}
|
||||
static Attrs BadColor(const TensorProto& x) {
|
||||
return Attrs().BadColor(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output summary;
|
||||
};
|
||||
|
||||
/// Merges summaries.
|
||||
///
|
||||
/// This op creates a
|
||||
/// [`Summary`](https://www.tensorflow.org/code/tensorflow/core/framework/summary.proto)
|
||||
/// protocol buffer that contains the union of all the values in the input
|
||||
/// summaries.
|
||||
///
|
||||
/// When the Op is run, it reports an `InvalidArgument` error if multiple values
|
||||
/// in the summaries to merge use the same tag.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * inputs: Can be of any shape. Each must contain serialized `Summary` protocol
|
||||
/// buffers.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: Scalar. Serialized `Summary` protocol buffer.
|
||||
class MergeSummary {
|
||||
public:
|
||||
MergeSummary(const ::tensorflow::Scope& scope, ::tensorflow::InputList inputs);
|
||||
operator ::tensorflow::Output() const { return summary; }
|
||||
operator ::tensorflow::Input() const { return summary; }
|
||||
::tensorflow::Node* node() const { return summary.node(); }
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output summary;
|
||||
};
|
||||
|
||||
/// Prints a list of tensors.
|
||||
///
|
||||
/// Passes `input` through to `output` and prints `data` when evaluating.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * input: The tensor passed to `output`
|
||||
/// * data: A list of tensors to print out when op is evaluated.
|
||||
///
|
||||
/// Optional attributes (see `Attrs`):
|
||||
/// * message: A string, prefix of the error message.
|
||||
/// * first_n: Only log `first_n` number of times. -1 disables logging.
|
||||
/// * summarize: Only print this many entries of each tensor.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: = The unmodified `input` tensor
|
||||
class Print {
|
||||
public:
|
||||
/// Optional attribute setters for Print
|
||||
struct Attrs {
|
||||
/// A string, prefix of the error message.
|
||||
///
|
||||
/// Defaults to ""
|
||||
TF_MUST_USE_RESULT Attrs Message(StringPiece x) {
|
||||
Attrs ret = *this;
|
||||
ret.message_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// Only log `first_n` number of times. -1 disables logging.
|
||||
///
|
||||
/// Defaults to -1
|
||||
TF_MUST_USE_RESULT Attrs FirstN(int64 x) {
|
||||
Attrs ret = *this;
|
||||
ret.first_n_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// Only print this many entries of each tensor.
|
||||
///
|
||||
/// Defaults to 3
|
||||
TF_MUST_USE_RESULT Attrs Summarize(int64 x) {
|
||||
Attrs ret = *this;
|
||||
ret.summarize_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
StringPiece message_ = "";
|
||||
int64 first_n_ = -1;
|
||||
int64 summarize_ = 3;
|
||||
};
|
||||
Print(const ::tensorflow::Scope& scope, ::tensorflow::Input input,
|
||||
::tensorflow::InputList data);
|
||||
Print(const ::tensorflow::Scope& scope, ::tensorflow::Input input,
|
||||
::tensorflow::InputList data, const Print::Attrs& attrs);
|
||||
operator ::tensorflow::Output() const { return output; }
|
||||
operator ::tensorflow::Input() const { return output; }
|
||||
::tensorflow::Node* node() const { return output.node(); }
|
||||
|
||||
static Attrs Message(StringPiece x) {
|
||||
return Attrs().Message(x);
|
||||
}
|
||||
static Attrs FirstN(int64 x) {
|
||||
return Attrs().FirstN(x);
|
||||
}
|
||||
static Attrs Summarize(int64 x) {
|
||||
return Attrs().Summarize(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output;
|
||||
};
|
||||
|
||||
/// Prints a string scalar.
|
||||
///
|
||||
/// Prints a string scalar to the desired output_stream.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * input: The string scalar to print.
|
||||
///
|
||||
/// Optional attributes (see `Attrs`):
|
||||
/// * output_stream: A string specifying the output stream or logging level to print to.
|
||||
///
|
||||
/// Returns:
|
||||
/// * the created `Operation`
|
||||
class PrintV2 {
|
||||
public:
|
||||
/// Optional attribute setters for PrintV2
|
||||
struct Attrs {
|
||||
/// A string specifying the output stream or logging level to print to.
|
||||
///
|
||||
/// Defaults to "stderr"
|
||||
TF_MUST_USE_RESULT Attrs OutputStream(StringPiece x) {
|
||||
Attrs ret = *this;
|
||||
ret.output_stream_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
StringPiece output_stream_ = "stderr";
|
||||
};
|
||||
PrintV2(const ::tensorflow::Scope& scope, ::tensorflow::Input input);
|
||||
PrintV2(const ::tensorflow::Scope& scope, ::tensorflow::Input input, const
|
||||
PrintV2::Attrs& attrs);
|
||||
operator ::tensorflow::Operation() const { return operation; }
|
||||
|
||||
static Attrs OutputStream(StringPiece x) {
|
||||
return Attrs().OutputStream(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
};
|
||||
|
||||
/// Outputs a `Summary` protocol buffer with scalar values.
|
||||
///
|
||||
/// The input `tags` and `values` must have the same shape. The generated summary
|
||||
/// has a summary value for each tag-value pair in `tags` and `values`.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * tags: Tags for the summary.
|
||||
/// * values: Same shape as `tags. Values for the summary.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: Scalar. Serialized `Summary` protocol buffer.
|
||||
class ScalarSummary {
|
||||
public:
|
||||
ScalarSummary(const ::tensorflow::Scope& scope, ::tensorflow::Input tags,
|
||||
::tensorflow::Input values);
|
||||
operator ::tensorflow::Output() const { return summary; }
|
||||
operator ::tensorflow::Input() const { return summary; }
|
||||
::tensorflow::Node* node() const { return summary.node(); }
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output summary;
|
||||
};
|
||||
|
||||
/// Outputs a `Summary` protocol buffer with a tensor.
|
||||
///
|
||||
/// This op is being phased out in favor of TensorSummaryV2, which lets callers pass
|
||||
/// a tag as well as a serialized SummaryMetadata proto string that contains
|
||||
/// plugin-specific data. We will keep this op to maintain backwards compatibility.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * tensor: A tensor to serialize.
|
||||
///
|
||||
/// Optional attributes (see `Attrs`):
|
||||
/// * description: A json-encoded SummaryDescription proto.
|
||||
/// * labels: An unused list of strings.
|
||||
/// * display_name: An unused string.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: The summary tensor.
|
||||
class TensorSummary {
|
||||
public:
|
||||
/// Optional attribute setters for TensorSummary
|
||||
struct Attrs {
|
||||
/// A json-encoded SummaryDescription proto.
|
||||
///
|
||||
/// Defaults to ""
|
||||
TF_MUST_USE_RESULT Attrs Description(StringPiece x) {
|
||||
Attrs ret = *this;
|
||||
ret.description_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// An unused list of strings.
|
||||
///
|
||||
/// Defaults to []
|
||||
TF_MUST_USE_RESULT Attrs Labels(const gtl::ArraySlice<string>& x) {
|
||||
Attrs ret = *this;
|
||||
ret.labels_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// An unused string.
|
||||
///
|
||||
/// Defaults to ""
|
||||
TF_MUST_USE_RESULT Attrs DisplayName(StringPiece x) {
|
||||
Attrs ret = *this;
|
||||
ret.display_name_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
StringPiece description_ = "";
|
||||
gtl::ArraySlice<string> labels_ = {};
|
||||
StringPiece display_name_ = "";
|
||||
};
|
||||
TensorSummary(const ::tensorflow::Scope& scope, ::tensorflow::Input tensor);
|
||||
TensorSummary(const ::tensorflow::Scope& scope, ::tensorflow::Input tensor,
|
||||
const TensorSummary::Attrs& attrs);
|
||||
operator ::tensorflow::Output() const { return summary; }
|
||||
operator ::tensorflow::Input() const { return summary; }
|
||||
::tensorflow::Node* node() const { return summary.node(); }
|
||||
|
||||
static Attrs Description(StringPiece x) {
|
||||
return Attrs().Description(x);
|
||||
}
|
||||
static Attrs Labels(const gtl::ArraySlice<string>& x) {
|
||||
return Attrs().Labels(x);
|
||||
}
|
||||
static Attrs DisplayName(StringPiece x) {
|
||||
return Attrs().DisplayName(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output summary;
|
||||
};
|
||||
|
||||
/// Outputs a `Summary` protocol buffer with a tensor and per-plugin data.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * tag: A string attached to this summary. Used for organization in TensorBoard.
|
||||
/// * tensor: A tensor to serialize.
|
||||
/// * serialized_summary_metadata: A serialized SummaryMetadata proto. Contains plugin
|
||||
/// data.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: The summary tensor.
|
||||
class TensorSummaryV2 {
|
||||
public:
|
||||
TensorSummaryV2(const ::tensorflow::Scope& scope, ::tensorflow::Input tag,
|
||||
::tensorflow::Input tensor, ::tensorflow::Input
|
||||
serialized_summary_metadata);
|
||||
operator ::tensorflow::Output() const { return summary; }
|
||||
operator ::tensorflow::Input() const { return summary; }
|
||||
::tensorflow::Node* node() const { return summary.node(); }
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output summary;
|
||||
};
|
||||
|
||||
/// Provides the time since epoch in seconds.
|
||||
///
|
||||
/// Returns the timestamp as a `float64` for seconds since the Unix epoch.
|
||||
///
|
||||
/// Note: the timestamp is computed when the op is executed, not when it is added
|
||||
/// to the graph.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: The ts tensor.
|
||||
class Timestamp {
|
||||
public:
|
||||
Timestamp(const ::tensorflow::Scope& scope);
|
||||
operator ::tensorflow::Output() const { return ts; }
|
||||
operator ::tensorflow::Input() const { return ts; }
|
||||
::tensorflow::Node* node() const { return ts.node(); }
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output ts;
|
||||
};
|
||||
|
||||
/// @}
|
||||
|
||||
} // namespace ops
|
||||
} // namespace tensorflow
|
||||
|
||||
#endif // TENSORFLOW_CC_OPS_LOGGING_OPS_H_
|
||||
@@ -0,0 +1,28 @@
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#ifndef TENSORFLOW_CC_OPS_LOGGING_OPS_INTERNAL_H_
|
||||
#define TENSORFLOW_CC_OPS_LOGGING_OPS_INTERNAL_H_
|
||||
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#include "tensorflow/cc/framework/ops.h"
|
||||
#include "tensorflow/cc/framework/scope.h"
|
||||
#include "tensorflow/core/framework/tensor.h"
|
||||
#include "tensorflow/core/framework/tensor_shape.h"
|
||||
#include "tensorflow/core/framework/types.h"
|
||||
#include "tensorflow/core/lib/gtl/array_slice.h"
|
||||
|
||||
namespace tensorflow {
|
||||
namespace ops {
|
||||
namespace internal {
|
||||
// NOTE: This namespace has internal TensorFlow details that
|
||||
// are not part of TensorFlow's public API.
|
||||
|
||||
/// @defgroup logging_ops_internal Logging Ops Internal
|
||||
/// @{
|
||||
|
||||
} // namespace internal
|
||||
} // namespace ops
|
||||
} // namespace tensorflow
|
||||
|
||||
#endif // TENSORFLOW_CC_OPS_LOGGING_OPS_INTERNAL_H_
|
||||
@@ -0,0 +1,610 @@
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#ifndef TENSORFLOW_CC_OPS_LOOKUP_OPS_H_
|
||||
#define TENSORFLOW_CC_OPS_LOOKUP_OPS_H_
|
||||
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#include "tensorflow/cc/framework/ops.h"
|
||||
#include "tensorflow/cc/framework/scope.h"
|
||||
#include "tensorflow/core/framework/tensor.h"
|
||||
#include "tensorflow/core/framework/tensor_shape.h"
|
||||
#include "tensorflow/core/framework/types.h"
|
||||
#include "tensorflow/core/lib/gtl/array_slice.h"
|
||||
|
||||
namespace tensorflow {
|
||||
namespace ops {
|
||||
|
||||
/// @defgroup lookup_ops Lookup Ops
|
||||
/// @{
|
||||
|
||||
/// Creates a non-initialized hash table.
|
||||
///
|
||||
/// This op creates a hash table, specifying the type of its keys and values.
|
||||
/// Before using the table you will have to initialize it. After initialization the
|
||||
/// table will be immutable.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * key_dtype: Type of the table keys.
|
||||
/// * value_dtype: Type of the table values.
|
||||
///
|
||||
/// Optional attributes (see `Attrs`):
|
||||
/// * container: If non-empty, this table is placed in the given container.
|
||||
/// Otherwise, a default container is used.
|
||||
/// * shared_name: If non-empty, this table is shared under the given name across
|
||||
/// multiple sessions.
|
||||
/// * use_node_name_sharing: If true and shared_name is empty, the table is shared
|
||||
/// using the node name.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: Handle to a table.
|
||||
class HashTable {
|
||||
public:
|
||||
/// Optional attribute setters for HashTable
|
||||
struct Attrs {
|
||||
/// If non-empty, this table is placed in the given container.
|
||||
/// Otherwise, a default container is used.
|
||||
///
|
||||
/// Defaults to ""
|
||||
TF_MUST_USE_RESULT Attrs Container(StringPiece x) {
|
||||
Attrs ret = *this;
|
||||
ret.container_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// If non-empty, this table is shared under the given name across
|
||||
/// multiple sessions.
|
||||
///
|
||||
/// Defaults to ""
|
||||
TF_MUST_USE_RESULT Attrs SharedName(StringPiece x) {
|
||||
Attrs ret = *this;
|
||||
ret.shared_name_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// If true and shared_name is empty, the table is shared
|
||||
/// using the node name.
|
||||
///
|
||||
/// Defaults to false
|
||||
TF_MUST_USE_RESULT Attrs UseNodeNameSharing(bool x) {
|
||||
Attrs ret = *this;
|
||||
ret.use_node_name_sharing_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
StringPiece container_ = "";
|
||||
StringPiece shared_name_ = "";
|
||||
bool use_node_name_sharing_ = false;
|
||||
};
|
||||
HashTable(const ::tensorflow::Scope& scope, DataType key_dtype, DataType
|
||||
value_dtype);
|
||||
HashTable(const ::tensorflow::Scope& scope, DataType key_dtype, DataType
|
||||
value_dtype, const HashTable::Attrs& attrs);
|
||||
operator ::tensorflow::Output() const { return table_handle; }
|
||||
operator ::tensorflow::Input() const { return table_handle; }
|
||||
::tensorflow::Node* node() const { return table_handle.node(); }
|
||||
|
||||
static Attrs Container(StringPiece x) {
|
||||
return Attrs().Container(x);
|
||||
}
|
||||
static Attrs SharedName(StringPiece x) {
|
||||
return Attrs().SharedName(x);
|
||||
}
|
||||
static Attrs UseNodeNameSharing(bool x) {
|
||||
return Attrs().UseNodeNameSharing(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output table_handle;
|
||||
};
|
||||
|
||||
/// Initializes a table from a text file.
|
||||
///
|
||||
/// It inserts one key-value pair into the table for each line of the file.
|
||||
/// The key and value is extracted from the whole line content, elements from the
|
||||
/// split line based on `delimiter` or the line number (starting from zero).
|
||||
/// Where to extract the key and value from a line is specified by `key_index` and
|
||||
/// `value_index`.
|
||||
///
|
||||
/// - A value of -1 means use the line number(starting from zero), expects `int64`.
|
||||
/// - A value of -2 means use the whole line content, expects `string`.
|
||||
/// - A value >= 0 means use the index (starting at zero) of the split line based
|
||||
/// on `delimiter`.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * table_handle: Handle to a table which will be initialized.
|
||||
/// * filename: Filename of a vocabulary text file.
|
||||
/// * key_index: Column index in a line to get the table `key` values from.
|
||||
/// * value_index: Column index that represents information of a line to get the table
|
||||
/// `value` values from.
|
||||
///
|
||||
/// Optional attributes (see `Attrs`):
|
||||
/// * vocab_size: Number of elements of the file, use -1 if unknown.
|
||||
/// * delimiter: Delimiter to separate fields in a line.
|
||||
///
|
||||
/// Returns:
|
||||
/// * the created `Operation`
|
||||
class InitializeTableFromTextFile {
|
||||
public:
|
||||
/// Optional attribute setters for InitializeTableFromTextFile
|
||||
struct Attrs {
|
||||
/// Number of elements of the file, use -1 if unknown.
|
||||
///
|
||||
/// Defaults to -1
|
||||
TF_MUST_USE_RESULT Attrs VocabSize(int64 x) {
|
||||
Attrs ret = *this;
|
||||
ret.vocab_size_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// Delimiter to separate fields in a line.
|
||||
///
|
||||
/// Defaults to "\t"
|
||||
TF_MUST_USE_RESULT Attrs Delimiter(StringPiece x) {
|
||||
Attrs ret = *this;
|
||||
ret.delimiter_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int64 vocab_size_ = -1;
|
||||
StringPiece delimiter_ = "\t";
|
||||
};
|
||||
InitializeTableFromTextFile(const ::tensorflow::Scope& scope,
|
||||
::tensorflow::Input table_handle,
|
||||
::tensorflow::Input filename, int64 key_index,
|
||||
int64 value_index);
|
||||
InitializeTableFromTextFile(const ::tensorflow::Scope& scope,
|
||||
::tensorflow::Input table_handle,
|
||||
::tensorflow::Input filename, int64 key_index,
|
||||
int64 value_index, const
|
||||
InitializeTableFromTextFile::Attrs& attrs);
|
||||
operator ::tensorflow::Operation() const { return operation; }
|
||||
|
||||
static Attrs VocabSize(int64 x) {
|
||||
return Attrs().VocabSize(x);
|
||||
}
|
||||
static Attrs Delimiter(StringPiece x) {
|
||||
return Attrs().Delimiter(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
};
|
||||
|
||||
/// Table initializer that takes two tensors for keys and values respectively.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * table_handle: Handle to a table which will be initialized.
|
||||
/// * keys: Keys of type Tkey.
|
||||
/// * values: Values of type Tval.
|
||||
///
|
||||
/// Returns:
|
||||
/// * the created `Operation`
|
||||
class InitializeTable {
|
||||
public:
|
||||
InitializeTable(const ::tensorflow::Scope& scope, ::tensorflow::Input
|
||||
table_handle, ::tensorflow::Input keys, ::tensorflow::Input
|
||||
values);
|
||||
operator ::tensorflow::Operation() const { return operation; }
|
||||
|
||||
Operation operation;
|
||||
};
|
||||
|
||||
/// Outputs all keys and values in the table.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * table_handle: Handle to the table.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output` keys: Vector of all keys present in the table.
|
||||
/// * `Output` values: Tensor of all values in the table. Indexed in parallel with `keys`.
|
||||
class LookupTableExport {
|
||||
public:
|
||||
LookupTableExport(const ::tensorflow::Scope& scope, ::tensorflow::Input
|
||||
table_handle, DataType Tkeys, DataType Tvalues);
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output keys;
|
||||
::tensorflow::Output values;
|
||||
};
|
||||
|
||||
/// Looks up keys in a table, outputs the corresponding values.
|
||||
///
|
||||
/// The tensor `keys` must of the same type as the keys of the table.
|
||||
/// The output `values` is of the type of the table values.
|
||||
///
|
||||
/// The scalar `default_value` is the value output for keys not present in the
|
||||
/// table. It must also be of the same type as the table values.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * table_handle: Handle to the table.
|
||||
/// * keys: Any shape. Keys to look up.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: Same shape as `keys`. Values found in the table, or `default_values`
|
||||
/// for missing keys.
|
||||
class LookupTableFind {
|
||||
public:
|
||||
LookupTableFind(const ::tensorflow::Scope& scope, ::tensorflow::Input
|
||||
table_handle, ::tensorflow::Input keys, ::tensorflow::Input
|
||||
default_value);
|
||||
operator ::tensorflow::Output() const { return values; }
|
||||
operator ::tensorflow::Input() const { return values; }
|
||||
::tensorflow::Node* node() const { return values.node(); }
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output values;
|
||||
};
|
||||
|
||||
/// Replaces the contents of the table with the specified keys and values.
|
||||
///
|
||||
/// The tensor `keys` must be of the same type as the keys of the table.
|
||||
/// The tensor `values` must be of the type of the table values.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * table_handle: Handle to the table.
|
||||
/// * keys: Any shape. Keys to look up.
|
||||
/// * values: Values to associate with keys.
|
||||
///
|
||||
/// Returns:
|
||||
/// * the created `Operation`
|
||||
class LookupTableImport {
|
||||
public:
|
||||
LookupTableImport(const ::tensorflow::Scope& scope, ::tensorflow::Input
|
||||
table_handle, ::tensorflow::Input keys, ::tensorflow::Input
|
||||
values);
|
||||
operator ::tensorflow::Operation() const { return operation; }
|
||||
|
||||
Operation operation;
|
||||
};
|
||||
|
||||
/// Updates the table to associates keys with values.
|
||||
///
|
||||
/// The tensor `keys` must be of the same type as the keys of the table.
|
||||
/// The tensor `values` must be of the type of the table values.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * table_handle: Handle to the table.
|
||||
/// * keys: Any shape. Keys to look up.
|
||||
/// * values: Values to associate with keys.
|
||||
///
|
||||
/// Returns:
|
||||
/// * the created `Operation`
|
||||
class LookupTableInsert {
|
||||
public:
|
||||
LookupTableInsert(const ::tensorflow::Scope& scope, ::tensorflow::Input
|
||||
table_handle, ::tensorflow::Input keys, ::tensorflow::Input
|
||||
values);
|
||||
operator ::tensorflow::Operation() const { return operation; }
|
||||
|
||||
Operation operation;
|
||||
};
|
||||
|
||||
/// Computes the number of elements in the given table.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * table_handle: Handle to the table.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: Scalar that contains number of elements in the table.
|
||||
class LookupTableSize {
|
||||
public:
|
||||
LookupTableSize(const ::tensorflow::Scope& scope, ::tensorflow::Input
|
||||
table_handle);
|
||||
operator ::tensorflow::Output() const { return size; }
|
||||
operator ::tensorflow::Input() const { return size; }
|
||||
::tensorflow::Node* node() const { return size.node(); }
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output size;
|
||||
};
|
||||
|
||||
/// Creates an empty hash table that uses tensors as the backing store.
|
||||
///
|
||||
/// It uses "open addressing" with quadratic reprobing to resolve
|
||||
/// collisions.
|
||||
///
|
||||
/// This op creates a mutable hash table, specifying the type of its keys and
|
||||
/// values. Each value must be a scalar. Data can be inserted into the table using
|
||||
/// the insert operations. It does not support the initialization operation.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * empty_key: The key used to represent empty key buckets internally. Must not
|
||||
/// be used in insert or lookup operations.
|
||||
/// * value_dtype: Type of the table values.
|
||||
///
|
||||
/// Optional attributes (see `Attrs`):
|
||||
/// * container: If non-empty, this table is placed in the given container.
|
||||
/// Otherwise, a default container is used.
|
||||
/// * shared_name: If non-empty, this table is shared under the given name across
|
||||
/// multiple sessions.
|
||||
/// * value_shape: The shape of each value.
|
||||
/// * initial_num_buckets: The initial number of hash table buckets. Must be a power
|
||||
/// to 2.
|
||||
/// * max_load_factor: The maximum ratio between number of entries and number of
|
||||
/// buckets before growing the table. Must be between 0 and 1.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: Handle to a table.
|
||||
class MutableDenseHashTable {
|
||||
public:
|
||||
/// Optional attribute setters for MutableDenseHashTable
|
||||
struct Attrs {
|
||||
/// If non-empty, this table is placed in the given container.
|
||||
/// Otherwise, a default container is used.
|
||||
///
|
||||
/// Defaults to ""
|
||||
TF_MUST_USE_RESULT Attrs Container(StringPiece x) {
|
||||
Attrs ret = *this;
|
||||
ret.container_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// If non-empty, this table is shared under the given name across
|
||||
/// multiple sessions.
|
||||
///
|
||||
/// Defaults to ""
|
||||
TF_MUST_USE_RESULT Attrs SharedName(StringPiece x) {
|
||||
Attrs ret = *this;
|
||||
ret.shared_name_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// Defaults to false
|
||||
TF_MUST_USE_RESULT Attrs UseNodeNameSharing(bool x) {
|
||||
Attrs ret = *this;
|
||||
ret.use_node_name_sharing_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// The shape of each value.
|
||||
///
|
||||
/// Defaults to []
|
||||
TF_MUST_USE_RESULT Attrs ValueShape(PartialTensorShape x) {
|
||||
Attrs ret = *this;
|
||||
ret.value_shape_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// The initial number of hash table buckets. Must be a power
|
||||
/// to 2.
|
||||
///
|
||||
/// Defaults to 131072
|
||||
TF_MUST_USE_RESULT Attrs InitialNumBuckets(int64 x) {
|
||||
Attrs ret = *this;
|
||||
ret.initial_num_buckets_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// The maximum ratio between number of entries and number of
|
||||
/// buckets before growing the table. Must be between 0 and 1.
|
||||
///
|
||||
/// Defaults to 0.8
|
||||
TF_MUST_USE_RESULT Attrs MaxLoadFactor(float x) {
|
||||
Attrs ret = *this;
|
||||
ret.max_load_factor_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
StringPiece container_ = "";
|
||||
StringPiece shared_name_ = "";
|
||||
bool use_node_name_sharing_ = false;
|
||||
PartialTensorShape value_shape_ = {};
|
||||
int64 initial_num_buckets_ = 131072;
|
||||
float max_load_factor_ = 0.8f;
|
||||
};
|
||||
MutableDenseHashTable(const ::tensorflow::Scope& scope, ::tensorflow::Input
|
||||
empty_key, DataType value_dtype);
|
||||
MutableDenseHashTable(const ::tensorflow::Scope& scope, ::tensorflow::Input
|
||||
empty_key, DataType value_dtype, const
|
||||
MutableDenseHashTable::Attrs& attrs);
|
||||
operator ::tensorflow::Output() const { return table_handle; }
|
||||
operator ::tensorflow::Input() const { return table_handle; }
|
||||
::tensorflow::Node* node() const { return table_handle.node(); }
|
||||
|
||||
static Attrs Container(StringPiece x) {
|
||||
return Attrs().Container(x);
|
||||
}
|
||||
static Attrs SharedName(StringPiece x) {
|
||||
return Attrs().SharedName(x);
|
||||
}
|
||||
static Attrs UseNodeNameSharing(bool x) {
|
||||
return Attrs().UseNodeNameSharing(x);
|
||||
}
|
||||
static Attrs ValueShape(PartialTensorShape x) {
|
||||
return Attrs().ValueShape(x);
|
||||
}
|
||||
static Attrs InitialNumBuckets(int64 x) {
|
||||
return Attrs().InitialNumBuckets(x);
|
||||
}
|
||||
static Attrs MaxLoadFactor(float x) {
|
||||
return Attrs().MaxLoadFactor(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output table_handle;
|
||||
};
|
||||
|
||||
/// Creates an empty hash table.
|
||||
///
|
||||
/// This op creates a mutable hash table, specifying the type of its keys and
|
||||
/// values. Each value must be a vector. Data can be inserted into the table using
|
||||
/// the insert operations. It does not support the initialization operation.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * key_dtype: Type of the table keys.
|
||||
/// * value_dtype: Type of the table values.
|
||||
///
|
||||
/// Optional attributes (see `Attrs`):
|
||||
/// * container: If non-empty, this table is placed in the given container.
|
||||
/// Otherwise, a default container is used.
|
||||
/// * shared_name: If non-empty, this table is shared under the given name across
|
||||
/// multiple sessions.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: Handle to a table.
|
||||
class MutableHashTableOfTensors {
|
||||
public:
|
||||
/// Optional attribute setters for MutableHashTableOfTensors
|
||||
struct Attrs {
|
||||
/// If non-empty, this table is placed in the given container.
|
||||
/// Otherwise, a default container is used.
|
||||
///
|
||||
/// Defaults to ""
|
||||
TF_MUST_USE_RESULT Attrs Container(StringPiece x) {
|
||||
Attrs ret = *this;
|
||||
ret.container_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// If non-empty, this table is shared under the given name across
|
||||
/// multiple sessions.
|
||||
///
|
||||
/// Defaults to ""
|
||||
TF_MUST_USE_RESULT Attrs SharedName(StringPiece x) {
|
||||
Attrs ret = *this;
|
||||
ret.shared_name_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// Defaults to false
|
||||
TF_MUST_USE_RESULT Attrs UseNodeNameSharing(bool x) {
|
||||
Attrs ret = *this;
|
||||
ret.use_node_name_sharing_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// Defaults to []
|
||||
TF_MUST_USE_RESULT Attrs ValueShape(PartialTensorShape x) {
|
||||
Attrs ret = *this;
|
||||
ret.value_shape_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
StringPiece container_ = "";
|
||||
StringPiece shared_name_ = "";
|
||||
bool use_node_name_sharing_ = false;
|
||||
PartialTensorShape value_shape_ = {};
|
||||
};
|
||||
MutableHashTableOfTensors(const ::tensorflow::Scope& scope, DataType key_dtype,
|
||||
DataType value_dtype);
|
||||
MutableHashTableOfTensors(const ::tensorflow::Scope& scope, DataType key_dtype,
|
||||
DataType value_dtype, const
|
||||
MutableHashTableOfTensors::Attrs& attrs);
|
||||
operator ::tensorflow::Output() const { return table_handle; }
|
||||
operator ::tensorflow::Input() const { return table_handle; }
|
||||
::tensorflow::Node* node() const { return table_handle.node(); }
|
||||
|
||||
static Attrs Container(StringPiece x) {
|
||||
return Attrs().Container(x);
|
||||
}
|
||||
static Attrs SharedName(StringPiece x) {
|
||||
return Attrs().SharedName(x);
|
||||
}
|
||||
static Attrs UseNodeNameSharing(bool x) {
|
||||
return Attrs().UseNodeNameSharing(x);
|
||||
}
|
||||
static Attrs ValueShape(PartialTensorShape x) {
|
||||
return Attrs().ValueShape(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output table_handle;
|
||||
};
|
||||
|
||||
/// Creates an empty hash table.
|
||||
///
|
||||
/// This op creates a mutable hash table, specifying the type of its keys and
|
||||
/// values. Each value must be a scalar. Data can be inserted into the table using
|
||||
/// the insert operations. It does not support the initialization operation.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * key_dtype: Type of the table keys.
|
||||
/// * value_dtype: Type of the table values.
|
||||
///
|
||||
/// Optional attributes (see `Attrs`):
|
||||
/// * container: If non-empty, this table is placed in the given container.
|
||||
/// Otherwise, a default container is used.
|
||||
/// * shared_name: If non-empty, this table is shared under the given name across
|
||||
/// multiple sessions.
|
||||
/// * use_node_name_sharing: If true and shared_name is empty, the table is shared
|
||||
/// using the node name.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: Handle to a table.
|
||||
class MutableHashTable {
|
||||
public:
|
||||
/// Optional attribute setters for MutableHashTable
|
||||
struct Attrs {
|
||||
/// If non-empty, this table is placed in the given container.
|
||||
/// Otherwise, a default container is used.
|
||||
///
|
||||
/// Defaults to ""
|
||||
TF_MUST_USE_RESULT Attrs Container(StringPiece x) {
|
||||
Attrs ret = *this;
|
||||
ret.container_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// If non-empty, this table is shared under the given name across
|
||||
/// multiple sessions.
|
||||
///
|
||||
/// Defaults to ""
|
||||
TF_MUST_USE_RESULT Attrs SharedName(StringPiece x) {
|
||||
Attrs ret = *this;
|
||||
ret.shared_name_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// If true and shared_name is empty, the table is shared
|
||||
/// using the node name.
|
||||
///
|
||||
/// Defaults to false
|
||||
TF_MUST_USE_RESULT Attrs UseNodeNameSharing(bool x) {
|
||||
Attrs ret = *this;
|
||||
ret.use_node_name_sharing_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
StringPiece container_ = "";
|
||||
StringPiece shared_name_ = "";
|
||||
bool use_node_name_sharing_ = false;
|
||||
};
|
||||
MutableHashTable(const ::tensorflow::Scope& scope, DataType key_dtype, DataType
|
||||
value_dtype);
|
||||
MutableHashTable(const ::tensorflow::Scope& scope, DataType key_dtype, DataType
|
||||
value_dtype, const MutableHashTable::Attrs& attrs);
|
||||
operator ::tensorflow::Output() const { return table_handle; }
|
||||
operator ::tensorflow::Input() const { return table_handle; }
|
||||
::tensorflow::Node* node() const { return table_handle.node(); }
|
||||
|
||||
static Attrs Container(StringPiece x) {
|
||||
return Attrs().Container(x);
|
||||
}
|
||||
static Attrs SharedName(StringPiece x) {
|
||||
return Attrs().SharedName(x);
|
||||
}
|
||||
static Attrs UseNodeNameSharing(bool x) {
|
||||
return Attrs().UseNodeNameSharing(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output table_handle;
|
||||
};
|
||||
|
||||
/// @}
|
||||
|
||||
} // namespace ops
|
||||
} // namespace tensorflow
|
||||
|
||||
#endif // TENSORFLOW_CC_OPS_LOOKUP_OPS_H_
|
||||
@@ -0,0 +1,28 @@
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#ifndef TENSORFLOW_CC_OPS_LOOKUP_OPS_INTERNAL_H_
|
||||
#define TENSORFLOW_CC_OPS_LOOKUP_OPS_INTERNAL_H_
|
||||
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#include "tensorflow/cc/framework/ops.h"
|
||||
#include "tensorflow/cc/framework/scope.h"
|
||||
#include "tensorflow/core/framework/tensor.h"
|
||||
#include "tensorflow/core/framework/tensor_shape.h"
|
||||
#include "tensorflow/core/framework/types.h"
|
||||
#include "tensorflow/core/lib/gtl/array_slice.h"
|
||||
|
||||
namespace tensorflow {
|
||||
namespace ops {
|
||||
namespace internal {
|
||||
// NOTE: This namespace has internal TensorFlow details that
|
||||
// are not part of TensorFlow's public API.
|
||||
|
||||
/// @defgroup lookup_ops_internal Lookup Ops Internal
|
||||
/// @{
|
||||
|
||||
} // namespace internal
|
||||
} // namespace ops
|
||||
} // namespace tensorflow
|
||||
|
||||
#endif // TENSORFLOW_CC_OPS_LOOKUP_OPS_INTERNAL_H_
|
||||
@@ -0,0 +1,76 @@
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#ifndef TENSORFLOW_CC_OPS_MANIP_OPS_H_
|
||||
#define TENSORFLOW_CC_OPS_MANIP_OPS_H_
|
||||
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#include "tensorflow/cc/framework/ops.h"
|
||||
#include "tensorflow/cc/framework/scope.h"
|
||||
#include "tensorflow/core/framework/tensor.h"
|
||||
#include "tensorflow/core/framework/tensor_shape.h"
|
||||
#include "tensorflow/core/framework/types.h"
|
||||
#include "tensorflow/core/lib/gtl/array_slice.h"
|
||||
|
||||
namespace tensorflow {
|
||||
namespace ops {
|
||||
|
||||
/// @defgroup manip_ops Manip Ops
|
||||
/// @{
|
||||
|
||||
/// Rolls the elements of a tensor along an axis.
|
||||
///
|
||||
/// The elements are shifted positively (towards larger indices) by the offset of
|
||||
/// `shift` along the dimension of `axis`. Negative `shift` values will shift
|
||||
/// elements in the opposite direction. Elements that roll passed the last position
|
||||
/// will wrap around to the first and vice versa. Multiple shifts along multiple
|
||||
/// axes may be specified.
|
||||
///
|
||||
/// For example:
|
||||
///
|
||||
/// ```
|
||||
/// # 't' is [0, 1, 2, 3, 4]
|
||||
/// roll(t, shift=2, axis=0) ==> [3, 4, 0, 1, 2]
|
||||
///
|
||||
/// # shifting along multiple dimensions
|
||||
/// # 't' is [[0, 1, 2, 3, 4], [5, 6, 7, 8, 9]]
|
||||
/// roll(t, shift=[1, -2], axis=[0, 1]) ==> [[7, 8, 9, 5, 6], [2, 3, 4, 0, 1]]
|
||||
///
|
||||
/// # shifting along the same axis multiple times
|
||||
/// # 't' is [[0, 1, 2, 3, 4], [5, 6, 7, 8, 9]]
|
||||
/// roll(t, shift=[2, -3], axis=[1, 1]) ==> [[1, 2, 3, 4, 0], [6, 7, 8, 9, 5]]
|
||||
/// ```
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * shift: Dimension must be 0-D or 1-D. `shift[i]` specifies the number of places by which
|
||||
/// elements are shifted positively (towards larger indices) along the dimension
|
||||
/// specified by `axis[i]`. Negative shifts will roll the elements in the opposite
|
||||
/// direction.
|
||||
/// * axis: Dimension must be 0-D or 1-D. `axis[i]` specifies the dimension that the shift
|
||||
/// `shift[i]` should occur. If the same axis is referenced more than once, the
|
||||
/// total shift for that axis will be the sum of all the shifts that belong to that
|
||||
/// axis.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: Has the same shape and size as the input. The elements are shifted
|
||||
/// positively (towards larger indices) by the offsets of `shift` along the
|
||||
/// dimensions of `axis`.
|
||||
class Roll {
|
||||
public:
|
||||
Roll(const ::tensorflow::Scope& scope, ::tensorflow::Input input,
|
||||
::tensorflow::Input shift, ::tensorflow::Input axis);
|
||||
operator ::tensorflow::Output() const { return output; }
|
||||
operator ::tensorflow::Input() const { return output; }
|
||||
::tensorflow::Node* node() const { return output.node(); }
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output;
|
||||
};
|
||||
|
||||
/// @}
|
||||
|
||||
} // namespace ops
|
||||
} // namespace tensorflow
|
||||
|
||||
#endif // TENSORFLOW_CC_OPS_MANIP_OPS_H_
|
||||
@@ -0,0 +1,28 @@
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#ifndef TENSORFLOW_CC_OPS_MANIP_OPS_INTERNAL_H_
|
||||
#define TENSORFLOW_CC_OPS_MANIP_OPS_INTERNAL_H_
|
||||
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#include "tensorflow/cc/framework/ops.h"
|
||||
#include "tensorflow/cc/framework/scope.h"
|
||||
#include "tensorflow/core/framework/tensor.h"
|
||||
#include "tensorflow/core/framework/tensor_shape.h"
|
||||
#include "tensorflow/core/framework/types.h"
|
||||
#include "tensorflow/core/lib/gtl/array_slice.h"
|
||||
|
||||
namespace tensorflow {
|
||||
namespace ops {
|
||||
namespace internal {
|
||||
// NOTE: This namespace has internal TensorFlow details that
|
||||
// are not part of TensorFlow's public API.
|
||||
|
||||
/// @defgroup manip_ops_internal Manip Ops Internal
|
||||
/// @{
|
||||
|
||||
} // namespace internal
|
||||
} // namespace ops
|
||||
} // namespace tensorflow
|
||||
|
||||
#endif // TENSORFLOW_CC_OPS_MANIP_OPS_INTERNAL_H_
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,179 @@
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#ifndef TENSORFLOW_CC_OPS_MATH_OPS_INTERNAL_H_
|
||||
#define TENSORFLOW_CC_OPS_MATH_OPS_INTERNAL_H_
|
||||
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#include "tensorflow/cc/framework/ops.h"
|
||||
#include "tensorflow/cc/framework/scope.h"
|
||||
#include "tensorflow/core/framework/tensor.h"
|
||||
#include "tensorflow/core/framework/tensor_shape.h"
|
||||
#include "tensorflow/core/framework/types.h"
|
||||
#include "tensorflow/core/lib/gtl/array_slice.h"
|
||||
|
||||
namespace tensorflow {
|
||||
namespace ops {
|
||||
namespace internal {
|
||||
// NOTE: This namespace has internal TensorFlow details that
|
||||
// are not part of TensorFlow's public API.
|
||||
|
||||
/// @defgroup math_ops_internal Math Ops Internal
|
||||
/// @{
|
||||
|
||||
/// Computes the gradient of `igamma(a, x)` wrt `a`.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: The z tensor.
|
||||
class IgammaGradA {
|
||||
public:
|
||||
IgammaGradA(const ::tensorflow::Scope& scope, ::tensorflow::Input a,
|
||||
::tensorflow::Input x);
|
||||
operator ::tensorflow::Output() const { return z; }
|
||||
operator ::tensorflow::Input() const { return z; }
|
||||
::tensorflow::Node* node() const { return z.node(); }
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output z;
|
||||
};
|
||||
|
||||
/// Computes the gradient for the inverse of `x` wrt its input.
|
||||
///
|
||||
/// Specifically, `grad = -dy * y*y`, where `y = 1/x`, and `dy`
|
||||
/// is the corresponding input gradient.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: The z tensor.
|
||||
class InvGrad {
|
||||
public:
|
||||
InvGrad(const ::tensorflow::Scope& scope, ::tensorflow::Input y,
|
||||
::tensorflow::Input dy);
|
||||
operator ::tensorflow::Output() const { return z; }
|
||||
operator ::tensorflow::Input() const { return z; }
|
||||
::tensorflow::Node* node() const { return z.node(); }
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output z;
|
||||
};
|
||||
|
||||
/// Computes the gradient for the inverse of `x` wrt its input.
|
||||
///
|
||||
/// Specifically, `grad = -dy * y*y`, where `y = 1/x`, and `dy`
|
||||
/// is the corresponding input gradient.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: The z tensor.
|
||||
class ReciprocalGrad {
|
||||
public:
|
||||
ReciprocalGrad(const ::tensorflow::Scope& scope, ::tensorflow::Input y,
|
||||
::tensorflow::Input dy);
|
||||
operator ::tensorflow::Output() const { return z; }
|
||||
operator ::tensorflow::Input() const { return z; }
|
||||
::tensorflow::Node* node() const { return z.node(); }
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output z;
|
||||
};
|
||||
|
||||
/// Computes the gradient for the rsqrt of `x` wrt its input.
|
||||
///
|
||||
/// Specifically, `grad = dy * -0.5 * y^3`, where `y = rsqrt(x)`, and `dy`
|
||||
/// is the corresponding input gradient.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: The z tensor.
|
||||
class RsqrtGrad {
|
||||
public:
|
||||
RsqrtGrad(const ::tensorflow::Scope& scope, ::tensorflow::Input y,
|
||||
::tensorflow::Input dy);
|
||||
operator ::tensorflow::Output() const { return z; }
|
||||
operator ::tensorflow::Input() const { return z; }
|
||||
::tensorflow::Node* node() const { return z.node(); }
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output z;
|
||||
};
|
||||
|
||||
/// Computes the gradient of the sigmoid of `x` wrt its input.
|
||||
///
|
||||
/// Specifically, `grad = dy * y * (1 - y)`, where `y = sigmoid(x)`, and
|
||||
/// `dy` is the corresponding input gradient.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: The z tensor.
|
||||
class SigmoidGrad {
|
||||
public:
|
||||
SigmoidGrad(const ::tensorflow::Scope& scope, ::tensorflow::Input y,
|
||||
::tensorflow::Input dy);
|
||||
operator ::tensorflow::Output() const { return z; }
|
||||
operator ::tensorflow::Input() const { return z; }
|
||||
::tensorflow::Node* node() const { return z.node(); }
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output z;
|
||||
};
|
||||
|
||||
/// Computes the gradient for the sqrt of `x` wrt its input.
|
||||
///
|
||||
/// Specifically, `grad = dy * 0.5 / y`, where `y = sqrt(x)`, and `dy`
|
||||
/// is the corresponding input gradient.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: The z tensor.
|
||||
class SqrtGrad {
|
||||
public:
|
||||
SqrtGrad(const ::tensorflow::Scope& scope, ::tensorflow::Input y,
|
||||
::tensorflow::Input dy);
|
||||
operator ::tensorflow::Output() const { return z; }
|
||||
operator ::tensorflow::Input() const { return z; }
|
||||
::tensorflow::Node* node() const { return z.node(); }
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output z;
|
||||
};
|
||||
|
||||
/// Computes the gradient for the tanh of `x` wrt its input.
|
||||
///
|
||||
/// Specifically, `grad = dy * (1 - y*y)`, where `y = tanh(x)`, and `dy`
|
||||
/// is the corresponding input gradient.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: The z tensor.
|
||||
class TanhGrad {
|
||||
public:
|
||||
TanhGrad(const ::tensorflow::Scope& scope, ::tensorflow::Input y,
|
||||
::tensorflow::Input dy);
|
||||
operator ::tensorflow::Output() const { return z; }
|
||||
operator ::tensorflow::Input() const { return z; }
|
||||
::tensorflow::Node* node() const { return z.node(); }
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output z;
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
} // namespace ops
|
||||
} // namespace tensorflow
|
||||
|
||||
#endif // TENSORFLOW_CC_OPS_MATH_OPS_INTERNAL_H_
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,541 @@
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#ifndef TENSORFLOW_CC_OPS_NN_OPS_INTERNAL_H_
|
||||
#define TENSORFLOW_CC_OPS_NN_OPS_INTERNAL_H_
|
||||
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#include "tensorflow/cc/framework/ops.h"
|
||||
#include "tensorflow/cc/framework/scope.h"
|
||||
#include "tensorflow/core/framework/tensor.h"
|
||||
#include "tensorflow/core/framework/tensor_shape.h"
|
||||
#include "tensorflow/core/framework/types.h"
|
||||
#include "tensorflow/core/lib/gtl/array_slice.h"
|
||||
|
||||
namespace tensorflow {
|
||||
namespace ops {
|
||||
namespace internal {
|
||||
// NOTE: This namespace has internal TensorFlow details that
|
||||
// are not part of TensorFlow's public API.
|
||||
|
||||
/// @defgroup nn_ops_internal Nn Ops Internal
|
||||
/// @{
|
||||
|
||||
/// Computes gradients of the average pooling function.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * orig_input_shape: 1-D. Shape of the original input to `avg_pool`.
|
||||
/// * grad: 4-D with shape `[batch, height, width, channels]`. Gradients w.r.t.
|
||||
/// the output of `avg_pool`.
|
||||
/// * ksize: The size of the sliding window for each dimension of the input.
|
||||
/// * strides: The stride of the sliding window for each dimension of the input.
|
||||
/// * padding: The type of padding algorithm to use.
|
||||
///
|
||||
/// Optional attributes (see `Attrs`):
|
||||
/// * data_format: Specify the data format of the input and output data. With the
|
||||
/// default format "NHWC", the data is stored in the order of:
|
||||
/// [batch, in_height, in_width, in_channels].
|
||||
/// Alternatively, the format could be "NCHW", the data storage order of:
|
||||
/// [batch, in_channels, in_height, in_width].
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: 4-D. Gradients w.r.t. the input of `avg_pool`.
|
||||
class AvgPoolGrad {
|
||||
public:
|
||||
/// Optional attribute setters for AvgPoolGrad
|
||||
struct Attrs {
|
||||
/// Specify the data format of the input and output data. With the
|
||||
/// default format "NHWC", the data is stored in the order of:
|
||||
/// [batch, in_height, in_width, in_channels].
|
||||
/// Alternatively, the format could be "NCHW", the data storage order of:
|
||||
/// [batch, in_channels, in_height, in_width].
|
||||
///
|
||||
/// Defaults to "NHWC"
|
||||
TF_MUST_USE_RESULT Attrs DataFormat(StringPiece x) {
|
||||
Attrs ret = *this;
|
||||
ret.data_format_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
StringPiece data_format_ = "NHWC";
|
||||
};
|
||||
AvgPoolGrad(const ::tensorflow::Scope& scope, ::tensorflow::Input
|
||||
orig_input_shape, ::tensorflow::Input grad, const
|
||||
gtl::ArraySlice<int>& ksize, const gtl::ArraySlice<int>& strides,
|
||||
StringPiece padding);
|
||||
AvgPoolGrad(const ::tensorflow::Scope& scope, ::tensorflow::Input
|
||||
orig_input_shape, ::tensorflow::Input grad, const
|
||||
gtl::ArraySlice<int>& ksize, const gtl::ArraySlice<int>& strides,
|
||||
StringPiece padding, const AvgPoolGrad::Attrs& attrs);
|
||||
operator ::tensorflow::Output() const { return output; }
|
||||
operator ::tensorflow::Input() const { return output; }
|
||||
::tensorflow::Node* node() const { return output.node(); }
|
||||
|
||||
static Attrs DataFormat(StringPiece x) {
|
||||
return Attrs().DataFormat(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output;
|
||||
};
|
||||
|
||||
/// Computes gradients for the exponential linear (Elu) operation.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * gradients: The backpropagated gradients to the corresponding Elu operation.
|
||||
/// * outputs: The outputs of the corresponding Elu operation.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: The gradients: `gradients * (outputs + 1)` if outputs < 0,
|
||||
/// `gradients` otherwise.
|
||||
class EluGrad {
|
||||
public:
|
||||
EluGrad(const ::tensorflow::Scope& scope, ::tensorflow::Input gradients,
|
||||
::tensorflow::Input outputs);
|
||||
operator ::tensorflow::Output() const { return backprops; }
|
||||
operator ::tensorflow::Input() const { return backprops; }
|
||||
::tensorflow::Node* node() const { return backprops.node(); }
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output backprops;
|
||||
};
|
||||
|
||||
/// Computes gradient of the FractionalAvgPool function.
|
||||
///
|
||||
/// Unlike FractionalMaxPoolGrad, we don't need to find arg_max for
|
||||
/// FractionalAvgPoolGrad, we just need to evenly back-propagate each element of
|
||||
/// out_backprop to those indices that form the same pooling cell. Therefore, we
|
||||
/// just need to know the shape of original input tensor, instead of the whole
|
||||
/// tensor.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * orig_input_tensor_shape: Original input tensor shape for `fractional_avg_pool`
|
||||
/// * out_backprop: 4-D with shape `[batch, height, width, channels]`. Gradients
|
||||
/// w.r.t. the output of `fractional_avg_pool`.
|
||||
/// * row_pooling_sequence: row pooling sequence, form pooling region with
|
||||
/// col_pooling_sequence.
|
||||
/// * col_pooling_sequence: column pooling sequence, form pooling region with
|
||||
/// row_pooling sequence.
|
||||
///
|
||||
/// Optional attributes (see `Attrs`):
|
||||
/// * overlapping: When set to True, it means when pooling, the values at the boundary
|
||||
/// of adjacent pooling cells are used by both cells. For example:
|
||||
///
|
||||
/// `index 0 1 2 3 4`
|
||||
///
|
||||
/// `value 20 5 16 3 7`
|
||||
///
|
||||
/// If the pooling sequence is [0, 2, 4], then 16, at index 2 will be used twice.
|
||||
/// The result would be [41/3, 26/3] for fractional avg pooling.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: 4-D. Gradients w.r.t. the input of `fractional_avg_pool`.
|
||||
class FractionalAvgPoolGrad {
|
||||
public:
|
||||
/// Optional attribute setters for FractionalAvgPoolGrad
|
||||
struct Attrs {
|
||||
/// When set to True, it means when pooling, the values at the boundary
|
||||
/// of adjacent pooling cells are used by both cells. For example:
|
||||
///
|
||||
/// `index 0 1 2 3 4`
|
||||
///
|
||||
/// `value 20 5 16 3 7`
|
||||
///
|
||||
/// If the pooling sequence is [0, 2, 4], then 16, at index 2 will be used twice.
|
||||
/// The result would be [41/3, 26/3] for fractional avg pooling.
|
||||
///
|
||||
/// Defaults to false
|
||||
TF_MUST_USE_RESULT Attrs Overlapping(bool x) {
|
||||
Attrs ret = *this;
|
||||
ret.overlapping_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool overlapping_ = false;
|
||||
};
|
||||
FractionalAvgPoolGrad(const ::tensorflow::Scope& scope, ::tensorflow::Input
|
||||
orig_input_tensor_shape, ::tensorflow::Input
|
||||
out_backprop, ::tensorflow::Input row_pooling_sequence,
|
||||
::tensorflow::Input col_pooling_sequence);
|
||||
FractionalAvgPoolGrad(const ::tensorflow::Scope& scope, ::tensorflow::Input
|
||||
orig_input_tensor_shape, ::tensorflow::Input
|
||||
out_backprop, ::tensorflow::Input row_pooling_sequence,
|
||||
::tensorflow::Input col_pooling_sequence, const
|
||||
FractionalAvgPoolGrad::Attrs& attrs);
|
||||
operator ::tensorflow::Output() const { return output; }
|
||||
operator ::tensorflow::Input() const { return output; }
|
||||
::tensorflow::Node* node() const { return output.node(); }
|
||||
|
||||
static Attrs Overlapping(bool x) {
|
||||
return Attrs().Overlapping(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output;
|
||||
};
|
||||
|
||||
/// Computes gradient of the FractionalMaxPool function.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * orig_input: Original input for `fractional_max_pool`
|
||||
/// * orig_output: Original output for `fractional_max_pool`
|
||||
/// * out_backprop: 4-D with shape `[batch, height, width, channels]`. Gradients
|
||||
/// w.r.t. the output of `fractional_max_pool`.
|
||||
/// * row_pooling_sequence: row pooling sequence, form pooling region with
|
||||
/// col_pooling_sequence.
|
||||
/// * col_pooling_sequence: column pooling sequence, form pooling region with
|
||||
/// row_pooling sequence.
|
||||
///
|
||||
/// Optional attributes (see `Attrs`):
|
||||
/// * overlapping: When set to True, it means when pooling, the values at the boundary
|
||||
/// of adjacent pooling cells are used by both cells. For example:
|
||||
///
|
||||
/// `index 0 1 2 3 4`
|
||||
///
|
||||
/// `value 20 5 16 3 7`
|
||||
///
|
||||
/// If the pooling sequence is [0, 2, 4], then 16, at index 2 will be used twice.
|
||||
/// The result would be [20, 16] for fractional max pooling.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: 4-D. Gradients w.r.t. the input of `fractional_max_pool`.
|
||||
class FractionalMaxPoolGrad {
|
||||
public:
|
||||
/// Optional attribute setters for FractionalMaxPoolGrad
|
||||
struct Attrs {
|
||||
/// When set to True, it means when pooling, the values at the boundary
|
||||
/// of adjacent pooling cells are used by both cells. For example:
|
||||
///
|
||||
/// `index 0 1 2 3 4`
|
||||
///
|
||||
/// `value 20 5 16 3 7`
|
||||
///
|
||||
/// If the pooling sequence is [0, 2, 4], then 16, at index 2 will be used twice.
|
||||
/// The result would be [20, 16] for fractional max pooling.
|
||||
///
|
||||
/// Defaults to false
|
||||
TF_MUST_USE_RESULT Attrs Overlapping(bool x) {
|
||||
Attrs ret = *this;
|
||||
ret.overlapping_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool overlapping_ = false;
|
||||
};
|
||||
FractionalMaxPoolGrad(const ::tensorflow::Scope& scope, ::tensorflow::Input
|
||||
orig_input, ::tensorflow::Input orig_output,
|
||||
::tensorflow::Input out_backprop, ::tensorflow::Input
|
||||
row_pooling_sequence, ::tensorflow::Input
|
||||
col_pooling_sequence);
|
||||
FractionalMaxPoolGrad(const ::tensorflow::Scope& scope, ::tensorflow::Input
|
||||
orig_input, ::tensorflow::Input orig_output,
|
||||
::tensorflow::Input out_backprop, ::tensorflow::Input
|
||||
row_pooling_sequence, ::tensorflow::Input
|
||||
col_pooling_sequence, const FractionalMaxPoolGrad::Attrs&
|
||||
attrs);
|
||||
operator ::tensorflow::Output() const { return output; }
|
||||
operator ::tensorflow::Input() const { return output; }
|
||||
::tensorflow::Node* node() const { return output.node(); }
|
||||
|
||||
static Attrs Overlapping(bool x) {
|
||||
return Attrs().Overlapping(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output;
|
||||
};
|
||||
|
||||
/// Gradients for Local Response Normalization.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * input_grads: 4-D with shape `[batch, height, width, channels]`.
|
||||
/// * input_image: 4-D with shape `[batch, height, width, channels]`.
|
||||
/// * output_image: 4-D with shape `[batch, height, width, channels]`.
|
||||
///
|
||||
/// Optional attributes (see `Attrs`):
|
||||
/// * depth_radius: A depth radius.
|
||||
/// * bias: An offset (usually > 0 to avoid dividing by 0).
|
||||
/// * alpha: A scale factor, usually positive.
|
||||
/// * beta: An exponent.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: The gradients for LRN.
|
||||
class LRNGrad {
|
||||
public:
|
||||
/// Optional attribute setters for LRNGrad
|
||||
struct Attrs {
|
||||
/// A depth radius.
|
||||
///
|
||||
/// Defaults to 5
|
||||
TF_MUST_USE_RESULT Attrs DepthRadius(int64 x) {
|
||||
Attrs ret = *this;
|
||||
ret.depth_radius_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// An offset (usually > 0 to avoid dividing by 0).
|
||||
///
|
||||
/// Defaults to 1
|
||||
TF_MUST_USE_RESULT Attrs Bias(float x) {
|
||||
Attrs ret = *this;
|
||||
ret.bias_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// A scale factor, usually positive.
|
||||
///
|
||||
/// Defaults to 1
|
||||
TF_MUST_USE_RESULT Attrs Alpha(float x) {
|
||||
Attrs ret = *this;
|
||||
ret.alpha_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// An exponent.
|
||||
///
|
||||
/// Defaults to 0.5
|
||||
TF_MUST_USE_RESULT Attrs Beta(float x) {
|
||||
Attrs ret = *this;
|
||||
ret.beta_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int64 depth_radius_ = 5;
|
||||
float bias_ = 1.0f;
|
||||
float alpha_ = 1.0f;
|
||||
float beta_ = 0.5f;
|
||||
};
|
||||
LRNGrad(const ::tensorflow::Scope& scope, ::tensorflow::Input input_grads,
|
||||
::tensorflow::Input input_image, ::tensorflow::Input output_image);
|
||||
LRNGrad(const ::tensorflow::Scope& scope, ::tensorflow::Input input_grads,
|
||||
::tensorflow::Input input_image, ::tensorflow::Input output_image,
|
||||
const LRNGrad::Attrs& attrs);
|
||||
operator ::tensorflow::Output() const { return output; }
|
||||
operator ::tensorflow::Input() const { return output; }
|
||||
::tensorflow::Node* node() const { return output.node(); }
|
||||
|
||||
static Attrs DepthRadius(int64 x) {
|
||||
return Attrs().DepthRadius(x);
|
||||
}
|
||||
static Attrs Bias(float x) {
|
||||
return Attrs().Bias(x);
|
||||
}
|
||||
static Attrs Alpha(float x) {
|
||||
return Attrs().Alpha(x);
|
||||
}
|
||||
static Attrs Beta(float x) {
|
||||
return Attrs().Beta(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output;
|
||||
};
|
||||
|
||||
/// Computes gradients of the maxpooling function.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * orig_input: The original input tensor.
|
||||
/// * orig_output: The original output tensor.
|
||||
/// * grad: 4-D. Gradients w.r.t. the output of `max_pool`.
|
||||
/// * ksize: The size of the window for each dimension of the input tensor.
|
||||
/// * strides: The stride of the sliding window for each dimension of the
|
||||
/// input tensor.
|
||||
/// * padding: The type of padding algorithm to use.
|
||||
///
|
||||
/// Optional attributes (see `Attrs`):
|
||||
/// * data_format: Specify the data format of the input and output data. With the
|
||||
/// default format "NHWC", the data is stored in the order of:
|
||||
/// [batch, in_height, in_width, in_channels].
|
||||
/// Alternatively, the format could be "NCHW", the data storage order of:
|
||||
/// [batch, in_channels, in_height, in_width].
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: Gradients w.r.t. the input to `max_pool`.
|
||||
class MaxPoolGrad {
|
||||
public:
|
||||
/// Optional attribute setters for MaxPoolGrad
|
||||
struct Attrs {
|
||||
/// Specify the data format of the input and output data. With the
|
||||
/// default format "NHWC", the data is stored in the order of:
|
||||
/// [batch, in_height, in_width, in_channels].
|
||||
/// Alternatively, the format could be "NCHW", the data storage order of:
|
||||
/// [batch, in_channels, in_height, in_width].
|
||||
///
|
||||
/// Defaults to "NHWC"
|
||||
TF_MUST_USE_RESULT Attrs DataFormat(StringPiece x) {
|
||||
Attrs ret = *this;
|
||||
ret.data_format_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
StringPiece data_format_ = "NHWC";
|
||||
};
|
||||
MaxPoolGrad(const ::tensorflow::Scope& scope, ::tensorflow::Input orig_input,
|
||||
::tensorflow::Input orig_output, ::tensorflow::Input grad, const
|
||||
gtl::ArraySlice<int>& ksize, const gtl::ArraySlice<int>& strides,
|
||||
StringPiece padding);
|
||||
MaxPoolGrad(const ::tensorflow::Scope& scope, ::tensorflow::Input orig_input,
|
||||
::tensorflow::Input orig_output, ::tensorflow::Input grad, const
|
||||
gtl::ArraySlice<int>& ksize, const gtl::ArraySlice<int>& strides,
|
||||
StringPiece padding, const MaxPoolGrad::Attrs& attrs);
|
||||
operator ::tensorflow::Output() const { return output; }
|
||||
operator ::tensorflow::Input() const { return output; }
|
||||
::tensorflow::Node* node() const { return output.node(); }
|
||||
|
||||
static Attrs DataFormat(StringPiece x) {
|
||||
return Attrs().DataFormat(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output;
|
||||
};
|
||||
|
||||
/// Computes gradients of the maxpooling function.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * input: The original input.
|
||||
/// * grad: 4-D with shape `[batch, height, width, channels]`. Gradients w.r.t. the
|
||||
/// output of `max_pool`.
|
||||
/// * argmax: The indices of the maximum values chosen for each output of `max_pool`.
|
||||
/// * ksize: The size of the window for each dimension of the input tensor.
|
||||
/// * strides: The stride of the sliding window for each dimension of the
|
||||
/// input tensor.
|
||||
/// * padding: The type of padding algorithm to use.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: Gradients w.r.t. the input of `max_pool`.
|
||||
class MaxPoolGradWithArgmax {
|
||||
public:
|
||||
MaxPoolGradWithArgmax(const ::tensorflow::Scope& scope, ::tensorflow::Input
|
||||
input, ::tensorflow::Input grad, ::tensorflow::Input
|
||||
argmax, const gtl::ArraySlice<int>& ksize, const
|
||||
gtl::ArraySlice<int>& strides, StringPiece padding);
|
||||
operator ::tensorflow::Output() const { return output; }
|
||||
operator ::tensorflow::Input() const { return output; }
|
||||
::tensorflow::Node* node() const { return output.node(); }
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output;
|
||||
};
|
||||
|
||||
/// Computes rectified linear 6 gradients for a Relu6 operation.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * gradients: The backpropagated gradients to the corresponding Relu6 operation.
|
||||
/// * features: The features passed as input to the corresponding Relu6 operation, or
|
||||
/// its output; using either one produces the same result.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: The gradients:
|
||||
/// `gradients * (features > 0) * (features < 6)`.
|
||||
class Relu6Grad {
|
||||
public:
|
||||
Relu6Grad(const ::tensorflow::Scope& scope, ::tensorflow::Input gradients,
|
||||
::tensorflow::Input features);
|
||||
operator ::tensorflow::Output() const { return backprops; }
|
||||
operator ::tensorflow::Input() const { return backprops; }
|
||||
::tensorflow::Node* node() const { return backprops.node(); }
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output backprops;
|
||||
};
|
||||
|
||||
/// Computes rectified linear gradients for a Relu operation.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * gradients: The backpropagated gradients to the corresponding Relu operation.
|
||||
/// * features: The features passed as input to the corresponding Relu operation, OR
|
||||
/// the outputs of that operation (both work equivalently).
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: `gradients * (features > 0)`.
|
||||
class ReluGrad {
|
||||
public:
|
||||
ReluGrad(const ::tensorflow::Scope& scope, ::tensorflow::Input gradients,
|
||||
::tensorflow::Input features);
|
||||
operator ::tensorflow::Output() const { return backprops; }
|
||||
operator ::tensorflow::Input() const { return backprops; }
|
||||
::tensorflow::Node* node() const { return backprops.node(); }
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output backprops;
|
||||
};
|
||||
|
||||
/// Computes gradients for the scaled exponential linear (Selu) operation.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * gradients: The backpropagated gradients to the corresponding Selu operation.
|
||||
/// * outputs: The outputs of the corresponding Selu operation.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: The gradients: `gradients * (outputs + scale * alpha)`
|
||||
/// if outputs < 0, `scale * gradients` otherwise.
|
||||
class SeluGrad {
|
||||
public:
|
||||
SeluGrad(const ::tensorflow::Scope& scope, ::tensorflow::Input gradients,
|
||||
::tensorflow::Input outputs);
|
||||
operator ::tensorflow::Output() const { return backprops; }
|
||||
operator ::tensorflow::Input() const { return backprops; }
|
||||
::tensorflow::Node* node() const { return backprops.node(); }
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output backprops;
|
||||
};
|
||||
|
||||
/// Computes softplus gradients for a softplus operation.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * gradients: The backpropagated gradients to the corresponding softplus operation.
|
||||
/// * features: The features passed as input to the corresponding softplus operation.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: The gradients: `gradients / (1 + exp(-features))`.
|
||||
class SoftplusGrad {
|
||||
public:
|
||||
SoftplusGrad(const ::tensorflow::Scope& scope, ::tensorflow::Input gradients,
|
||||
::tensorflow::Input features);
|
||||
operator ::tensorflow::Output() const { return backprops; }
|
||||
operator ::tensorflow::Input() const { return backprops; }
|
||||
::tensorflow::Node* node() const { return backprops.node(); }
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output backprops;
|
||||
};
|
||||
|
||||
/// Computes softsign gradients for a softsign operation.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * gradients: The backpropagated gradients to the corresponding softsign operation.
|
||||
/// * features: The features passed as input to the corresponding softsign operation.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: The gradients: `gradients / (1 + abs(features)) ** 2`.
|
||||
class SoftsignGrad {
|
||||
public:
|
||||
SoftsignGrad(const ::tensorflow::Scope& scope, ::tensorflow::Input gradients,
|
||||
::tensorflow::Input features);
|
||||
operator ::tensorflow::Output() const { return backprops; }
|
||||
operator ::tensorflow::Input() const { return backprops; }
|
||||
::tensorflow::Node* node() const { return backprops.node(); }
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output backprops;
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
} // namespace ops
|
||||
} // namespace tensorflow
|
||||
|
||||
#endif // TENSORFLOW_CC_OPS_NN_OPS_INTERNAL_H_
|
||||
@@ -0,0 +1,41 @@
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#ifndef TENSORFLOW_CC_OPS_NO_OP_H_
|
||||
#define TENSORFLOW_CC_OPS_NO_OP_H_
|
||||
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#include "tensorflow/cc/framework/ops.h"
|
||||
#include "tensorflow/cc/framework/scope.h"
|
||||
#include "tensorflow/core/framework/tensor.h"
|
||||
#include "tensorflow/core/framework/tensor_shape.h"
|
||||
#include "tensorflow/core/framework/types.h"
|
||||
#include "tensorflow/core/lib/gtl/array_slice.h"
|
||||
|
||||
namespace tensorflow {
|
||||
namespace ops {
|
||||
|
||||
/// @defgroup no_op No Op
|
||||
/// @{
|
||||
|
||||
/// Does nothing. Only useful as a placeholder for control edges.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
///
|
||||
/// Returns:
|
||||
/// * the created `Operation`
|
||||
class NoOp {
|
||||
public:
|
||||
NoOp(const ::tensorflow::Scope& scope);
|
||||
operator ::tensorflow::Operation() const { return operation; }
|
||||
|
||||
Operation operation;
|
||||
};
|
||||
|
||||
/// @}
|
||||
|
||||
} // namespace ops
|
||||
} // namespace tensorflow
|
||||
|
||||
#endif // TENSORFLOW_CC_OPS_NO_OP_H_
|
||||
@@ -0,0 +1,28 @@
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#ifndef TENSORFLOW_CC_OPS_NO_OP_INTERNAL_H_
|
||||
#define TENSORFLOW_CC_OPS_NO_OP_INTERNAL_H_
|
||||
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#include "tensorflow/cc/framework/ops.h"
|
||||
#include "tensorflow/cc/framework/scope.h"
|
||||
#include "tensorflow/core/framework/tensor.h"
|
||||
#include "tensorflow/core/framework/tensor_shape.h"
|
||||
#include "tensorflow/core/framework/types.h"
|
||||
#include "tensorflow/core/lib/gtl/array_slice.h"
|
||||
|
||||
namespace tensorflow {
|
||||
namespace ops {
|
||||
namespace internal {
|
||||
// NOTE: This namespace has internal TensorFlow details that
|
||||
// are not part of TensorFlow's public API.
|
||||
|
||||
/// @defgroup no_op_internal No Op Internal
|
||||
/// @{
|
||||
|
||||
} // namespace internal
|
||||
} // namespace ops
|
||||
} // namespace tensorflow
|
||||
|
||||
#endif // TENSORFLOW_CC_OPS_NO_OP_INTERNAL_H_
|
||||
@@ -0,0 +1,854 @@
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#ifndef TENSORFLOW_CC_OPS_PARSING_OPS_H_
|
||||
#define TENSORFLOW_CC_OPS_PARSING_OPS_H_
|
||||
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#include "tensorflow/cc/framework/ops.h"
|
||||
#include "tensorflow/cc/framework/scope.h"
|
||||
#include "tensorflow/core/framework/tensor.h"
|
||||
#include "tensorflow/core/framework/tensor_shape.h"
|
||||
#include "tensorflow/core/framework/types.h"
|
||||
#include "tensorflow/core/lib/gtl/array_slice.h"
|
||||
|
||||
namespace tensorflow {
|
||||
namespace ops {
|
||||
|
||||
/// @defgroup parsing_ops Parsing Ops
|
||||
/// @{
|
||||
|
||||
/// Convert CSV records to tensors. Each column maps to one tensor.
|
||||
///
|
||||
/// RFC 4180 format is expected for the CSV records.
|
||||
/// (https://tools.ietf.org/html/rfc4180)
|
||||
/// Note that we allow leading and trailing spaces with int or float field.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * records: Each string is a record/row in the csv and all records should have
|
||||
/// the same format.
|
||||
/// * record_defaults: One tensor per column of the input record, with either a
|
||||
/// scalar default value for that column or an empty vector if the column is
|
||||
/// required.
|
||||
///
|
||||
/// Optional attributes (see `Attrs`):
|
||||
/// * field_delim: char delimiter to separate fields in a record.
|
||||
/// * use_quote_delim: If false, treats double quotation marks as regular
|
||||
/// characters inside of the string fields (ignoring RFC 4180, Section 2,
|
||||
/// Bullet 5).
|
||||
/// * na_value: Additional string to recognize as NA/NaN.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `OutputList`: Each tensor will have the same shape as records.
|
||||
class DecodeCSV {
|
||||
public:
|
||||
/// Optional attribute setters for DecodeCSV
|
||||
struct Attrs {
|
||||
/// char delimiter to separate fields in a record.
|
||||
///
|
||||
/// Defaults to ","
|
||||
TF_MUST_USE_RESULT Attrs FieldDelim(StringPiece x) {
|
||||
Attrs ret = *this;
|
||||
ret.field_delim_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// If false, treats double quotation marks as regular
|
||||
/// characters inside of the string fields (ignoring RFC 4180, Section 2,
|
||||
/// Bullet 5).
|
||||
///
|
||||
/// Defaults to true
|
||||
TF_MUST_USE_RESULT Attrs UseQuoteDelim(bool x) {
|
||||
Attrs ret = *this;
|
||||
ret.use_quote_delim_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// Additional string to recognize as NA/NaN.
|
||||
///
|
||||
/// Defaults to ""
|
||||
TF_MUST_USE_RESULT Attrs NaValue(StringPiece x) {
|
||||
Attrs ret = *this;
|
||||
ret.na_value_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// Defaults to []
|
||||
TF_MUST_USE_RESULT Attrs SelectCols(const gtl::ArraySlice<int>& x) {
|
||||
Attrs ret = *this;
|
||||
ret.select_cols_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
StringPiece field_delim_ = ",";
|
||||
bool use_quote_delim_ = true;
|
||||
StringPiece na_value_ = "";
|
||||
gtl::ArraySlice<int> select_cols_ = {};
|
||||
};
|
||||
DecodeCSV(const ::tensorflow::Scope& scope, ::tensorflow::Input records,
|
||||
::tensorflow::InputList record_defaults);
|
||||
DecodeCSV(const ::tensorflow::Scope& scope, ::tensorflow::Input records,
|
||||
::tensorflow::InputList record_defaults, const DecodeCSV::Attrs&
|
||||
attrs);
|
||||
::tensorflow::Output operator[](size_t index) const { return output[index]; }
|
||||
|
||||
|
||||
static Attrs FieldDelim(StringPiece x) {
|
||||
return Attrs().FieldDelim(x);
|
||||
}
|
||||
static Attrs UseQuoteDelim(bool x) {
|
||||
return Attrs().UseQuoteDelim(x);
|
||||
}
|
||||
static Attrs NaValue(StringPiece x) {
|
||||
return Attrs().NaValue(x);
|
||||
}
|
||||
static Attrs SelectCols(const gtl::ArraySlice<int>& x) {
|
||||
return Attrs().SelectCols(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::OutputList output;
|
||||
};
|
||||
|
||||
/// Decompress strings.
|
||||
///
|
||||
/// This op decompresses each element of the `bytes` input `Tensor`, which
|
||||
/// is assumed to be compressed using the given `compression_type`.
|
||||
///
|
||||
/// The `output` is a string `Tensor` of the same shape as `bytes`,
|
||||
/// each element containing the decompressed data from the corresponding
|
||||
/// element in `bytes`.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * bytes: A Tensor of string which is compressed.
|
||||
///
|
||||
/// Optional attributes (see `Attrs`):
|
||||
/// * compression_type: A scalar containing either (i) the empty string (no
|
||||
/// compression), (ii) "ZLIB", or (iii) "GZIP".
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: A Tensor with the same shape as input `bytes`, uncompressed
|
||||
/// from bytes.
|
||||
class DecodeCompressed {
|
||||
public:
|
||||
/// Optional attribute setters for DecodeCompressed
|
||||
struct Attrs {
|
||||
/// A scalar containing either (i) the empty string (no
|
||||
/// compression), (ii) "ZLIB", or (iii) "GZIP".
|
||||
///
|
||||
/// Defaults to ""
|
||||
TF_MUST_USE_RESULT Attrs CompressionType(StringPiece x) {
|
||||
Attrs ret = *this;
|
||||
ret.compression_type_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
StringPiece compression_type_ = "";
|
||||
};
|
||||
DecodeCompressed(const ::tensorflow::Scope& scope, ::tensorflow::Input bytes);
|
||||
DecodeCompressed(const ::tensorflow::Scope& scope, ::tensorflow::Input bytes,
|
||||
const DecodeCompressed::Attrs& attrs);
|
||||
operator ::tensorflow::Output() const { return output; }
|
||||
operator ::tensorflow::Input() const { return output; }
|
||||
::tensorflow::Node* node() const { return output.node(); }
|
||||
|
||||
static Attrs CompressionType(StringPiece x) {
|
||||
return Attrs().CompressionType(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output;
|
||||
};
|
||||
|
||||
/// Convert JSON-encoded Example records to binary protocol buffer strings.
|
||||
///
|
||||
/// This op translates a tensor containing Example records, encoded using
|
||||
/// the [standard JSON
|
||||
/// mapping](https://developers.google.com/protocol-buffers/docs/proto3#json),
|
||||
/// into a tensor containing the same records encoded as binary protocol
|
||||
/// buffers. The resulting tensor can then be fed to any of the other
|
||||
/// Example-parsing ops.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * json_examples: Each string is a JSON object serialized according to the JSON
|
||||
/// mapping of the Example proto.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: Each string is a binary Example protocol buffer corresponding
|
||||
/// to the respective element of `json_examples`.
|
||||
class DecodeJSONExample {
|
||||
public:
|
||||
DecodeJSONExample(const ::tensorflow::Scope& scope, ::tensorflow::Input
|
||||
json_examples);
|
||||
operator ::tensorflow::Output() const { return binary_examples; }
|
||||
operator ::tensorflow::Input() const { return binary_examples; }
|
||||
::tensorflow::Node* node() const { return binary_examples.node(); }
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output binary_examples;
|
||||
};
|
||||
|
||||
/// Reinterpret the bytes of a string as a vector of numbers.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * bytes: All the elements must have the same length.
|
||||
///
|
||||
/// Optional attributes (see `Attrs`):
|
||||
/// * little_endian: Whether the input `bytes` are in little-endian order.
|
||||
/// Ignored for `out_type` values that are stored in a single byte like
|
||||
/// `uint8`.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: A Tensor with one more dimension than the input `bytes`. The
|
||||
/// added dimension will have size equal to the length of the elements
|
||||
/// of `bytes` divided by the number of bytes to represent `out_type`.
|
||||
class DecodeRaw {
|
||||
public:
|
||||
/// Optional attribute setters for DecodeRaw
|
||||
struct Attrs {
|
||||
/// Whether the input `bytes` are in little-endian order.
|
||||
/// Ignored for `out_type` values that are stored in a single byte like
|
||||
/// `uint8`.
|
||||
///
|
||||
/// Defaults to true
|
||||
TF_MUST_USE_RESULT Attrs LittleEndian(bool x) {
|
||||
Attrs ret = *this;
|
||||
ret.little_endian_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool little_endian_ = true;
|
||||
};
|
||||
DecodeRaw(const ::tensorflow::Scope& scope, ::tensorflow::Input bytes, DataType
|
||||
out_type);
|
||||
DecodeRaw(const ::tensorflow::Scope& scope, ::tensorflow::Input bytes, DataType
|
||||
out_type, const DecodeRaw::Attrs& attrs);
|
||||
operator ::tensorflow::Output() const { return output; }
|
||||
operator ::tensorflow::Input() const { return output; }
|
||||
::tensorflow::Node* node() const { return output.node(); }
|
||||
|
||||
static Attrs LittleEndian(bool x) {
|
||||
return Attrs().LittleEndian(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output;
|
||||
};
|
||||
|
||||
/// Transforms a vector of brain.Example protos (as strings) into typed tensors.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * serialized: A vector containing a batch of binary serialized Example protos.
|
||||
/// * names: A vector containing the names of the serialized protos.
|
||||
/// May contain, for example, table key (descriptive) names for the
|
||||
/// corresponding serialized protos. These are purely useful for debugging
|
||||
/// purposes, and the presence of values here has no effect on the output.
|
||||
/// May also be an empty vector if no names are available.
|
||||
/// If non-empty, this vector must be the same length as "serialized".
|
||||
/// * sparse_keys: A list of Nsparse string Tensors (scalars).
|
||||
/// The keys expected in the Examples' features associated with sparse values.
|
||||
/// * dense_keys: A list of Ndense string Tensors (scalars).
|
||||
/// The keys expected in the Examples' features associated with dense values.
|
||||
/// * dense_defaults: A list of Ndense Tensors (some may be empty).
|
||||
/// dense_defaults[j] provides default values
|
||||
/// when the example's feature_map lacks dense_key[j]. If an empty Tensor is
|
||||
/// provided for dense_defaults[j], then the Feature dense_keys[j] is required.
|
||||
/// The input type is inferred from dense_defaults[j], even when it's empty.
|
||||
/// If dense_defaults[j] is not empty, and dense_shapes[j] is fully defined,
|
||||
/// then the shape of dense_defaults[j] must match that of dense_shapes[j].
|
||||
/// If dense_shapes[j] has an undefined major dimension (variable strides dense
|
||||
/// feature), dense_defaults[j] must contain a single element:
|
||||
/// the padding element.
|
||||
/// * sparse_types: A list of Nsparse types; the data types of data in each Feature
|
||||
/// given in sparse_keys.
|
||||
/// Currently the ParseExample supports DT_FLOAT (FloatList),
|
||||
/// DT_INT64 (Int64List), and DT_STRING (BytesList).
|
||||
/// * dense_shapes: A list of Ndense shapes; the shapes of data in each Feature
|
||||
/// given in dense_keys.
|
||||
/// The number of elements in the Feature corresponding to dense_key[j]
|
||||
/// must always equal dense_shapes[j].NumEntries().
|
||||
/// If dense_shapes[j] == (D0, D1, ..., DN) then the shape of output
|
||||
/// Tensor dense_values[j] will be (|serialized|, D0, D1, ..., DN):
|
||||
/// The dense outputs are just the inputs row-stacked by batch.
|
||||
/// This works for dense_shapes[j] = (-1, D1, ..., DN). In this case
|
||||
/// the shape of the output Tensor dense_values[j] will be
|
||||
/// (|serialized|, M, D1, .., DN), where M is the maximum number of blocks
|
||||
/// of elements of length D1 * .... * DN, across all minibatch entries
|
||||
/// in the input. Any minibatch entry with less than M blocks of elements of
|
||||
/// length D1 * ... * DN will be padded with the corresponding default_value
|
||||
/// scalar element along the second dimension.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `OutputList` sparse_indices
|
||||
/// * `OutputList` sparse_values
|
||||
/// * `OutputList` sparse_shapes
|
||||
/// * `OutputList` dense_values
|
||||
class ParseExample {
|
||||
public:
|
||||
ParseExample(const ::tensorflow::Scope& scope, ::tensorflow::Input serialized,
|
||||
::tensorflow::Input names, ::tensorflow::InputList sparse_keys,
|
||||
::tensorflow::InputList dense_keys, ::tensorflow::InputList
|
||||
dense_defaults, const DataTypeSlice& sparse_types, const
|
||||
gtl::ArraySlice<PartialTensorShape>& dense_shapes);
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::OutputList sparse_indices;
|
||||
::tensorflow::OutputList sparse_values;
|
||||
::tensorflow::OutputList sparse_shapes;
|
||||
::tensorflow::OutputList dense_values;
|
||||
};
|
||||
|
||||
/// Transforms a vector of brain.SequenceExample protos (as strings) into typed tensors.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * serialized: A vector containing binary serialized SequenceExample protos.
|
||||
/// * debug_name: A vector containing the names of the serialized protos.
|
||||
/// May contain, for example, table key (descriptive) name for the
|
||||
/// corresponding serialized proto. This is purely useful for debugging
|
||||
/// purposes, and the presence of values here has no effect on the output.
|
||||
/// May also be an empty vector if no name is available.
|
||||
/// * context_dense_defaults: A list of Ncontext_dense Tensors (some may be empty).
|
||||
/// context_dense_defaults[j] provides default values
|
||||
/// when the SequenceExample's context map lacks context_dense_key[j].
|
||||
/// If an empty Tensor is provided for context_dense_defaults[j],
|
||||
/// then the Feature context_dense_keys[j] is required.
|
||||
/// The input type is inferred from context_dense_defaults[j], even when it's
|
||||
/// empty. If context_dense_defaults[j] is not empty, its shape must match
|
||||
/// context_dense_shapes[j].
|
||||
/// * feature_list_dense_missing_assumed_empty: A vector listing the
|
||||
/// FeatureList keys which may be missing from the SequenceExamples. If the
|
||||
/// associated FeatureList is missing, it is treated as empty. By default,
|
||||
/// any FeatureList not listed in this vector must exist in the SequenceExamples.
|
||||
/// * context_sparse_keys: A list of Ncontext_sparse string Tensors (scalars).
|
||||
/// The keys expected in the Examples' features associated with context_sparse
|
||||
/// values.
|
||||
/// * context_dense_keys: A list of Ncontext_dense string Tensors (scalars).
|
||||
/// The keys expected in the SequenceExamples' context features associated with
|
||||
/// dense values.
|
||||
/// * feature_list_sparse_keys: A list of Nfeature_list_sparse string Tensors
|
||||
/// (scalars). The keys expected in the FeatureLists associated with sparse
|
||||
/// values.
|
||||
/// * feature_list_dense_keys: A list of Nfeature_list_dense string Tensors (scalars).
|
||||
/// The keys expected in the SequenceExamples' feature_lists associated
|
||||
/// with lists of dense values.
|
||||
///
|
||||
/// Optional attributes (see `Attrs`):
|
||||
/// * context_sparse_types: A list of Ncontext_sparse types; the data types of data in
|
||||
/// each context Feature given in context_sparse_keys.
|
||||
/// Currently the ParseSingleSequenceExample supports DT_FLOAT (FloatList),
|
||||
/// DT_INT64 (Int64List), and DT_STRING (BytesList).
|
||||
/// * context_dense_shapes: A list of Ncontext_dense shapes; the shapes of data in
|
||||
/// each context Feature given in context_dense_keys.
|
||||
/// The number of elements in the Feature corresponding to context_dense_key[j]
|
||||
/// must always equal context_dense_shapes[j].NumEntries().
|
||||
/// The shape of context_dense_values[j] will match context_dense_shapes[j].
|
||||
/// * feature_list_sparse_types: A list of Nfeature_list_sparse types; the data types
|
||||
/// of data in each FeatureList given in feature_list_sparse_keys.
|
||||
/// Currently the ParseSingleSequenceExample supports DT_FLOAT (FloatList),
|
||||
/// DT_INT64 (Int64List), and DT_STRING (BytesList).
|
||||
/// * feature_list_dense_shapes: A list of Nfeature_list_dense shapes; the shapes of
|
||||
/// data in each FeatureList given in feature_list_dense_keys.
|
||||
/// The shape of each Feature in the FeatureList corresponding to
|
||||
/// feature_list_dense_key[j] must always equal
|
||||
/// feature_list_dense_shapes[j].NumEntries().
|
||||
///
|
||||
/// Returns:
|
||||
/// * `OutputList` context_sparse_indices
|
||||
/// * `OutputList` context_sparse_values
|
||||
/// * `OutputList` context_sparse_shapes
|
||||
/// * `OutputList` context_dense_values
|
||||
/// * `OutputList` feature_list_sparse_indices
|
||||
/// * `OutputList` feature_list_sparse_values
|
||||
/// * `OutputList` feature_list_sparse_shapes
|
||||
/// * `OutputList` feature_list_dense_values
|
||||
/// * `OutputList` feature_list_dense_lengths
|
||||
class ParseSequenceExample {
|
||||
public:
|
||||
/// Optional attribute setters for ParseSequenceExample
|
||||
struct Attrs {
|
||||
/// Defaults to 0
|
||||
TF_MUST_USE_RESULT Attrs NcontextSparse(int64 x) {
|
||||
Attrs ret = *this;
|
||||
ret.Ncontext_sparse_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// Defaults to 0
|
||||
TF_MUST_USE_RESULT Attrs NcontextDense(int64 x) {
|
||||
Attrs ret = *this;
|
||||
ret.Ncontext_dense_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// Defaults to 0
|
||||
TF_MUST_USE_RESULT Attrs NfeatureListSparse(int64 x) {
|
||||
Attrs ret = *this;
|
||||
ret.Nfeature_list_sparse_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// Defaults to 0
|
||||
TF_MUST_USE_RESULT Attrs NfeatureListDense(int64 x) {
|
||||
Attrs ret = *this;
|
||||
ret.Nfeature_list_dense_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// A list of Ncontext_sparse types; the data types of data in
|
||||
/// each context Feature given in context_sparse_keys.
|
||||
/// Currently the ParseSingleSequenceExample supports DT_FLOAT (FloatList),
|
||||
/// DT_INT64 (Int64List), and DT_STRING (BytesList).
|
||||
///
|
||||
/// Defaults to []
|
||||
TF_MUST_USE_RESULT Attrs ContextSparseTypes(const DataTypeSlice& x) {
|
||||
Attrs ret = *this;
|
||||
ret.context_sparse_types_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// Defaults to []
|
||||
TF_MUST_USE_RESULT Attrs FeatureListDenseTypes(const DataTypeSlice& x) {
|
||||
Attrs ret = *this;
|
||||
ret.feature_list_dense_types_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// A list of Ncontext_dense shapes; the shapes of data in
|
||||
/// each context Feature given in context_dense_keys.
|
||||
/// The number of elements in the Feature corresponding to context_dense_key[j]
|
||||
/// must always equal context_dense_shapes[j].NumEntries().
|
||||
/// The shape of context_dense_values[j] will match context_dense_shapes[j].
|
||||
///
|
||||
/// Defaults to []
|
||||
TF_MUST_USE_RESULT Attrs ContextDenseShapes(const gtl::ArraySlice<PartialTensorShape>& x) {
|
||||
Attrs ret = *this;
|
||||
ret.context_dense_shapes_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// A list of Nfeature_list_sparse types; the data types
|
||||
/// of data in each FeatureList given in feature_list_sparse_keys.
|
||||
/// Currently the ParseSingleSequenceExample supports DT_FLOAT (FloatList),
|
||||
/// DT_INT64 (Int64List), and DT_STRING (BytesList).
|
||||
///
|
||||
/// Defaults to []
|
||||
TF_MUST_USE_RESULT Attrs FeatureListSparseTypes(const DataTypeSlice& x) {
|
||||
Attrs ret = *this;
|
||||
ret.feature_list_sparse_types_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// A list of Nfeature_list_dense shapes; the shapes of
|
||||
/// data in each FeatureList given in feature_list_dense_keys.
|
||||
/// The shape of each Feature in the FeatureList corresponding to
|
||||
/// feature_list_dense_key[j] must always equal
|
||||
/// feature_list_dense_shapes[j].NumEntries().
|
||||
///
|
||||
/// Defaults to []
|
||||
TF_MUST_USE_RESULT Attrs FeatureListDenseShapes(const gtl::ArraySlice<PartialTensorShape>& x) {
|
||||
Attrs ret = *this;
|
||||
ret.feature_list_dense_shapes_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int64 Ncontext_sparse_ = 0;
|
||||
int64 Ncontext_dense_ = 0;
|
||||
int64 Nfeature_list_sparse_ = 0;
|
||||
int64 Nfeature_list_dense_ = 0;
|
||||
DataTypeSlice context_sparse_types_ = {};
|
||||
DataTypeSlice feature_list_dense_types_ = {};
|
||||
gtl::ArraySlice<PartialTensorShape> context_dense_shapes_ = {};
|
||||
DataTypeSlice feature_list_sparse_types_ = {};
|
||||
gtl::ArraySlice<PartialTensorShape> feature_list_dense_shapes_ = {};
|
||||
};
|
||||
ParseSequenceExample(const ::tensorflow::Scope& scope, ::tensorflow::Input
|
||||
serialized, ::tensorflow::Input debug_name,
|
||||
::tensorflow::InputList context_dense_defaults, const
|
||||
gtl::ArraySlice<string>&
|
||||
feature_list_dense_missing_assumed_empty, const
|
||||
gtl::ArraySlice<string>& context_sparse_keys, const
|
||||
gtl::ArraySlice<string>& context_dense_keys, const
|
||||
gtl::ArraySlice<string>& feature_list_sparse_keys, const
|
||||
gtl::ArraySlice<string>& feature_list_dense_keys);
|
||||
ParseSequenceExample(const ::tensorflow::Scope& scope, ::tensorflow::Input
|
||||
serialized, ::tensorflow::Input debug_name,
|
||||
::tensorflow::InputList context_dense_defaults, const
|
||||
gtl::ArraySlice<string>&
|
||||
feature_list_dense_missing_assumed_empty, const
|
||||
gtl::ArraySlice<string>& context_sparse_keys, const
|
||||
gtl::ArraySlice<string>& context_dense_keys, const
|
||||
gtl::ArraySlice<string>& feature_list_sparse_keys, const
|
||||
gtl::ArraySlice<string>& feature_list_dense_keys, const
|
||||
ParseSequenceExample::Attrs& attrs);
|
||||
|
||||
static Attrs NcontextSparse(int64 x) {
|
||||
return Attrs().NcontextSparse(x);
|
||||
}
|
||||
static Attrs NcontextDense(int64 x) {
|
||||
return Attrs().NcontextDense(x);
|
||||
}
|
||||
static Attrs NfeatureListSparse(int64 x) {
|
||||
return Attrs().NfeatureListSparse(x);
|
||||
}
|
||||
static Attrs NfeatureListDense(int64 x) {
|
||||
return Attrs().NfeatureListDense(x);
|
||||
}
|
||||
static Attrs ContextSparseTypes(const DataTypeSlice& x) {
|
||||
return Attrs().ContextSparseTypes(x);
|
||||
}
|
||||
static Attrs FeatureListDenseTypes(const DataTypeSlice& x) {
|
||||
return Attrs().FeatureListDenseTypes(x);
|
||||
}
|
||||
static Attrs ContextDenseShapes(const gtl::ArraySlice<PartialTensorShape>& x) {
|
||||
return Attrs().ContextDenseShapes(x);
|
||||
}
|
||||
static Attrs FeatureListSparseTypes(const DataTypeSlice& x) {
|
||||
return Attrs().FeatureListSparseTypes(x);
|
||||
}
|
||||
static Attrs FeatureListDenseShapes(const gtl::ArraySlice<PartialTensorShape>& x) {
|
||||
return Attrs().FeatureListDenseShapes(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::OutputList context_sparse_indices;
|
||||
::tensorflow::OutputList context_sparse_values;
|
||||
::tensorflow::OutputList context_sparse_shapes;
|
||||
::tensorflow::OutputList context_dense_values;
|
||||
::tensorflow::OutputList feature_list_sparse_indices;
|
||||
::tensorflow::OutputList feature_list_sparse_values;
|
||||
::tensorflow::OutputList feature_list_sparse_shapes;
|
||||
::tensorflow::OutputList feature_list_dense_values;
|
||||
::tensorflow::OutputList feature_list_dense_lengths;
|
||||
};
|
||||
|
||||
/// Transforms a tf.Example proto (as a string) into typed tensors.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * serialized: A vector containing a batch of binary serialized Example protos.
|
||||
/// * dense_defaults: A list of Tensors (some may be empty), whose length matches
|
||||
/// the length of `dense_keys`. dense_defaults[j] provides default values
|
||||
/// when the example's feature_map lacks dense_key[j]. If an empty Tensor is
|
||||
/// provided for dense_defaults[j], then the Feature dense_keys[j] is required.
|
||||
/// The input type is inferred from dense_defaults[j], even when it's empty.
|
||||
/// If dense_defaults[j] is not empty, and dense_shapes[j] is fully defined,
|
||||
/// then the shape of dense_defaults[j] must match that of dense_shapes[j].
|
||||
/// If dense_shapes[j] has an undefined major dimension (variable strides dense
|
||||
/// feature), dense_defaults[j] must contain a single element:
|
||||
/// the padding element.
|
||||
/// * num_sparse: The number of sparse features to be parsed from the example. This
|
||||
/// must match the lengths of `sparse_keys` and `sparse_types`.
|
||||
/// * sparse_keys: A list of `num_sparse` strings.
|
||||
/// The keys expected in the Examples' features associated with sparse values.
|
||||
/// * dense_keys: The keys expected in the Examples' features associated with dense
|
||||
/// values.
|
||||
/// * sparse_types: A list of `num_sparse` types; the data types of data in each
|
||||
/// Feature given in sparse_keys.
|
||||
/// Currently the ParseSingleExample op supports DT_FLOAT (FloatList),
|
||||
/// DT_INT64 (Int64List), and DT_STRING (BytesList).
|
||||
/// * dense_shapes: The shapes of data in each Feature given in dense_keys.
|
||||
/// The length of this list must match the length of `dense_keys`. The
|
||||
/// number of elements in the Feature corresponding to dense_key[j] must
|
||||
/// always equal dense_shapes[j].NumEntries(). If dense_shapes[j] ==
|
||||
/// (D0, D1, ..., DN) then the shape of output Tensor dense_values[j]
|
||||
/// will be (D0, D1, ..., DN): In the case dense_shapes[j] = (-1, D1,
|
||||
/// ..., DN), the shape of the output Tensor dense_values[j] will be (M,
|
||||
/// D1, .., DN), where M is the number of blocks of elements of length
|
||||
/// D1 * .... * DN, in the input.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `OutputList` sparse_indices
|
||||
/// * `OutputList` sparse_values
|
||||
/// * `OutputList` sparse_shapes
|
||||
/// * `OutputList` dense_values
|
||||
class ParseSingleExample {
|
||||
public:
|
||||
ParseSingleExample(const ::tensorflow::Scope& scope, ::tensorflow::Input
|
||||
serialized, ::tensorflow::InputList dense_defaults, int64
|
||||
num_sparse, const gtl::ArraySlice<string>& sparse_keys,
|
||||
const gtl::ArraySlice<string>& dense_keys, const
|
||||
DataTypeSlice& sparse_types, const
|
||||
gtl::ArraySlice<PartialTensorShape>& dense_shapes);
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::OutputList sparse_indices;
|
||||
::tensorflow::OutputList sparse_values;
|
||||
::tensorflow::OutputList sparse_shapes;
|
||||
::tensorflow::OutputList dense_values;
|
||||
};
|
||||
|
||||
/// Transforms a scalar brain.SequenceExample proto (as strings) into typed tensors.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * serialized: A scalar containing a binary serialized SequenceExample proto.
|
||||
/// * feature_list_dense_missing_assumed_empty: A vector listing the
|
||||
/// FeatureList keys which may be missing from the SequenceExample. If the
|
||||
/// associated FeatureList is missing, it is treated as empty. By default,
|
||||
/// any FeatureList not listed in this vector must exist in the SequenceExample.
|
||||
/// * context_sparse_keys: A list of Ncontext_sparse string Tensors (scalars).
|
||||
/// The keys expected in the Examples' features associated with context_sparse
|
||||
/// values.
|
||||
/// * context_dense_keys: A list of Ncontext_dense string Tensors (scalars).
|
||||
/// The keys expected in the SequenceExamples' context features associated with
|
||||
/// dense values.
|
||||
/// * feature_list_sparse_keys: A list of Nfeature_list_sparse string Tensors
|
||||
/// (scalars). The keys expected in the FeatureLists associated with sparse
|
||||
/// values.
|
||||
/// * feature_list_dense_keys: A list of Nfeature_list_dense string Tensors (scalars).
|
||||
/// The keys expected in the SequenceExamples' feature_lists associated
|
||||
/// with lists of dense values.
|
||||
/// * context_dense_defaults: A list of Ncontext_dense Tensors (some may be empty).
|
||||
/// context_dense_defaults[j] provides default values
|
||||
/// when the SequenceExample's context map lacks context_dense_key[j].
|
||||
/// If an empty Tensor is provided for context_dense_defaults[j],
|
||||
/// then the Feature context_dense_keys[j] is required.
|
||||
/// The input type is inferred from context_dense_defaults[j], even when it's
|
||||
/// empty. If context_dense_defaults[j] is not empty, its shape must match
|
||||
/// context_dense_shapes[j].
|
||||
/// * debug_name: A scalar containing the name of the serialized proto.
|
||||
/// May contain, for example, table key (descriptive) name for the
|
||||
/// corresponding serialized proto. This is purely useful for debugging
|
||||
/// purposes, and the presence of values here has no effect on the output.
|
||||
/// May also be an empty scalar if no name is available.
|
||||
///
|
||||
/// Optional attributes (see `Attrs`):
|
||||
/// * context_sparse_types: A list of Ncontext_sparse types; the data types of data in
|
||||
/// each context Feature given in context_sparse_keys.
|
||||
/// Currently the ParseSingleSequenceExample supports DT_FLOAT (FloatList),
|
||||
/// DT_INT64 (Int64List), and DT_STRING (BytesList).
|
||||
/// * context_dense_shapes: A list of Ncontext_dense shapes; the shapes of data in
|
||||
/// each context Feature given in context_dense_keys.
|
||||
/// The number of elements in the Feature corresponding to context_dense_key[j]
|
||||
/// must always equal context_dense_shapes[j].NumEntries().
|
||||
/// The shape of context_dense_values[j] will match context_dense_shapes[j].
|
||||
/// * feature_list_sparse_types: A list of Nfeature_list_sparse types; the data types
|
||||
/// of data in each FeatureList given in feature_list_sparse_keys.
|
||||
/// Currently the ParseSingleSequenceExample supports DT_FLOAT (FloatList),
|
||||
/// DT_INT64 (Int64List), and DT_STRING (BytesList).
|
||||
/// * feature_list_dense_shapes: A list of Nfeature_list_dense shapes; the shapes of
|
||||
/// data in each FeatureList given in feature_list_dense_keys.
|
||||
/// The shape of each Feature in the FeatureList corresponding to
|
||||
/// feature_list_dense_key[j] must always equal
|
||||
/// feature_list_dense_shapes[j].NumEntries().
|
||||
///
|
||||
/// Returns:
|
||||
/// * `OutputList` context_sparse_indices
|
||||
/// * `OutputList` context_sparse_values
|
||||
/// * `OutputList` context_sparse_shapes
|
||||
/// * `OutputList` context_dense_values
|
||||
/// * `OutputList` feature_list_sparse_indices
|
||||
/// * `OutputList` feature_list_sparse_values
|
||||
/// * `OutputList` feature_list_sparse_shapes
|
||||
/// * `OutputList` feature_list_dense_values
|
||||
class ParseSingleSequenceExample {
|
||||
public:
|
||||
/// Optional attribute setters for ParseSingleSequenceExample
|
||||
struct Attrs {
|
||||
/// A list of Ncontext_sparse types; the data types of data in
|
||||
/// each context Feature given in context_sparse_keys.
|
||||
/// Currently the ParseSingleSequenceExample supports DT_FLOAT (FloatList),
|
||||
/// DT_INT64 (Int64List), and DT_STRING (BytesList).
|
||||
///
|
||||
/// Defaults to []
|
||||
TF_MUST_USE_RESULT Attrs ContextSparseTypes(const DataTypeSlice& x) {
|
||||
Attrs ret = *this;
|
||||
ret.context_sparse_types_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// Defaults to []
|
||||
TF_MUST_USE_RESULT Attrs FeatureListDenseTypes(const DataTypeSlice& x) {
|
||||
Attrs ret = *this;
|
||||
ret.feature_list_dense_types_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// A list of Ncontext_dense shapes; the shapes of data in
|
||||
/// each context Feature given in context_dense_keys.
|
||||
/// The number of elements in the Feature corresponding to context_dense_key[j]
|
||||
/// must always equal context_dense_shapes[j].NumEntries().
|
||||
/// The shape of context_dense_values[j] will match context_dense_shapes[j].
|
||||
///
|
||||
/// Defaults to []
|
||||
TF_MUST_USE_RESULT Attrs ContextDenseShapes(const gtl::ArraySlice<PartialTensorShape>& x) {
|
||||
Attrs ret = *this;
|
||||
ret.context_dense_shapes_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// A list of Nfeature_list_sparse types; the data types
|
||||
/// of data in each FeatureList given in feature_list_sparse_keys.
|
||||
/// Currently the ParseSingleSequenceExample supports DT_FLOAT (FloatList),
|
||||
/// DT_INT64 (Int64List), and DT_STRING (BytesList).
|
||||
///
|
||||
/// Defaults to []
|
||||
TF_MUST_USE_RESULT Attrs FeatureListSparseTypes(const DataTypeSlice& x) {
|
||||
Attrs ret = *this;
|
||||
ret.feature_list_sparse_types_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// A list of Nfeature_list_dense shapes; the shapes of
|
||||
/// data in each FeatureList given in feature_list_dense_keys.
|
||||
/// The shape of each Feature in the FeatureList corresponding to
|
||||
/// feature_list_dense_key[j] must always equal
|
||||
/// feature_list_dense_shapes[j].NumEntries().
|
||||
///
|
||||
/// Defaults to []
|
||||
TF_MUST_USE_RESULT Attrs FeatureListDenseShapes(const gtl::ArraySlice<PartialTensorShape>& x) {
|
||||
Attrs ret = *this;
|
||||
ret.feature_list_dense_shapes_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
DataTypeSlice context_sparse_types_ = {};
|
||||
DataTypeSlice feature_list_dense_types_ = {};
|
||||
gtl::ArraySlice<PartialTensorShape> context_dense_shapes_ = {};
|
||||
DataTypeSlice feature_list_sparse_types_ = {};
|
||||
gtl::ArraySlice<PartialTensorShape> feature_list_dense_shapes_ = {};
|
||||
};
|
||||
ParseSingleSequenceExample(const ::tensorflow::Scope& scope,
|
||||
::tensorflow::Input serialized, ::tensorflow::Input
|
||||
feature_list_dense_missing_assumed_empty,
|
||||
::tensorflow::InputList context_sparse_keys,
|
||||
::tensorflow::InputList context_dense_keys,
|
||||
::tensorflow::InputList feature_list_sparse_keys,
|
||||
::tensorflow::InputList feature_list_dense_keys,
|
||||
::tensorflow::InputList context_dense_defaults,
|
||||
::tensorflow::Input debug_name);
|
||||
ParseSingleSequenceExample(const ::tensorflow::Scope& scope,
|
||||
::tensorflow::Input serialized, ::tensorflow::Input
|
||||
feature_list_dense_missing_assumed_empty,
|
||||
::tensorflow::InputList context_sparse_keys,
|
||||
::tensorflow::InputList context_dense_keys,
|
||||
::tensorflow::InputList feature_list_sparse_keys,
|
||||
::tensorflow::InputList feature_list_dense_keys,
|
||||
::tensorflow::InputList context_dense_defaults,
|
||||
::tensorflow::Input debug_name, const
|
||||
ParseSingleSequenceExample::Attrs& attrs);
|
||||
|
||||
static Attrs ContextSparseTypes(const DataTypeSlice& x) {
|
||||
return Attrs().ContextSparseTypes(x);
|
||||
}
|
||||
static Attrs FeatureListDenseTypes(const DataTypeSlice& x) {
|
||||
return Attrs().FeatureListDenseTypes(x);
|
||||
}
|
||||
static Attrs ContextDenseShapes(const gtl::ArraySlice<PartialTensorShape>& x) {
|
||||
return Attrs().ContextDenseShapes(x);
|
||||
}
|
||||
static Attrs FeatureListSparseTypes(const DataTypeSlice& x) {
|
||||
return Attrs().FeatureListSparseTypes(x);
|
||||
}
|
||||
static Attrs FeatureListDenseShapes(const gtl::ArraySlice<PartialTensorShape>& x) {
|
||||
return Attrs().FeatureListDenseShapes(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::OutputList context_sparse_indices;
|
||||
::tensorflow::OutputList context_sparse_values;
|
||||
::tensorflow::OutputList context_sparse_shapes;
|
||||
::tensorflow::OutputList context_dense_values;
|
||||
::tensorflow::OutputList feature_list_sparse_indices;
|
||||
::tensorflow::OutputList feature_list_sparse_values;
|
||||
::tensorflow::OutputList feature_list_sparse_shapes;
|
||||
::tensorflow::OutputList feature_list_dense_values;
|
||||
};
|
||||
|
||||
/// Transforms a serialized tensorflow.TensorProto proto into a Tensor.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * serialized: A scalar string containing a serialized TensorProto proto.
|
||||
/// * out_type: The type of the serialized tensor. The provided type must match the
|
||||
/// type of the serialized tensor and no implicit conversion will take place.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: A Tensor of type `out_type`.
|
||||
class ParseTensor {
|
||||
public:
|
||||
ParseTensor(const ::tensorflow::Scope& scope, ::tensorflow::Input serialized,
|
||||
DataType out_type);
|
||||
operator ::tensorflow::Output() const { return output; }
|
||||
operator ::tensorflow::Input() const { return output; }
|
||||
::tensorflow::Node* node() const { return output.node(); }
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output;
|
||||
};
|
||||
|
||||
/// Transforms a Tensor into a serialized TensorProto proto.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * tensor: A Tensor of type `T`.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: A serialized TensorProto proto of the input tensor.
|
||||
class SerializeTensor {
|
||||
public:
|
||||
SerializeTensor(const ::tensorflow::Scope& scope, ::tensorflow::Input tensor);
|
||||
operator ::tensorflow::Output() const { return serialized; }
|
||||
operator ::tensorflow::Input() const { return serialized; }
|
||||
::tensorflow::Node* node() const { return serialized.node(); }
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output serialized;
|
||||
};
|
||||
|
||||
/// Converts each string in the input Tensor to the specified numeric type.
|
||||
///
|
||||
/// (Note that int32 overflow results in an error while float overflow
|
||||
/// results in a rounded value.)
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
///
|
||||
/// Optional attributes (see `Attrs`):
|
||||
/// * out_type: The numeric type to interpret each string in `string_tensor` as.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: A Tensor of the same shape as the input `string_tensor`.
|
||||
class StringToNumber {
|
||||
public:
|
||||
/// Optional attribute setters for StringToNumber
|
||||
struct Attrs {
|
||||
/// The numeric type to interpret each string in `string_tensor` as.
|
||||
///
|
||||
/// Defaults to DT_FLOAT
|
||||
TF_MUST_USE_RESULT Attrs OutType(DataType x) {
|
||||
Attrs ret = *this;
|
||||
ret.out_type_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
DataType out_type_ = DT_FLOAT;
|
||||
};
|
||||
StringToNumber(const ::tensorflow::Scope& scope, ::tensorflow::Input
|
||||
string_tensor);
|
||||
StringToNumber(const ::tensorflow::Scope& scope, ::tensorflow::Input
|
||||
string_tensor, const StringToNumber::Attrs& attrs);
|
||||
operator ::tensorflow::Output() const { return output; }
|
||||
operator ::tensorflow::Input() const { return output; }
|
||||
::tensorflow::Node* node() const { return output.node(); }
|
||||
|
||||
static Attrs OutType(DataType x) {
|
||||
return Attrs().OutType(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output;
|
||||
};
|
||||
|
||||
/// @}
|
||||
|
||||
} // namespace ops
|
||||
} // namespace tensorflow
|
||||
|
||||
#endif // TENSORFLOW_CC_OPS_PARSING_OPS_H_
|
||||
@@ -0,0 +1,28 @@
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#ifndef TENSORFLOW_CC_OPS_PARSING_OPS_INTERNAL_H_
|
||||
#define TENSORFLOW_CC_OPS_PARSING_OPS_INTERNAL_H_
|
||||
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#include "tensorflow/cc/framework/ops.h"
|
||||
#include "tensorflow/cc/framework/scope.h"
|
||||
#include "tensorflow/core/framework/tensor.h"
|
||||
#include "tensorflow/core/framework/tensor_shape.h"
|
||||
#include "tensorflow/core/framework/types.h"
|
||||
#include "tensorflow/core/lib/gtl/array_slice.h"
|
||||
|
||||
namespace tensorflow {
|
||||
namespace ops {
|
||||
namespace internal {
|
||||
// NOTE: This namespace has internal TensorFlow details that
|
||||
// are not part of TensorFlow's public API.
|
||||
|
||||
/// @defgroup parsing_ops_internal Parsing Ops Internal
|
||||
/// @{
|
||||
|
||||
} // namespace internal
|
||||
} // namespace ops
|
||||
} // namespace tensorflow
|
||||
|
||||
#endif // TENSORFLOW_CC_OPS_PARSING_OPS_INTERNAL_H_
|
||||
@@ -0,0 +1,663 @@
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#ifndef TENSORFLOW_CC_OPS_RANDOM_OPS_H_
|
||||
#define TENSORFLOW_CC_OPS_RANDOM_OPS_H_
|
||||
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#include "tensorflow/cc/framework/ops.h"
|
||||
#include "tensorflow/cc/framework/scope.h"
|
||||
#include "tensorflow/core/framework/tensor.h"
|
||||
#include "tensorflow/core/framework/tensor_shape.h"
|
||||
#include "tensorflow/core/framework/types.h"
|
||||
#include "tensorflow/core/lib/gtl/array_slice.h"
|
||||
|
||||
namespace tensorflow {
|
||||
namespace ops {
|
||||
|
||||
/// @defgroup random_ops Random Ops
|
||||
/// @{
|
||||
|
||||
/// Draws samples from a multinomial distribution.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * logits: 2-D Tensor with shape `[batch_size, num_classes]`. Each slice `[i, :]`
|
||||
/// represents the unnormalized log probabilities for all classes.
|
||||
/// * num_samples: 0-D. Number of independent samples to draw for each row slice.
|
||||
///
|
||||
/// Optional attributes (see `Attrs`):
|
||||
/// * seed: If either seed or seed2 is set to be non-zero, the internal random number
|
||||
/// generator is seeded by the given seed. Otherwise, a random seed is used.
|
||||
/// * seed2: A second seed to avoid seed collision.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: 2-D Tensor with shape `[batch_size, num_samples]`. Each slice `[i, :]`
|
||||
/// contains the drawn class labels with range `[0, num_classes)`.
|
||||
class Multinomial {
|
||||
public:
|
||||
/// Optional attribute setters for Multinomial
|
||||
struct Attrs {
|
||||
/// If either seed or seed2 is set to be non-zero, the internal random number
|
||||
/// generator is seeded by the given seed. Otherwise, a random seed is used.
|
||||
///
|
||||
/// Defaults to 0
|
||||
TF_MUST_USE_RESULT Attrs Seed(int64 x) {
|
||||
Attrs ret = *this;
|
||||
ret.seed_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// A second seed to avoid seed collision.
|
||||
///
|
||||
/// Defaults to 0
|
||||
TF_MUST_USE_RESULT Attrs Seed2(int64 x) {
|
||||
Attrs ret = *this;
|
||||
ret.seed2_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// Defaults to DT_INT64
|
||||
TF_MUST_USE_RESULT Attrs OutputDtype(DataType x) {
|
||||
Attrs ret = *this;
|
||||
ret.output_dtype_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int64 seed_ = 0;
|
||||
int64 seed2_ = 0;
|
||||
DataType output_dtype_ = DT_INT64;
|
||||
};
|
||||
Multinomial(const ::tensorflow::Scope& scope, ::tensorflow::Input logits,
|
||||
::tensorflow::Input num_samples);
|
||||
Multinomial(const ::tensorflow::Scope& scope, ::tensorflow::Input logits,
|
||||
::tensorflow::Input num_samples, const Multinomial::Attrs& attrs);
|
||||
operator ::tensorflow::Output() const { return output; }
|
||||
operator ::tensorflow::Input() const { return output; }
|
||||
::tensorflow::Node* node() const { return output.node(); }
|
||||
|
||||
static Attrs Seed(int64 x) {
|
||||
return Attrs().Seed(x);
|
||||
}
|
||||
static Attrs Seed2(int64 x) {
|
||||
return Attrs().Seed2(x);
|
||||
}
|
||||
static Attrs OutputDtype(DataType x) {
|
||||
return Attrs().OutputDtype(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output;
|
||||
};
|
||||
|
||||
/// Outputs random values from a normal distribution. The parameters may each be a
|
||||
///
|
||||
/// scalar which applies to the entire output, or a vector of length shape[0] which
|
||||
/// stores the parameters for each batch.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * shape: The shape of the output tensor. Batches are indexed by the 0th dimension.
|
||||
/// * means: The mean parameter of each batch.
|
||||
/// * stdevs: The standard deviation parameter of each batch. Must be greater than 0.
|
||||
/// * minvals: The minimum cutoff. May be -infinity.
|
||||
/// * maxvals: The maximum cutoff. May be +infinity, and must be more than the minval
|
||||
/// for each batch.
|
||||
///
|
||||
/// Optional attributes (see `Attrs`):
|
||||
/// * seed: If either `seed` or `seed2` are set to be non-zero, the random number
|
||||
/// generator is seeded by the given seed. Otherwise, it is seeded by a
|
||||
/// random seed.
|
||||
/// * seed2: A second seed to avoid seed collision.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: A matrix of shape num_batches x samples_per_batch, filled with random
|
||||
/// truncated normal values using the parameters for each row.
|
||||
class ParameterizedTruncatedNormal {
|
||||
public:
|
||||
/// Optional attribute setters for ParameterizedTruncatedNormal
|
||||
struct Attrs {
|
||||
/// If either `seed` or `seed2` are set to be non-zero, the random number
|
||||
/// generator is seeded by the given seed. Otherwise, it is seeded by a
|
||||
/// random seed.
|
||||
///
|
||||
/// Defaults to 0
|
||||
TF_MUST_USE_RESULT Attrs Seed(int64 x) {
|
||||
Attrs ret = *this;
|
||||
ret.seed_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// A second seed to avoid seed collision.
|
||||
///
|
||||
/// Defaults to 0
|
||||
TF_MUST_USE_RESULT Attrs Seed2(int64 x) {
|
||||
Attrs ret = *this;
|
||||
ret.seed2_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int64 seed_ = 0;
|
||||
int64 seed2_ = 0;
|
||||
};
|
||||
ParameterizedTruncatedNormal(const ::tensorflow::Scope& scope,
|
||||
::tensorflow::Input shape, ::tensorflow::Input
|
||||
means, ::tensorflow::Input stdevs,
|
||||
::tensorflow::Input minvals, ::tensorflow::Input
|
||||
maxvals);
|
||||
ParameterizedTruncatedNormal(const ::tensorflow::Scope& scope,
|
||||
::tensorflow::Input shape, ::tensorflow::Input
|
||||
means, ::tensorflow::Input stdevs,
|
||||
::tensorflow::Input minvals, ::tensorflow::Input
|
||||
maxvals, const
|
||||
ParameterizedTruncatedNormal::Attrs& attrs);
|
||||
operator ::tensorflow::Output() const { return output; }
|
||||
operator ::tensorflow::Input() const { return output; }
|
||||
::tensorflow::Node* node() const { return output.node(); }
|
||||
|
||||
static Attrs Seed(int64 x) {
|
||||
return Attrs().Seed(x);
|
||||
}
|
||||
static Attrs Seed2(int64 x) {
|
||||
return Attrs().Seed2(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output;
|
||||
};
|
||||
|
||||
/// Outputs random values from the Gamma distribution(s) described by alpha.
|
||||
///
|
||||
/// This op uses the algorithm by Marsaglia et al. to acquire samples via
|
||||
/// transformation-rejection from pairs of uniform and normal random variables.
|
||||
/// See http://dl.acm.org/citation.cfm?id=358414
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * shape: 1-D integer tensor. Shape of independent samples to draw from each
|
||||
/// distribution described by the shape parameters given in alpha.
|
||||
/// * alpha: A tensor in which each scalar is a "shape" parameter describing the
|
||||
/// associated gamma distribution.
|
||||
///
|
||||
/// Optional attributes (see `Attrs`):
|
||||
/// * seed: If either `seed` or `seed2` are set to be non-zero, the random number
|
||||
/// generator is seeded by the given seed. Otherwise, it is seeded by a
|
||||
/// random seed.
|
||||
/// * seed2: A second seed to avoid seed collision.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: A tensor with shape `shape + shape(alpha)`. Each slice
|
||||
/// `[:, ..., :, i0, i1, ...iN]` contains the samples drawn for
|
||||
/// `alpha[i0, i1, ...iN]`. The dtype of the output matches the dtype of alpha.
|
||||
class RandomGamma {
|
||||
public:
|
||||
/// Optional attribute setters for RandomGamma
|
||||
struct Attrs {
|
||||
/// If either `seed` or `seed2` are set to be non-zero, the random number
|
||||
/// generator is seeded by the given seed. Otherwise, it is seeded by a
|
||||
/// random seed.
|
||||
///
|
||||
/// Defaults to 0
|
||||
TF_MUST_USE_RESULT Attrs Seed(int64 x) {
|
||||
Attrs ret = *this;
|
||||
ret.seed_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// A second seed to avoid seed collision.
|
||||
///
|
||||
/// Defaults to 0
|
||||
TF_MUST_USE_RESULT Attrs Seed2(int64 x) {
|
||||
Attrs ret = *this;
|
||||
ret.seed2_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int64 seed_ = 0;
|
||||
int64 seed2_ = 0;
|
||||
};
|
||||
RandomGamma(const ::tensorflow::Scope& scope, ::tensorflow::Input shape,
|
||||
::tensorflow::Input alpha);
|
||||
RandomGamma(const ::tensorflow::Scope& scope, ::tensorflow::Input shape,
|
||||
::tensorflow::Input alpha, const RandomGamma::Attrs& attrs);
|
||||
operator ::tensorflow::Output() const { return output; }
|
||||
operator ::tensorflow::Input() const { return output; }
|
||||
::tensorflow::Node* node() const { return output.node(); }
|
||||
|
||||
static Attrs Seed(int64 x) {
|
||||
return Attrs().Seed(x);
|
||||
}
|
||||
static Attrs Seed2(int64 x) {
|
||||
return Attrs().Seed2(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output;
|
||||
};
|
||||
|
||||
/// Outputs random values from the Poisson distribution(s) described by rate.
|
||||
///
|
||||
/// This op uses two algorithms, depending on rate. If rate >= 10, then
|
||||
/// the algorithm by Hormann is used to acquire samples via
|
||||
/// transformation-rejection.
|
||||
/// See http://www.sciencedirect.com/science/article/pii/0167668793909974.
|
||||
///
|
||||
/// Otherwise, Knuth's algorithm is used to acquire samples via multiplying uniform
|
||||
/// random variables.
|
||||
/// See Donald E. Knuth (1969). Seminumerical Algorithms. The Art of Computer
|
||||
/// Programming, Volume 2. Addison Wesley
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * shape: 1-D integer tensor. Shape of independent samples to draw from each
|
||||
/// distribution described by the shape parameters given in rate.
|
||||
/// * rate: A tensor in which each scalar is a "rate" parameter describing the
|
||||
/// associated poisson distribution.
|
||||
///
|
||||
/// Optional attributes (see `Attrs`):
|
||||
/// * seed: If either `seed` or `seed2` are set to be non-zero, the random number
|
||||
/// generator is seeded by the given seed. Otherwise, it is seeded by a
|
||||
/// random seed.
|
||||
/// * seed2: A second seed to avoid seed collision.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: A tensor with shape `shape + shape(rate)`. Each slice
|
||||
/// `[:, ..., :, i0, i1, ...iN]` contains the samples drawn for
|
||||
/// `rate[i0, i1, ...iN]`.
|
||||
class RandomPoissonV2 {
|
||||
public:
|
||||
/// Optional attribute setters for RandomPoissonV2
|
||||
struct Attrs {
|
||||
/// If either `seed` or `seed2` are set to be non-zero, the random number
|
||||
/// generator is seeded by the given seed. Otherwise, it is seeded by a
|
||||
/// random seed.
|
||||
///
|
||||
/// Defaults to 0
|
||||
TF_MUST_USE_RESULT Attrs Seed(int64 x) {
|
||||
Attrs ret = *this;
|
||||
ret.seed_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// A second seed to avoid seed collision.
|
||||
///
|
||||
/// Defaults to 0
|
||||
TF_MUST_USE_RESULT Attrs Seed2(int64 x) {
|
||||
Attrs ret = *this;
|
||||
ret.seed2_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// Defaults to DT_INT64
|
||||
TF_MUST_USE_RESULT Attrs Dtype(DataType x) {
|
||||
Attrs ret = *this;
|
||||
ret.dtype_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int64 seed_ = 0;
|
||||
int64 seed2_ = 0;
|
||||
DataType dtype_ = DT_INT64;
|
||||
};
|
||||
RandomPoissonV2(const ::tensorflow::Scope& scope, ::tensorflow::Input shape,
|
||||
::tensorflow::Input rate);
|
||||
RandomPoissonV2(const ::tensorflow::Scope& scope, ::tensorflow::Input shape,
|
||||
::tensorflow::Input rate, const RandomPoissonV2::Attrs& attrs);
|
||||
operator ::tensorflow::Output() const { return output; }
|
||||
operator ::tensorflow::Input() const { return output; }
|
||||
::tensorflow::Node* node() const { return output.node(); }
|
||||
|
||||
static Attrs Seed(int64 x) {
|
||||
return Attrs().Seed(x);
|
||||
}
|
||||
static Attrs Seed2(int64 x) {
|
||||
return Attrs().Seed2(x);
|
||||
}
|
||||
static Attrs Dtype(DataType x) {
|
||||
return Attrs().Dtype(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output;
|
||||
};
|
||||
|
||||
/// Randomly shuffles a tensor along its first dimension.
|
||||
///
|
||||
/// The tensor is shuffled along dimension 0, such that each `value[j]` is mapped
|
||||
/// to one and only one `output[i]`. For example, a mapping that might occur for a
|
||||
/// 3x2 tensor is:
|
||||
///
|
||||
/// ```
|
||||
/// [[1, 2], [[5, 6],
|
||||
/// [3, 4], ==> [1, 2],
|
||||
/// [5, 6]] [3, 4]]
|
||||
/// ```
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * value: The tensor to be shuffled.
|
||||
///
|
||||
/// Optional attributes (see `Attrs`):
|
||||
/// * seed: If either `seed` or `seed2` are set to be non-zero, the random number
|
||||
/// generator is seeded by the given seed. Otherwise, it is seeded by a
|
||||
/// random seed.
|
||||
/// * seed2: A second seed to avoid seed collision.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: A tensor of same shape and type as `value`, shuffled along its first
|
||||
/// dimension.
|
||||
class RandomShuffle {
|
||||
public:
|
||||
/// Optional attribute setters for RandomShuffle
|
||||
struct Attrs {
|
||||
/// If either `seed` or `seed2` are set to be non-zero, the random number
|
||||
/// generator is seeded by the given seed. Otherwise, it is seeded by a
|
||||
/// random seed.
|
||||
///
|
||||
/// Defaults to 0
|
||||
TF_MUST_USE_RESULT Attrs Seed(int64 x) {
|
||||
Attrs ret = *this;
|
||||
ret.seed_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// A second seed to avoid seed collision.
|
||||
///
|
||||
/// Defaults to 0
|
||||
TF_MUST_USE_RESULT Attrs Seed2(int64 x) {
|
||||
Attrs ret = *this;
|
||||
ret.seed2_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int64 seed_ = 0;
|
||||
int64 seed2_ = 0;
|
||||
};
|
||||
RandomShuffle(const ::tensorflow::Scope& scope, ::tensorflow::Input value);
|
||||
RandomShuffle(const ::tensorflow::Scope& scope, ::tensorflow::Input value,
|
||||
const RandomShuffle::Attrs& attrs);
|
||||
operator ::tensorflow::Output() const { return output; }
|
||||
operator ::tensorflow::Input() const { return output; }
|
||||
::tensorflow::Node* node() const { return output.node(); }
|
||||
|
||||
static Attrs Seed(int64 x) {
|
||||
return Attrs().Seed(x);
|
||||
}
|
||||
static Attrs Seed2(int64 x) {
|
||||
return Attrs().Seed2(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output;
|
||||
};
|
||||
|
||||
/// Outputs random values from a normal distribution.
|
||||
///
|
||||
/// The generated values will have mean 0 and standard deviation 1.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * shape: The shape of the output tensor.
|
||||
/// * dtype: The type of the output.
|
||||
///
|
||||
/// Optional attributes (see `Attrs`):
|
||||
/// * seed: If either `seed` or `seed2` are set to be non-zero, the random number
|
||||
/// generator is seeded by the given seed. Otherwise, it is seeded by a
|
||||
/// random seed.
|
||||
/// * seed2: A second seed to avoid seed collision.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: A tensor of the specified shape filled with random normal values.
|
||||
class RandomNormal {
|
||||
public:
|
||||
/// Optional attribute setters for RandomNormal
|
||||
struct Attrs {
|
||||
/// If either `seed` or `seed2` are set to be non-zero, the random number
|
||||
/// generator is seeded by the given seed. Otherwise, it is seeded by a
|
||||
/// random seed.
|
||||
///
|
||||
/// Defaults to 0
|
||||
TF_MUST_USE_RESULT Attrs Seed(int64 x) {
|
||||
Attrs ret = *this;
|
||||
ret.seed_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// A second seed to avoid seed collision.
|
||||
///
|
||||
/// Defaults to 0
|
||||
TF_MUST_USE_RESULT Attrs Seed2(int64 x) {
|
||||
Attrs ret = *this;
|
||||
ret.seed2_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int64 seed_ = 0;
|
||||
int64 seed2_ = 0;
|
||||
};
|
||||
RandomNormal(const ::tensorflow::Scope& scope, ::tensorflow::Input shape,
|
||||
DataType dtype);
|
||||
RandomNormal(const ::tensorflow::Scope& scope, ::tensorflow::Input shape,
|
||||
DataType dtype, const RandomNormal::Attrs& attrs);
|
||||
operator ::tensorflow::Output() const { return output; }
|
||||
operator ::tensorflow::Input() const { return output; }
|
||||
::tensorflow::Node* node() const { return output.node(); }
|
||||
|
||||
static Attrs Seed(int64 x) {
|
||||
return Attrs().Seed(x);
|
||||
}
|
||||
static Attrs Seed2(int64 x) {
|
||||
return Attrs().Seed2(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output;
|
||||
};
|
||||
|
||||
/// Outputs random values from a uniform distribution.
|
||||
///
|
||||
/// The generated values follow a uniform distribution in the range `[0, 1)`. The
|
||||
/// lower bound 0 is included in the range, while the upper bound 1 is excluded.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * shape: The shape of the output tensor.
|
||||
/// * dtype: The type of the output.
|
||||
///
|
||||
/// Optional attributes (see `Attrs`):
|
||||
/// * seed: If either `seed` or `seed2` are set to be non-zero, the random number
|
||||
/// generator is seeded by the given seed. Otherwise, it is seeded by a
|
||||
/// random seed.
|
||||
/// * seed2: A second seed to avoid seed collision.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: A tensor of the specified shape filled with uniform random values.
|
||||
class RandomUniform {
|
||||
public:
|
||||
/// Optional attribute setters for RandomUniform
|
||||
struct Attrs {
|
||||
/// If either `seed` or `seed2` are set to be non-zero, the random number
|
||||
/// generator is seeded by the given seed. Otherwise, it is seeded by a
|
||||
/// random seed.
|
||||
///
|
||||
/// Defaults to 0
|
||||
TF_MUST_USE_RESULT Attrs Seed(int64 x) {
|
||||
Attrs ret = *this;
|
||||
ret.seed_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// A second seed to avoid seed collision.
|
||||
///
|
||||
/// Defaults to 0
|
||||
TF_MUST_USE_RESULT Attrs Seed2(int64 x) {
|
||||
Attrs ret = *this;
|
||||
ret.seed2_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int64 seed_ = 0;
|
||||
int64 seed2_ = 0;
|
||||
};
|
||||
RandomUniform(const ::tensorflow::Scope& scope, ::tensorflow::Input shape,
|
||||
DataType dtype);
|
||||
RandomUniform(const ::tensorflow::Scope& scope, ::tensorflow::Input shape,
|
||||
DataType dtype, const RandomUniform::Attrs& attrs);
|
||||
operator ::tensorflow::Output() const { return output; }
|
||||
operator ::tensorflow::Input() const { return output; }
|
||||
::tensorflow::Node* node() const { return output.node(); }
|
||||
|
||||
static Attrs Seed(int64 x) {
|
||||
return Attrs().Seed(x);
|
||||
}
|
||||
static Attrs Seed2(int64 x) {
|
||||
return Attrs().Seed2(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output;
|
||||
};
|
||||
|
||||
/// Outputs random integers from a uniform distribution.
|
||||
///
|
||||
/// The generated values are uniform integers in the range `[minval, maxval)`.
|
||||
/// The lower bound `minval` is included in the range, while the upper bound
|
||||
/// `maxval` is excluded.
|
||||
///
|
||||
/// The random integers are slightly biased unless `maxval - minval` is an exact
|
||||
/// power of two. The bias is small for values of `maxval - minval` significantly
|
||||
/// smaller than the range of the output (either `2^32` or `2^64`).
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * shape: The shape of the output tensor.
|
||||
/// * minval: 0-D. Inclusive lower bound on the generated integers.
|
||||
/// * maxval: 0-D. Exclusive upper bound on the generated integers.
|
||||
///
|
||||
/// Optional attributes (see `Attrs`):
|
||||
/// * seed: If either `seed` or `seed2` are set to be non-zero, the random number
|
||||
/// generator is seeded by the given seed. Otherwise, it is seeded by a
|
||||
/// random seed.
|
||||
/// * seed2: A second seed to avoid seed collision.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: A tensor of the specified shape filled with uniform random integers.
|
||||
class RandomUniformInt {
|
||||
public:
|
||||
/// Optional attribute setters for RandomUniformInt
|
||||
struct Attrs {
|
||||
/// If either `seed` or `seed2` are set to be non-zero, the random number
|
||||
/// generator is seeded by the given seed. Otherwise, it is seeded by a
|
||||
/// random seed.
|
||||
///
|
||||
/// Defaults to 0
|
||||
TF_MUST_USE_RESULT Attrs Seed(int64 x) {
|
||||
Attrs ret = *this;
|
||||
ret.seed_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// A second seed to avoid seed collision.
|
||||
///
|
||||
/// Defaults to 0
|
||||
TF_MUST_USE_RESULT Attrs Seed2(int64 x) {
|
||||
Attrs ret = *this;
|
||||
ret.seed2_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int64 seed_ = 0;
|
||||
int64 seed2_ = 0;
|
||||
};
|
||||
RandomUniformInt(const ::tensorflow::Scope& scope, ::tensorflow::Input shape,
|
||||
::tensorflow::Input minval, ::tensorflow::Input maxval);
|
||||
RandomUniformInt(const ::tensorflow::Scope& scope, ::tensorflow::Input shape,
|
||||
::tensorflow::Input minval, ::tensorflow::Input maxval, const
|
||||
RandomUniformInt::Attrs& attrs);
|
||||
operator ::tensorflow::Output() const { return output; }
|
||||
operator ::tensorflow::Input() const { return output; }
|
||||
::tensorflow::Node* node() const { return output.node(); }
|
||||
|
||||
static Attrs Seed(int64 x) {
|
||||
return Attrs().Seed(x);
|
||||
}
|
||||
static Attrs Seed2(int64 x) {
|
||||
return Attrs().Seed2(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output;
|
||||
};
|
||||
|
||||
/// Outputs random values from a truncated normal distribution.
|
||||
///
|
||||
/// The generated values follow a normal distribution with mean 0 and standard
|
||||
/// deviation 1, except that values whose magnitude is more than 2 standard
|
||||
/// deviations from the mean are dropped and re-picked.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * shape: The shape of the output tensor.
|
||||
/// * dtype: The type of the output.
|
||||
///
|
||||
/// Optional attributes (see `Attrs`):
|
||||
/// * seed: If either `seed` or `seed2` are set to be non-zero, the random number
|
||||
/// generator is seeded by the given seed. Otherwise, it is seeded by a
|
||||
/// random seed.
|
||||
/// * seed2: A second seed to avoid seed collision.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: A tensor of the specified shape filled with random truncated normal
|
||||
/// values.
|
||||
class TruncatedNormal {
|
||||
public:
|
||||
/// Optional attribute setters for TruncatedNormal
|
||||
struct Attrs {
|
||||
/// If either `seed` or `seed2` are set to be non-zero, the random number
|
||||
/// generator is seeded by the given seed. Otherwise, it is seeded by a
|
||||
/// random seed.
|
||||
///
|
||||
/// Defaults to 0
|
||||
TF_MUST_USE_RESULT Attrs Seed(int64 x) {
|
||||
Attrs ret = *this;
|
||||
ret.seed_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// A second seed to avoid seed collision.
|
||||
///
|
||||
/// Defaults to 0
|
||||
TF_MUST_USE_RESULT Attrs Seed2(int64 x) {
|
||||
Attrs ret = *this;
|
||||
ret.seed2_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int64 seed_ = 0;
|
||||
int64 seed2_ = 0;
|
||||
};
|
||||
TruncatedNormal(const ::tensorflow::Scope& scope, ::tensorflow::Input shape,
|
||||
DataType dtype);
|
||||
TruncatedNormal(const ::tensorflow::Scope& scope, ::tensorflow::Input shape,
|
||||
DataType dtype, const TruncatedNormal::Attrs& attrs);
|
||||
operator ::tensorflow::Output() const { return output; }
|
||||
operator ::tensorflow::Input() const { return output; }
|
||||
::tensorflow::Node* node() const { return output.node(); }
|
||||
|
||||
static Attrs Seed(int64 x) {
|
||||
return Attrs().Seed(x);
|
||||
}
|
||||
static Attrs Seed2(int64 x) {
|
||||
return Attrs().Seed2(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output;
|
||||
};
|
||||
|
||||
/// @}
|
||||
|
||||
} // namespace ops
|
||||
} // namespace tensorflow
|
||||
|
||||
#endif // TENSORFLOW_CC_OPS_RANDOM_OPS_H_
|
||||
@@ -0,0 +1,47 @@
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#ifndef TENSORFLOW_CC_OPS_RANDOM_OPS_INTERNAL_H_
|
||||
#define TENSORFLOW_CC_OPS_RANDOM_OPS_INTERNAL_H_
|
||||
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#include "tensorflow/cc/framework/ops.h"
|
||||
#include "tensorflow/cc/framework/scope.h"
|
||||
#include "tensorflow/core/framework/tensor.h"
|
||||
#include "tensorflow/core/framework/tensor_shape.h"
|
||||
#include "tensorflow/core/framework/types.h"
|
||||
#include "tensorflow/core/lib/gtl/array_slice.h"
|
||||
|
||||
namespace tensorflow {
|
||||
namespace ops {
|
||||
namespace internal {
|
||||
// NOTE: This namespace has internal TensorFlow details that
|
||||
// are not part of TensorFlow's public API.
|
||||
|
||||
/// @defgroup random_ops_internal Random Ops Internal
|
||||
/// @{
|
||||
|
||||
/// Computes the derivative of a Gamma random sample w.r.t. `alpha`.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: The output tensor.
|
||||
class RandomGammaGrad {
|
||||
public:
|
||||
RandomGammaGrad(const ::tensorflow::Scope& scope, ::tensorflow::Input alpha,
|
||||
::tensorflow::Input sample);
|
||||
operator ::tensorflow::Output() const { return output; }
|
||||
operator ::tensorflow::Input() const { return output; }
|
||||
::tensorflow::Node* node() const { return output.node(); }
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output;
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
} // namespace ops
|
||||
} // namespace tensorflow
|
||||
|
||||
#endif // TENSORFLOW_CC_OPS_RANDOM_OPS_INTERNAL_H_
|
||||
@@ -0,0 +1,46 @@
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#ifndef TENSORFLOW_CC_OPS_REMOTE_FUSED_GRAPH_OPS_H_
|
||||
#define TENSORFLOW_CC_OPS_REMOTE_FUSED_GRAPH_OPS_H_
|
||||
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#include "tensorflow/cc/framework/ops.h"
|
||||
#include "tensorflow/cc/framework/scope.h"
|
||||
#include "tensorflow/core/framework/tensor.h"
|
||||
#include "tensorflow/core/framework/tensor_shape.h"
|
||||
#include "tensorflow/core/framework/types.h"
|
||||
#include "tensorflow/core/lib/gtl/array_slice.h"
|
||||
|
||||
namespace tensorflow {
|
||||
namespace ops {
|
||||
|
||||
/// @defgroup remote_fused_graph_ops Remote Fused Graph Ops
|
||||
/// @{
|
||||
|
||||
/// TODO: add doc.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
///
|
||||
/// Returns:
|
||||
/// * `OutputList`: The outputs tensor.
|
||||
class RemoteFusedGraphExecute {
|
||||
public:
|
||||
RemoteFusedGraphExecute(const ::tensorflow::Scope& scope,
|
||||
::tensorflow::InputList inputs, const DataTypeSlice&
|
||||
Toutputs, StringPiece
|
||||
serialized_remote_fused_graph_execute_info);
|
||||
::tensorflow::Output operator[](size_t index) const { return outputs[index]; }
|
||||
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::OutputList outputs;
|
||||
};
|
||||
|
||||
/// @}
|
||||
|
||||
} // namespace ops
|
||||
} // namespace tensorflow
|
||||
|
||||
#endif // TENSORFLOW_CC_OPS_REMOTE_FUSED_GRAPH_OPS_H_
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,28 @@
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#ifndef TENSORFLOW_CC_OPS_SPARSE_OPS_INTERNAL_H_
|
||||
#define TENSORFLOW_CC_OPS_SPARSE_OPS_INTERNAL_H_
|
||||
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#include "tensorflow/cc/framework/ops.h"
|
||||
#include "tensorflow/cc/framework/scope.h"
|
||||
#include "tensorflow/core/framework/tensor.h"
|
||||
#include "tensorflow/core/framework/tensor_shape.h"
|
||||
#include "tensorflow/core/framework/types.h"
|
||||
#include "tensorflow/core/lib/gtl/array_slice.h"
|
||||
|
||||
namespace tensorflow {
|
||||
namespace ops {
|
||||
namespace internal {
|
||||
// NOTE: This namespace has internal TensorFlow details that
|
||||
// are not part of TensorFlow's public API.
|
||||
|
||||
/// @defgroup sparse_ops_internal Sparse Ops Internal
|
||||
/// @{
|
||||
|
||||
} // namespace internal
|
||||
} // namespace ops
|
||||
} // namespace tensorflow
|
||||
|
||||
#endif // TENSORFLOW_CC_OPS_SPARSE_OPS_INTERNAL_H_
|
||||
@@ -0,0 +1,40 @@
|
||||
/* Copyright 2016 The TensorFlow Authors. All Rights Reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==============================================================================*/
|
||||
|
||||
#ifndef TENSORFLOW_CC_OPS_STANDARD_OPS_H_
|
||||
#define TENSORFLOW_CC_OPS_STANDARD_OPS_H_
|
||||
|
||||
#include "tensorflow/cc/ops/array_ops.h"
|
||||
#include "tensorflow/cc/ops/candidate_sampling_ops.h"
|
||||
#include "tensorflow/cc/ops/const_op.h"
|
||||
#include "tensorflow/cc/ops/control_flow_ops.h"
|
||||
#include "tensorflow/cc/ops/data_flow_ops.h"
|
||||
#include "tensorflow/cc/ops/image_ops.h"
|
||||
#include "tensorflow/cc/ops/io_ops.h"
|
||||
#include "tensorflow/cc/ops/linalg_ops.h"
|
||||
#include "tensorflow/cc/ops/logging_ops.h"
|
||||
#include "tensorflow/cc/ops/lookup_ops.h"
|
||||
#include "tensorflow/cc/ops/math_ops.h"
|
||||
#include "tensorflow/cc/ops/nn_ops.h"
|
||||
#include "tensorflow/cc/ops/no_op.h"
|
||||
#include "tensorflow/cc/ops/parsing_ops.h"
|
||||
#include "tensorflow/cc/ops/random_ops.h"
|
||||
#include "tensorflow/cc/ops/sparse_ops.h"
|
||||
#include "tensorflow/cc/ops/state_ops.h"
|
||||
#include "tensorflow/cc/ops/string_ops.h"
|
||||
#include "tensorflow/cc/ops/training_ops.h"
|
||||
#include "tensorflow/cc/ops/user_ops.h"
|
||||
|
||||
#endif // TENSORFLOW_CC_OPS_STANDARD_OPS_H_
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,28 @@
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#ifndef TENSORFLOW_CC_OPS_STATE_OPS_INTERNAL_H_
|
||||
#define TENSORFLOW_CC_OPS_STATE_OPS_INTERNAL_H_
|
||||
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#include "tensorflow/cc/framework/ops.h"
|
||||
#include "tensorflow/cc/framework/scope.h"
|
||||
#include "tensorflow/core/framework/tensor.h"
|
||||
#include "tensorflow/core/framework/tensor_shape.h"
|
||||
#include "tensorflow/core/framework/types.h"
|
||||
#include "tensorflow/core/lib/gtl/array_slice.h"
|
||||
|
||||
namespace tensorflow {
|
||||
namespace ops {
|
||||
namespace internal {
|
||||
// NOTE: This namespace has internal TensorFlow details that
|
||||
// are not part of TensorFlow's public API.
|
||||
|
||||
/// @defgroup state_ops_internal State Ops Internal
|
||||
/// @{
|
||||
|
||||
} // namespace internal
|
||||
} // namespace ops
|
||||
} // namespace tensorflow
|
||||
|
||||
#endif // TENSORFLOW_CC_OPS_STATE_OPS_INTERNAL_H_
|
||||
@@ -0,0 +1,902 @@
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#ifndef TENSORFLOW_CC_OPS_STRING_OPS_H_
|
||||
#define TENSORFLOW_CC_OPS_STRING_OPS_H_
|
||||
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#include "tensorflow/cc/framework/ops.h"
|
||||
#include "tensorflow/cc/framework/scope.h"
|
||||
#include "tensorflow/core/framework/tensor.h"
|
||||
#include "tensorflow/core/framework/tensor_shape.h"
|
||||
#include "tensorflow/core/framework/types.h"
|
||||
#include "tensorflow/core/lib/gtl/array_slice.h"
|
||||
|
||||
namespace tensorflow {
|
||||
namespace ops {
|
||||
|
||||
/// @defgroup string_ops String Ops
|
||||
/// @{
|
||||
|
||||
/// Converts each entry in the given tensor to strings. Supports many numeric
|
||||
///
|
||||
/// types and boolean.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
///
|
||||
/// Optional attributes (see `Attrs`):
|
||||
/// * precision: The post-decimal precision to use for floating point numbers.
|
||||
/// Only used if precision > -1.
|
||||
/// * scientific: Use scientific notation for floating point numbers.
|
||||
/// * shortest: Use shortest representation (either scientific or standard) for
|
||||
/// floating point numbers.
|
||||
/// * width: Pad pre-decimal numbers to this width.
|
||||
/// Applies to both floating point and integer numbers.
|
||||
/// Only used if width > -1.
|
||||
/// * fill: The value to pad if width > -1. If empty, pads with spaces.
|
||||
/// Another typical value is '0'. String cannot be longer than 1 character.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: The output tensor.
|
||||
class AsString {
|
||||
public:
|
||||
/// Optional attribute setters for AsString
|
||||
struct Attrs {
|
||||
/// The post-decimal precision to use for floating point numbers.
|
||||
/// Only used if precision > -1.
|
||||
///
|
||||
/// Defaults to -1
|
||||
TF_MUST_USE_RESULT Attrs Precision(int64 x) {
|
||||
Attrs ret = *this;
|
||||
ret.precision_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// Use scientific notation for floating point numbers.
|
||||
///
|
||||
/// Defaults to false
|
||||
TF_MUST_USE_RESULT Attrs Scientific(bool x) {
|
||||
Attrs ret = *this;
|
||||
ret.scientific_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// Use shortest representation (either scientific or standard) for
|
||||
/// floating point numbers.
|
||||
///
|
||||
/// Defaults to false
|
||||
TF_MUST_USE_RESULT Attrs Shortest(bool x) {
|
||||
Attrs ret = *this;
|
||||
ret.shortest_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// Pad pre-decimal numbers to this width.
|
||||
/// Applies to both floating point and integer numbers.
|
||||
/// Only used if width > -1.
|
||||
///
|
||||
/// Defaults to -1
|
||||
TF_MUST_USE_RESULT Attrs Width(int64 x) {
|
||||
Attrs ret = *this;
|
||||
ret.width_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// The value to pad if width > -1. If empty, pads with spaces.
|
||||
/// Another typical value is '0'. String cannot be longer than 1 character.
|
||||
///
|
||||
/// Defaults to ""
|
||||
TF_MUST_USE_RESULT Attrs Fill(StringPiece x) {
|
||||
Attrs ret = *this;
|
||||
ret.fill_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int64 precision_ = -1;
|
||||
bool scientific_ = false;
|
||||
bool shortest_ = false;
|
||||
int64 width_ = -1;
|
||||
StringPiece fill_ = "";
|
||||
};
|
||||
AsString(const ::tensorflow::Scope& scope, ::tensorflow::Input input);
|
||||
AsString(const ::tensorflow::Scope& scope, ::tensorflow::Input input, const
|
||||
AsString::Attrs& attrs);
|
||||
operator ::tensorflow::Output() const { return output; }
|
||||
operator ::tensorflow::Input() const { return output; }
|
||||
::tensorflow::Node* node() const { return output.node(); }
|
||||
|
||||
static Attrs Precision(int64 x) {
|
||||
return Attrs().Precision(x);
|
||||
}
|
||||
static Attrs Scientific(bool x) {
|
||||
return Attrs().Scientific(x);
|
||||
}
|
||||
static Attrs Shortest(bool x) {
|
||||
return Attrs().Shortest(x);
|
||||
}
|
||||
static Attrs Width(int64 x) {
|
||||
return Attrs().Width(x);
|
||||
}
|
||||
static Attrs Fill(StringPiece x) {
|
||||
return Attrs().Fill(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output;
|
||||
};
|
||||
|
||||
/// Decode web-safe base64-encoded strings.
|
||||
///
|
||||
/// Input may or may not have padding at the end. See EncodeBase64 for padding.
|
||||
/// Web-safe means that input must use - and _ instead of + and /.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * input: Base64 strings to decode.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: Decoded strings.
|
||||
class DecodeBase64 {
|
||||
public:
|
||||
DecodeBase64(const ::tensorflow::Scope& scope, ::tensorflow::Input input);
|
||||
operator ::tensorflow::Output() const { return output; }
|
||||
operator ::tensorflow::Input() const { return output; }
|
||||
::tensorflow::Node* node() const { return output.node(); }
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output;
|
||||
};
|
||||
|
||||
/// Encode strings into web-safe base64 format.
|
||||
///
|
||||
/// Refer to the following article for more information on base64 format:
|
||||
/// en.wikipedia.org/wiki/Base64. Base64 strings may have padding with '=' at the
|
||||
/// end so that the encoded has length multiple of 4. See Padding section of the
|
||||
/// link above.
|
||||
///
|
||||
/// Web-safe means that the encoder uses - and _ instead of + and /.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * input: Strings to be encoded.
|
||||
///
|
||||
/// Optional attributes (see `Attrs`):
|
||||
/// * pad: Bool whether padding is applied at the ends.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: Input strings encoded in base64.
|
||||
class EncodeBase64 {
|
||||
public:
|
||||
/// Optional attribute setters for EncodeBase64
|
||||
struct Attrs {
|
||||
/// Bool whether padding is applied at the ends.
|
||||
///
|
||||
/// Defaults to false
|
||||
TF_MUST_USE_RESULT Attrs Pad(bool x) {
|
||||
Attrs ret = *this;
|
||||
ret.pad_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool pad_ = false;
|
||||
};
|
||||
EncodeBase64(const ::tensorflow::Scope& scope, ::tensorflow::Input input);
|
||||
EncodeBase64(const ::tensorflow::Scope& scope, ::tensorflow::Input input, const
|
||||
EncodeBase64::Attrs& attrs);
|
||||
operator ::tensorflow::Output() const { return output; }
|
||||
operator ::tensorflow::Input() const { return output; }
|
||||
::tensorflow::Node* node() const { return output.node(); }
|
||||
|
||||
static Attrs Pad(bool x) {
|
||||
return Attrs().Pad(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output;
|
||||
};
|
||||
|
||||
/// Joins a string Tensor across the given dimensions.
|
||||
///
|
||||
/// Computes the string join across dimensions in the given string Tensor of shape
|
||||
/// `[\\(d_0, d_1, ..., d_{n-1}\\)]`. Returns a new Tensor created by joining the input
|
||||
/// strings with the given separator (default: empty string). Negative indices are
|
||||
/// counted backwards from the end, with `-1` being equivalent to `n - 1`. If
|
||||
/// indices are not specified, joins across all dimensions beginning from `n - 1`
|
||||
/// through `0`.
|
||||
///
|
||||
/// For example:
|
||||
///
|
||||
/// ```python
|
||||
/// # tensor `a` is [["a", "b"], ["c", "d"]]
|
||||
/// tf.reduce_join(a, 0) ==> ["ac", "bd"]
|
||||
/// tf.reduce_join(a, 1) ==> ["ab", "cd"]
|
||||
/// tf.reduce_join(a, -2) = tf.reduce_join(a, 0) ==> ["ac", "bd"]
|
||||
/// tf.reduce_join(a, -1) = tf.reduce_join(a, 1) ==> ["ab", "cd"]
|
||||
/// tf.reduce_join(a, 0, keep_dims=True) ==> [["ac", "bd"]]
|
||||
/// tf.reduce_join(a, 1, keep_dims=True) ==> [["ab"], ["cd"]]
|
||||
/// tf.reduce_join(a, 0, separator=".") ==> ["a.c", "b.d"]
|
||||
/// tf.reduce_join(a, [0, 1]) ==> "acbd"
|
||||
/// tf.reduce_join(a, [1, 0]) ==> "abcd"
|
||||
/// tf.reduce_join(a, []) ==> [["a", "b"], ["c", "d"]]
|
||||
/// tf.reduce_join(a) = tf.reduce_join(a, [1, 0]) ==> "abcd"
|
||||
/// ```
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * inputs: The input to be joined. All reduced indices must have non-zero size.
|
||||
/// * reduction_indices: The dimensions to reduce over. Dimensions are reduced in the
|
||||
/// order specified. Omitting `reduction_indices` is equivalent to passing
|
||||
/// `[n-1, n-2, ..., 0]`. Negative indices from `-n` to `-1` are supported.
|
||||
///
|
||||
/// Optional attributes (see `Attrs`):
|
||||
/// * keep_dims: If `True`, retain reduced dimensions with length `1`.
|
||||
/// * separator: The separator to use when joining.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: Has shape equal to that of the input with reduced dimensions removed or
|
||||
/// set to `1` depending on `keep_dims`.
|
||||
class ReduceJoin {
|
||||
public:
|
||||
/// Optional attribute setters for ReduceJoin
|
||||
struct Attrs {
|
||||
/// If `True`, retain reduced dimensions with length `1`.
|
||||
///
|
||||
/// Defaults to false
|
||||
TF_MUST_USE_RESULT Attrs KeepDims(bool x) {
|
||||
Attrs ret = *this;
|
||||
ret.keep_dims_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// The separator to use when joining.
|
||||
///
|
||||
/// Defaults to ""
|
||||
TF_MUST_USE_RESULT Attrs Separator(StringPiece x) {
|
||||
Attrs ret = *this;
|
||||
ret.separator_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool keep_dims_ = false;
|
||||
StringPiece separator_ = "";
|
||||
};
|
||||
ReduceJoin(const ::tensorflow::Scope& scope, ::tensorflow::Input inputs,
|
||||
::tensorflow::Input reduction_indices);
|
||||
ReduceJoin(const ::tensorflow::Scope& scope, ::tensorflow::Input inputs,
|
||||
::tensorflow::Input reduction_indices, const ReduceJoin::Attrs&
|
||||
attrs);
|
||||
operator ::tensorflow::Output() const { return output; }
|
||||
operator ::tensorflow::Input() const { return output; }
|
||||
::tensorflow::Node* node() const { return output.node(); }
|
||||
|
||||
static Attrs KeepDims(bool x) {
|
||||
return Attrs().KeepDims(x);
|
||||
}
|
||||
static Attrs Separator(StringPiece x) {
|
||||
return Attrs().Separator(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output;
|
||||
};
|
||||
|
||||
/// Check if the input matches the regex pattern.
|
||||
///
|
||||
/// The input is a string tensor of any shape. The pattern is a scalar
|
||||
/// string tensor which is applied to every element of the input tensor.
|
||||
/// The boolean values (True or False) of the output tensor indicate
|
||||
/// if the input matches the regex pattern provided.
|
||||
///
|
||||
/// The pattern follows the re2 syntax (https://github.com/google/re2/wiki/Syntax)
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * input: A string tensor of the text to be processed.
|
||||
/// * pattern: A scalar string tensor containing the regular expression to match the input.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: A bool tensor with the same shape as `input`.
|
||||
class RegexFullMatch {
|
||||
public:
|
||||
RegexFullMatch(const ::tensorflow::Scope& scope, ::tensorflow::Input input,
|
||||
::tensorflow::Input pattern);
|
||||
operator ::tensorflow::Output() const { return output; }
|
||||
operator ::tensorflow::Input() const { return output; }
|
||||
::tensorflow::Node* node() const { return output.node(); }
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output;
|
||||
};
|
||||
|
||||
/// Replaces the match of pattern in input with rewrite.
|
||||
///
|
||||
/// It follows the re2 syntax (https://github.com/google/re2/wiki/Syntax)
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * input: The text to be processed.
|
||||
/// * pattern: The regular expression to match the input.
|
||||
/// * rewrite: The rewrite to be applied to the matched expresion.
|
||||
///
|
||||
/// Optional attributes (see `Attrs`):
|
||||
/// * replace_global: If True, the replacement is global, otherwise the replacement
|
||||
/// is done only on the first match.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: The text after applying pattern and rewrite.
|
||||
class RegexReplace {
|
||||
public:
|
||||
/// Optional attribute setters for RegexReplace
|
||||
struct Attrs {
|
||||
/// If True, the replacement is global, otherwise the replacement
|
||||
/// is done only on the first match.
|
||||
///
|
||||
/// Defaults to true
|
||||
TF_MUST_USE_RESULT Attrs ReplaceGlobal(bool x) {
|
||||
Attrs ret = *this;
|
||||
ret.replace_global_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool replace_global_ = true;
|
||||
};
|
||||
RegexReplace(const ::tensorflow::Scope& scope, ::tensorflow::Input input,
|
||||
::tensorflow::Input pattern, ::tensorflow::Input rewrite);
|
||||
RegexReplace(const ::tensorflow::Scope& scope, ::tensorflow::Input input,
|
||||
::tensorflow::Input pattern, ::tensorflow::Input rewrite, const
|
||||
RegexReplace::Attrs& attrs);
|
||||
operator ::tensorflow::Output() const { return output; }
|
||||
operator ::tensorflow::Input() const { return output; }
|
||||
::tensorflow::Node* node() const { return output.node(); }
|
||||
|
||||
static Attrs ReplaceGlobal(bool x) {
|
||||
return Attrs().ReplaceGlobal(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output;
|
||||
};
|
||||
|
||||
/// Formats a string template using a list of tensors.
|
||||
///
|
||||
/// Formats a string template using a list of tensors, pretty-printing tensor summaries.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * inputs: The list of tensors to format into the placeholder string.
|
||||
///
|
||||
/// Optional attributes (see `Attrs`):
|
||||
/// * template_: A string, the template to format tensor summaries into.
|
||||
/// * placeholder: A string, at each placeholder in the template a subsequent tensor summary will be inserted.
|
||||
/// * summarize: When formatting the tensor summaries print the first and last summarize entries of each tensor dimension.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: = The resulting string scalar.
|
||||
class StringFormat {
|
||||
public:
|
||||
/// Optional attribute setters for StringFormat
|
||||
struct Attrs {
|
||||
/// A string, the template to format tensor summaries into.
|
||||
///
|
||||
/// Defaults to "%s"
|
||||
TF_MUST_USE_RESULT Attrs Template(StringPiece x) {
|
||||
Attrs ret = *this;
|
||||
ret.template_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// A string, at each placeholder in the template a subsequent tensor summary will be inserted.
|
||||
///
|
||||
/// Defaults to "%s"
|
||||
TF_MUST_USE_RESULT Attrs Placeholder(StringPiece x) {
|
||||
Attrs ret = *this;
|
||||
ret.placeholder_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// When formatting the tensor summaries print the first and last summarize entries of each tensor dimension.
|
||||
///
|
||||
/// Defaults to 3
|
||||
TF_MUST_USE_RESULT Attrs Summarize(int64 x) {
|
||||
Attrs ret = *this;
|
||||
ret.summarize_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
StringPiece template_ = "%s";
|
||||
StringPiece placeholder_ = "%s";
|
||||
int64 summarize_ = 3;
|
||||
};
|
||||
StringFormat(const ::tensorflow::Scope& scope, ::tensorflow::InputList inputs);
|
||||
StringFormat(const ::tensorflow::Scope& scope, ::tensorflow::InputList inputs,
|
||||
const StringFormat::Attrs& attrs);
|
||||
operator ::tensorflow::Output() const { return output; }
|
||||
operator ::tensorflow::Input() const { return output; }
|
||||
::tensorflow::Node* node() const { return output.node(); }
|
||||
|
||||
static Attrs Template(StringPiece x) {
|
||||
return Attrs().Template(x);
|
||||
}
|
||||
static Attrs Placeholder(StringPiece x) {
|
||||
return Attrs().Placeholder(x);
|
||||
}
|
||||
static Attrs Summarize(int64 x) {
|
||||
return Attrs().Summarize(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output;
|
||||
};
|
||||
|
||||
/// Joins the strings in the given list of string tensors into one tensor;
|
||||
///
|
||||
/// with the given separator (default is an empty separator).
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * inputs: A list of string tensors. The tensors must all have the same shape,
|
||||
/// or be scalars. Scalars may be mixed in; these will be broadcast to the shape
|
||||
/// of non-scalar inputs.
|
||||
///
|
||||
/// Optional attributes (see `Attrs`):
|
||||
/// * separator: string, an optional join separator.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: The output tensor.
|
||||
class StringJoin {
|
||||
public:
|
||||
/// Optional attribute setters for StringJoin
|
||||
struct Attrs {
|
||||
/// string, an optional join separator.
|
||||
///
|
||||
/// Defaults to ""
|
||||
TF_MUST_USE_RESULT Attrs Separator(StringPiece x) {
|
||||
Attrs ret = *this;
|
||||
ret.separator_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
StringPiece separator_ = "";
|
||||
};
|
||||
StringJoin(const ::tensorflow::Scope& scope, ::tensorflow::InputList inputs);
|
||||
StringJoin(const ::tensorflow::Scope& scope, ::tensorflow::InputList inputs,
|
||||
const StringJoin::Attrs& attrs);
|
||||
operator ::tensorflow::Output() const { return output; }
|
||||
operator ::tensorflow::Input() const { return output; }
|
||||
::tensorflow::Node* node() const { return output.node(); }
|
||||
|
||||
static Attrs Separator(StringPiece x) {
|
||||
return Attrs().Separator(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output;
|
||||
};
|
||||
|
||||
/// String lengths of `input`.
|
||||
///
|
||||
/// Computes the length of each string given in the input tensor.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * input: The string for which to compute the length.
|
||||
///
|
||||
/// Optional attributes (see `Attrs`):
|
||||
/// * unit: The unit that is counted to compute string length. One of: `"BYTE"` (for
|
||||
/// the number of bytes in each string) or `"UTF8_CHAR"` (for the number of UTF-8
|
||||
/// encoded Unicode code points in each string). Results are undefined
|
||||
/// if `unit=UTF8_CHAR` and the `input` strings do not contain structurally
|
||||
/// valid UTF-8.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: Integer tensor that has the same shape as `input`. The output contains the
|
||||
/// element-wise string lengths of `input`.
|
||||
class StringLength {
|
||||
public:
|
||||
/// Optional attribute setters for StringLength
|
||||
struct Attrs {
|
||||
/// The unit that is counted to compute string length. One of: `"BYTE"` (for
|
||||
/// the number of bytes in each string) or `"UTF8_CHAR"` (for the number of UTF-8
|
||||
/// encoded Unicode code points in each string). Results are undefined
|
||||
/// if `unit=UTF8_CHAR` and the `input` strings do not contain structurally
|
||||
/// valid UTF-8.
|
||||
///
|
||||
/// Defaults to "BYTE"
|
||||
TF_MUST_USE_RESULT Attrs Unit(StringPiece x) {
|
||||
Attrs ret = *this;
|
||||
ret.unit_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
StringPiece unit_ = "BYTE";
|
||||
};
|
||||
StringLength(const ::tensorflow::Scope& scope, ::tensorflow::Input input);
|
||||
StringLength(const ::tensorflow::Scope& scope, ::tensorflow::Input input, const
|
||||
StringLength::Attrs& attrs);
|
||||
operator ::tensorflow::Output() const { return output; }
|
||||
operator ::tensorflow::Input() const { return output; }
|
||||
::tensorflow::Node* node() const { return output.node(); }
|
||||
|
||||
static Attrs Unit(StringPiece x) {
|
||||
return Attrs().Unit(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output;
|
||||
};
|
||||
|
||||
/// Split elements of `input` based on `delimiter` into a `SparseTensor`.
|
||||
///
|
||||
/// Let N be the size of source (typically N will be the batch size). Split each
|
||||
/// element of `input` based on `delimiter` and return a `SparseTensor`
|
||||
/// containing the splitted tokens. Empty tokens are ignored.
|
||||
///
|
||||
/// `delimiter` can be empty, or a string of split characters. If `delimiter` is an
|
||||
/// empty string, each element of `input` is split into individual single-byte
|
||||
/// character strings, including splitting of UTF-8 multibyte sequences. Otherwise
|
||||
/// every character of `delimiter` is a potential split point.
|
||||
///
|
||||
/// For example:
|
||||
/// N = 2, input[0] is 'hello world' and input[1] is 'a b c', then the output
|
||||
/// will be
|
||||
///
|
||||
/// indices = [0, 0;
|
||||
/// 0, 1;
|
||||
/// 1, 0;
|
||||
/// 1, 1;
|
||||
/// 1, 2]
|
||||
/// shape = [2, 3]
|
||||
/// values = ['hello', 'world', 'a', 'b', 'c']
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * input: 1-D. Strings to split.
|
||||
/// * delimiter: 0-D. Delimiter characters (bytes), or empty string.
|
||||
///
|
||||
/// Optional attributes (see `Attrs`):
|
||||
/// * skip_empty: A `bool`. If `True`, skip the empty strings from the result.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output` indices: A dense matrix of int64 representing the indices of the sparse tensor.
|
||||
/// * `Output` values: A vector of strings corresponding to the splited values.
|
||||
/// * `Output` shape: a length-2 vector of int64 representing the shape of the sparse
|
||||
/// tensor, where the first value is N and the second value is the maximum number
|
||||
/// of tokens in a single input entry.
|
||||
class StringSplit {
|
||||
public:
|
||||
/// Optional attribute setters for StringSplit
|
||||
struct Attrs {
|
||||
/// A `bool`. If `True`, skip the empty strings from the result.
|
||||
///
|
||||
/// Defaults to true
|
||||
TF_MUST_USE_RESULT Attrs SkipEmpty(bool x) {
|
||||
Attrs ret = *this;
|
||||
ret.skip_empty_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool skip_empty_ = true;
|
||||
};
|
||||
StringSplit(const ::tensorflow::Scope& scope, ::tensorflow::Input input,
|
||||
::tensorflow::Input delimiter);
|
||||
StringSplit(const ::tensorflow::Scope& scope, ::tensorflow::Input input,
|
||||
::tensorflow::Input delimiter, const StringSplit::Attrs& attrs);
|
||||
|
||||
static Attrs SkipEmpty(bool x) {
|
||||
return Attrs().SkipEmpty(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output indices;
|
||||
::tensorflow::Output values;
|
||||
::tensorflow::Output shape;
|
||||
};
|
||||
|
||||
/// Split elements of `source` based on `sep` into a `SparseTensor`.
|
||||
///
|
||||
/// Let N be the size of source (typically N will be the batch size). Split each
|
||||
/// element of `source` based on `sep` and return a `SparseTensor`
|
||||
/// containing the split tokens. Empty tokens are ignored.
|
||||
///
|
||||
/// For example, N = 2, source[0] is 'hello world' and source[1] is 'a b c',
|
||||
/// then the output will be
|
||||
/// ```
|
||||
/// st.indices = [0, 0;
|
||||
/// 0, 1;
|
||||
/// 1, 0;
|
||||
/// 1, 1;
|
||||
/// 1, 2]
|
||||
/// st.shape = [2, 3]
|
||||
/// st.values = ['hello', 'world', 'a', 'b', 'c']
|
||||
/// ```
|
||||
///
|
||||
/// If `sep` is given, consecutive delimiters are not grouped together and are
|
||||
/// deemed to delimit empty strings. For example, source of `"1<>2<><>3"` and
|
||||
/// sep of `"<>"` returns `["1", "2", "", "3"]`. If `sep` is None or an empty
|
||||
/// string, consecutive whitespace are regarded as a single separator, and the
|
||||
/// result will contain no empty strings at the startor end if the string has
|
||||
/// leading or trailing whitespace.
|
||||
///
|
||||
/// Note that the above mentioned behavior matches python's str.split.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * input: `1-D` string `Tensor`, the strings to split.
|
||||
/// * sep: `0-D` string `Tensor`, the delimiter character.
|
||||
///
|
||||
/// Optional attributes (see `Attrs`):
|
||||
/// * maxsplit: An `int`. If `maxsplit > 0`, limit of the split of the result.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output` indices
|
||||
/// * `Output` values
|
||||
/// * `Output` shape
|
||||
class StringSplitV2 {
|
||||
public:
|
||||
/// Optional attribute setters for StringSplitV2
|
||||
struct Attrs {
|
||||
/// An `int`. If `maxsplit > 0`, limit of the split of the result.
|
||||
///
|
||||
/// Defaults to -1
|
||||
TF_MUST_USE_RESULT Attrs Maxsplit(int64 x) {
|
||||
Attrs ret = *this;
|
||||
ret.maxsplit_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int64 maxsplit_ = -1;
|
||||
};
|
||||
StringSplitV2(const ::tensorflow::Scope& scope, ::tensorflow::Input input,
|
||||
::tensorflow::Input sep);
|
||||
StringSplitV2(const ::tensorflow::Scope& scope, ::tensorflow::Input input,
|
||||
::tensorflow::Input sep, const StringSplitV2::Attrs& attrs);
|
||||
|
||||
static Attrs Maxsplit(int64 x) {
|
||||
return Attrs().Maxsplit(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output indices;
|
||||
::tensorflow::Output values;
|
||||
::tensorflow::Output shape;
|
||||
};
|
||||
|
||||
/// Strip leading and trailing whitespaces from the Tensor.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * input: A string `Tensor` of any shape.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: A string `Tensor` of the same shape as the input.
|
||||
class StringStrip {
|
||||
public:
|
||||
StringStrip(const ::tensorflow::Scope& scope, ::tensorflow::Input input);
|
||||
operator ::tensorflow::Output() const { return output; }
|
||||
operator ::tensorflow::Input() const { return output; }
|
||||
::tensorflow::Node* node() const { return output.node(); }
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output;
|
||||
};
|
||||
|
||||
/// Converts each string in the input Tensor to its hash mod by a number of buckets.
|
||||
///
|
||||
/// The hash function is deterministic on the content of the string within the
|
||||
/// process.
|
||||
///
|
||||
/// Note that the hash function may change from time to time.
|
||||
/// This functionality will be deprecated and it's recommended to use
|
||||
/// `tf.string_to_hash_bucket_fast()` or `tf.string_to_hash_bucket_strong()`.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * num_buckets: The number of buckets.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: A Tensor of the same shape as the input `string_tensor`.
|
||||
class StringToHashBucket {
|
||||
public:
|
||||
StringToHashBucket(const ::tensorflow::Scope& scope, ::tensorflow::Input
|
||||
string_tensor, int64 num_buckets);
|
||||
operator ::tensorflow::Output() const { return output; }
|
||||
operator ::tensorflow::Input() const { return output; }
|
||||
::tensorflow::Node* node() const { return output.node(); }
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output;
|
||||
};
|
||||
|
||||
/// Converts each string in the input Tensor to its hash mod by a number of buckets.
|
||||
///
|
||||
/// The hash function is deterministic on the content of the string within the
|
||||
/// process and will never change. However, it is not suitable for cryptography.
|
||||
/// This function may be used when CPU time is scarce and inputs are trusted or
|
||||
/// unimportant. There is a risk of adversaries constructing inputs that all hash
|
||||
/// to the same bucket. To prevent this problem, use a strong hash function with
|
||||
/// `tf.string_to_hash_bucket_strong`.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * input: The strings to assign a hash bucket.
|
||||
/// * num_buckets: The number of buckets.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: A Tensor of the same shape as the input `string_tensor`.
|
||||
class StringToHashBucketFast {
|
||||
public:
|
||||
StringToHashBucketFast(const ::tensorflow::Scope& scope, ::tensorflow::Input
|
||||
input, int64 num_buckets);
|
||||
operator ::tensorflow::Output() const { return output; }
|
||||
operator ::tensorflow::Input() const { return output; }
|
||||
::tensorflow::Node* node() const { return output.node(); }
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output;
|
||||
};
|
||||
|
||||
/// Converts each string in the input Tensor to its hash mod by a number of buckets.
|
||||
///
|
||||
/// The hash function is deterministic on the content of the string within the
|
||||
/// process. The hash function is a keyed hash function, where attribute `key`
|
||||
/// defines the key of the hash function. `key` is an array of 2 elements.
|
||||
///
|
||||
/// A strong hash is important when inputs may be malicious, e.g. URLs with
|
||||
/// additional components. Adversaries could try to make their inputs hash to the
|
||||
/// same bucket for a denial-of-service attack or to skew the results. A strong
|
||||
/// hash prevents this by making it difficult, if not infeasible, to compute inputs
|
||||
/// that hash to the same bucket. This comes at a cost of roughly 4x higher compute
|
||||
/// time than `tf.string_to_hash_bucket_fast`.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * input: The strings to assign a hash bucket.
|
||||
/// * num_buckets: The number of buckets.
|
||||
/// * key: The key for the keyed hash function passed as a list of two uint64
|
||||
/// elements.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: A Tensor of the same shape as the input `string_tensor`.
|
||||
class StringToHashBucketStrong {
|
||||
public:
|
||||
StringToHashBucketStrong(const ::tensorflow::Scope& scope, ::tensorflow::Input
|
||||
input, int64 num_buckets, const gtl::ArraySlice<int>&
|
||||
key);
|
||||
operator ::tensorflow::Output() const { return output; }
|
||||
operator ::tensorflow::Input() const { return output; }
|
||||
::tensorflow::Node* node() const { return output.node(); }
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output;
|
||||
};
|
||||
|
||||
/// Return substrings from `Tensor` of strings.
|
||||
///
|
||||
/// For each string in the input `Tensor`, creates a substring starting at index
|
||||
/// `pos` with a total length of `len`.
|
||||
///
|
||||
/// If `len` defines a substring that would extend beyond the length of the input
|
||||
/// string, then as many characters as possible are used.
|
||||
///
|
||||
/// A negative `pos` indicates distance within the string backwards from the end.
|
||||
///
|
||||
/// If `pos` specifies an index which is out of range for any of the input strings,
|
||||
/// then an `InvalidArgumentError` is thrown.
|
||||
///
|
||||
/// `pos` and `len` must have the same shape, otherwise a `ValueError` is thrown on
|
||||
/// Op creation.
|
||||
///
|
||||
/// *NOTE*: `Substr` supports broadcasting up to two dimensions. More about
|
||||
/// broadcasting
|
||||
/// [here](http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html)
|
||||
///
|
||||
/// ---
|
||||
///
|
||||
/// Examples
|
||||
///
|
||||
/// Using scalar `pos` and `len`:
|
||||
///
|
||||
/// ```python
|
||||
/// input = [b'Hello', b'World']
|
||||
/// position = 1
|
||||
/// length = 3
|
||||
///
|
||||
/// output = [b'ell', b'orl']
|
||||
/// ```
|
||||
///
|
||||
/// Using `pos` and `len` with same shape as `input`:
|
||||
///
|
||||
/// ```python
|
||||
/// input = [[b'ten', b'eleven', b'twelve'],
|
||||
/// [b'thirteen', b'fourteen', b'fifteen'],
|
||||
/// [b'sixteen', b'seventeen', b'eighteen']]
|
||||
/// position = [[1, 2, 3],
|
||||
/// [1, 2, 3],
|
||||
/// [1, 2, 3]]
|
||||
/// length = [[2, 3, 4],
|
||||
/// [4, 3, 2],
|
||||
/// [5, 5, 5]]
|
||||
///
|
||||
/// output = [[b'en', b'eve', b'lve'],
|
||||
/// [b'hirt', b'urt', b'te'],
|
||||
/// [b'ixtee', b'vente', b'hteen']]
|
||||
/// ```
|
||||
///
|
||||
/// Broadcasting `pos` and `len` onto `input`:
|
||||
///
|
||||
/// ```
|
||||
/// input = [[b'ten', b'eleven', b'twelve'],
|
||||
/// [b'thirteen', b'fourteen', b'fifteen'],
|
||||
/// [b'sixteen', b'seventeen', b'eighteen'],
|
||||
/// [b'nineteen', b'twenty', b'twentyone']]
|
||||
/// position = [1, 2, 3]
|
||||
/// length = [1, 2, 3]
|
||||
///
|
||||
/// output = [[b'e', b'ev', b'lve'],
|
||||
/// [b'h', b'ur', b'tee'],
|
||||
/// [b'i', b've', b'hte'],
|
||||
/// [b'i', b'en', b'nty']]
|
||||
/// ```
|
||||
///
|
||||
/// Broadcasting `input` onto `pos` and `len`:
|
||||
///
|
||||
/// ```
|
||||
/// input = b'thirteen'
|
||||
/// position = [1, 5, 7]
|
||||
/// length = [3, 2, 1]
|
||||
///
|
||||
/// output = [b'hir', b'ee', b'n']
|
||||
/// ```
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * input: Tensor of strings
|
||||
/// * pos: Scalar defining the position of first character in each substring
|
||||
/// * len: Scalar defining the number of characters to include in each substring
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: Tensor of substrings
|
||||
class Substr {
|
||||
public:
|
||||
Substr(const ::tensorflow::Scope& scope, ::tensorflow::Input input,
|
||||
::tensorflow::Input pos, ::tensorflow::Input len);
|
||||
operator ::tensorflow::Output() const { return output; }
|
||||
operator ::tensorflow::Input() const { return output; }
|
||||
::tensorflow::Node* node() const { return output.node(); }
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output;
|
||||
};
|
||||
|
||||
/// Determine the script codes of a given tensor of Unicode integer code points.
|
||||
///
|
||||
/// This operation converts Unicode code points to script codes corresponding to
|
||||
/// each code point. Script codes correspond to International Components for
|
||||
/// Unicode (ICU) UScriptCode values. See http://icu-project.org/apiref/icu4c/uscript_8h.html.
|
||||
/// Returns -1 (USCRIPT_INVALID_CODE) for invalid codepoints. Output shape will
|
||||
/// match input shape.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * input: A Tensor of int32 Unicode code points.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: A Tensor of int32 script codes corresponding to each input code point.
|
||||
class UnicodeScript {
|
||||
public:
|
||||
UnicodeScript(const ::tensorflow::Scope& scope, ::tensorflow::Input input);
|
||||
operator ::tensorflow::Output() const { return output; }
|
||||
operator ::tensorflow::Input() const { return output; }
|
||||
::tensorflow::Node* node() const { return output.node(); }
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output;
|
||||
};
|
||||
|
||||
/// @}
|
||||
|
||||
} // namespace ops
|
||||
} // namespace tensorflow
|
||||
|
||||
#endif // TENSORFLOW_CC_OPS_STRING_OPS_H_
|
||||
@@ -0,0 +1,105 @@
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#ifndef TENSORFLOW_CC_OPS_STRING_OPS_INTERNAL_H_
|
||||
#define TENSORFLOW_CC_OPS_STRING_OPS_INTERNAL_H_
|
||||
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#include "tensorflow/cc/framework/ops.h"
|
||||
#include "tensorflow/cc/framework/scope.h"
|
||||
#include "tensorflow/core/framework/tensor.h"
|
||||
#include "tensorflow/core/framework/tensor_shape.h"
|
||||
#include "tensorflow/core/framework/types.h"
|
||||
#include "tensorflow/core/lib/gtl/array_slice.h"
|
||||
|
||||
namespace tensorflow {
|
||||
namespace ops {
|
||||
namespace internal {
|
||||
// NOTE: This namespace has internal TensorFlow details that
|
||||
// are not part of TensorFlow's public API.
|
||||
|
||||
/// @defgroup string_ops_internal String Ops Internal
|
||||
/// @{
|
||||
|
||||
/// Check if the input matches the regex pattern.
|
||||
///
|
||||
/// The input is a string tensor of any shape. The pattern is the
|
||||
/// regular expression to be matched with every element of the input tensor.
|
||||
/// The boolean values (True or False) of the output tensor indicate
|
||||
/// if the input matches the regex pattern provided.
|
||||
///
|
||||
/// The pattern follows the re2 syntax (https://github.com/google/re2/wiki/Syntax)
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * input: A string tensor of the text to be processed.
|
||||
/// * pattern: The regular expression to match the input.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: A bool tensor with the same shape as `input`.
|
||||
class StaticRegexFullMatch {
|
||||
public:
|
||||
StaticRegexFullMatch(const ::tensorflow::Scope& scope, ::tensorflow::Input
|
||||
input, StringPiece pattern);
|
||||
operator ::tensorflow::Output() const { return output; }
|
||||
operator ::tensorflow::Input() const { return output; }
|
||||
::tensorflow::Node* node() const { return output.node(); }
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output;
|
||||
};
|
||||
|
||||
/// Replaces the match of pattern in input with rewrite.
|
||||
///
|
||||
/// It follows the re2 syntax (https://github.com/google/re2/wiki/Syntax)
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * input: The text to be processed.
|
||||
/// * pattern: The regular expression to match the input.
|
||||
/// * rewrite: The rewrite to be applied to the matched expresion.
|
||||
///
|
||||
/// Optional attributes (see `Attrs`):
|
||||
/// * replace_global: If True, the replacement is global, otherwise the replacement
|
||||
/// is done only on the first match.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: The text after applying pattern and rewrite.
|
||||
class StaticRegexReplace {
|
||||
public:
|
||||
/// Optional attribute setters for StaticRegexReplace
|
||||
struct Attrs {
|
||||
/// If True, the replacement is global, otherwise the replacement
|
||||
/// is done only on the first match.
|
||||
///
|
||||
/// Defaults to true
|
||||
TF_MUST_USE_RESULT Attrs ReplaceGlobal(bool x) {
|
||||
Attrs ret = *this;
|
||||
ret.replace_global_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool replace_global_ = true;
|
||||
};
|
||||
StaticRegexReplace(const ::tensorflow::Scope& scope, ::tensorflow::Input input,
|
||||
StringPiece pattern, StringPiece rewrite);
|
||||
StaticRegexReplace(const ::tensorflow::Scope& scope, ::tensorflow::Input input,
|
||||
StringPiece pattern, StringPiece rewrite, const
|
||||
StaticRegexReplace::Attrs& attrs);
|
||||
operator ::tensorflow::Output() const { return output; }
|
||||
operator ::tensorflow::Input() const { return output; }
|
||||
::tensorflow::Node* node() const { return output.node(); }
|
||||
|
||||
static Attrs ReplaceGlobal(bool x) {
|
||||
return Attrs().ReplaceGlobal(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output output;
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
} // namespace ops
|
||||
} // namespace tensorflow
|
||||
|
||||
#endif // TENSORFLOW_CC_OPS_STRING_OPS_INTERNAL_H_
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,154 @@
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#ifndef TENSORFLOW_CC_OPS_TRAINING_OPS_INTERNAL_H_
|
||||
#define TENSORFLOW_CC_OPS_TRAINING_OPS_INTERNAL_H_
|
||||
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#include "tensorflow/cc/framework/ops.h"
|
||||
#include "tensorflow/cc/framework/scope.h"
|
||||
#include "tensorflow/core/framework/tensor.h"
|
||||
#include "tensorflow/core/framework/tensor_shape.h"
|
||||
#include "tensorflow/core/framework/types.h"
|
||||
#include "tensorflow/core/lib/gtl/array_slice.h"
|
||||
|
||||
namespace tensorflow {
|
||||
namespace ops {
|
||||
namespace internal {
|
||||
// NOTE: This namespace has internal TensorFlow details that
|
||||
// are not part of TensorFlow's public API.
|
||||
|
||||
/// @defgroup training_ops_internal Training Ops Internal
|
||||
/// @{
|
||||
|
||||
/// Update '*var' according to the AdaMax algorithm.
|
||||
///
|
||||
/// m_t <- beta1 * m_{t-1} + (1 - beta1) * g
|
||||
/// v_t <- max(beta2 * v_{t-1}, abs(g))
|
||||
/// variable <- variable - learning_rate / (1 - beta1^t) * m_t / (v_t + epsilon)
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * var: Should be from a Variable().
|
||||
/// * m: Should be from a Variable().
|
||||
/// * v: Should be from a Variable().
|
||||
/// * beta1_power: Must be a scalar.
|
||||
/// * lr: Scaling factor. Must be a scalar.
|
||||
/// * beta1: Momentum factor. Must be a scalar.
|
||||
/// * beta2: Momentum factor. Must be a scalar.
|
||||
/// * epsilon: Ridge term. Must be a scalar.
|
||||
/// * grad: The gradient.
|
||||
///
|
||||
/// Optional attributes (see `Attrs`):
|
||||
/// * use_locking: If `True`, updating of the var, m, and v tensors will be protected
|
||||
/// by a lock; otherwise the behavior is undefined, but may exhibit less
|
||||
/// contention.
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: Same as "var".
|
||||
class ApplyAdaMax {
|
||||
public:
|
||||
/// Optional attribute setters for ApplyAdaMax
|
||||
struct Attrs {
|
||||
/// If `True`, updating of the var, m, and v tensors will be protected
|
||||
/// by a lock; otherwise the behavior is undefined, but may exhibit less
|
||||
/// contention.
|
||||
///
|
||||
/// Defaults to false
|
||||
TF_MUST_USE_RESULT Attrs UseLocking(bool x) {
|
||||
Attrs ret = *this;
|
||||
ret.use_locking_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool use_locking_ = false;
|
||||
};
|
||||
ApplyAdaMax(const ::tensorflow::Scope& scope, ::tensorflow::Input var,
|
||||
::tensorflow::Input m, ::tensorflow::Input v, ::tensorflow::Input
|
||||
beta1_power, ::tensorflow::Input lr, ::tensorflow::Input beta1,
|
||||
::tensorflow::Input beta2, ::tensorflow::Input epsilon,
|
||||
::tensorflow::Input grad);
|
||||
ApplyAdaMax(const ::tensorflow::Scope& scope, ::tensorflow::Input var,
|
||||
::tensorflow::Input m, ::tensorflow::Input v, ::tensorflow::Input
|
||||
beta1_power, ::tensorflow::Input lr, ::tensorflow::Input beta1,
|
||||
::tensorflow::Input beta2, ::tensorflow::Input epsilon,
|
||||
::tensorflow::Input grad, const ApplyAdaMax::Attrs& attrs);
|
||||
operator ::tensorflow::Output() const { return out; }
|
||||
operator ::tensorflow::Input() const { return out; }
|
||||
::tensorflow::Node* node() const { return out.node(); }
|
||||
|
||||
static Attrs UseLocking(bool x) {
|
||||
return Attrs().UseLocking(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output out;
|
||||
};
|
||||
|
||||
/// Update '*var' according to the AdaMax algorithm.
|
||||
///
|
||||
/// m_t <- beta1 * m_{t-1} + (1 - beta1) * g
|
||||
/// v_t <- max(beta2 * v_{t-1}, abs(g))
|
||||
/// variable <- variable - learning_rate / (1 - beta1^t) * m_t / (v_t + epsilon)
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
/// * var: Should be from a Variable().
|
||||
/// * m: Should be from a Variable().
|
||||
/// * v: Should be from a Variable().
|
||||
/// * beta1_power: Must be a scalar.
|
||||
/// * lr: Scaling factor. Must be a scalar.
|
||||
/// * beta1: Momentum factor. Must be a scalar.
|
||||
/// * beta2: Momentum factor. Must be a scalar.
|
||||
/// * epsilon: Ridge term. Must be a scalar.
|
||||
/// * grad: The gradient.
|
||||
///
|
||||
/// Optional attributes (see `Attrs`):
|
||||
/// * use_locking: If `True`, updating of the var, m, and v tensors will be protected
|
||||
/// by a lock; otherwise the behavior is undefined, but may exhibit less
|
||||
/// contention.
|
||||
///
|
||||
/// Returns:
|
||||
/// * the created `Operation`
|
||||
class ResourceApplyAdaMax {
|
||||
public:
|
||||
/// Optional attribute setters for ResourceApplyAdaMax
|
||||
struct Attrs {
|
||||
/// If `True`, updating of the var, m, and v tensors will be protected
|
||||
/// by a lock; otherwise the behavior is undefined, but may exhibit less
|
||||
/// contention.
|
||||
///
|
||||
/// Defaults to false
|
||||
TF_MUST_USE_RESULT Attrs UseLocking(bool x) {
|
||||
Attrs ret = *this;
|
||||
ret.use_locking_ = x;
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool use_locking_ = false;
|
||||
};
|
||||
ResourceApplyAdaMax(const ::tensorflow::Scope& scope, ::tensorflow::Input var,
|
||||
::tensorflow::Input m, ::tensorflow::Input v,
|
||||
::tensorflow::Input beta1_power, ::tensorflow::Input lr,
|
||||
::tensorflow::Input beta1, ::tensorflow::Input beta2,
|
||||
::tensorflow::Input epsilon, ::tensorflow::Input grad);
|
||||
ResourceApplyAdaMax(const ::tensorflow::Scope& scope, ::tensorflow::Input var,
|
||||
::tensorflow::Input m, ::tensorflow::Input v,
|
||||
::tensorflow::Input beta1_power, ::tensorflow::Input lr,
|
||||
::tensorflow::Input beta1, ::tensorflow::Input beta2,
|
||||
::tensorflow::Input epsilon, ::tensorflow::Input grad,
|
||||
const ResourceApplyAdaMax::Attrs& attrs);
|
||||
operator ::tensorflow::Operation() const { return operation; }
|
||||
|
||||
static Attrs UseLocking(bool x) {
|
||||
return Attrs().UseLocking(x);
|
||||
}
|
||||
|
||||
Operation operation;
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
} // namespace ops
|
||||
} // namespace tensorflow
|
||||
|
||||
#endif // TENSORFLOW_CC_OPS_TRAINING_OPS_INTERNAL_H_
|
||||
@@ -0,0 +1,44 @@
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#ifndef TENSORFLOW_CC_OPS_USER_OPS_H_
|
||||
#define TENSORFLOW_CC_OPS_USER_OPS_H_
|
||||
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#include "tensorflow/cc/framework/ops.h"
|
||||
#include "tensorflow/cc/framework/scope.h"
|
||||
#include "tensorflow/core/framework/tensor.h"
|
||||
#include "tensorflow/core/framework/tensor_shape.h"
|
||||
#include "tensorflow/core/framework/types.h"
|
||||
#include "tensorflow/core/lib/gtl/array_slice.h"
|
||||
|
||||
namespace tensorflow {
|
||||
namespace ops {
|
||||
|
||||
/// @defgroup user_ops User Ops
|
||||
/// @{
|
||||
|
||||
/// Output a fact about factorials.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * scope: A Scope object
|
||||
///
|
||||
/// Returns:
|
||||
/// * `Output`: The fact tensor.
|
||||
class Fact {
|
||||
public:
|
||||
Fact(const ::tensorflow::Scope& scope);
|
||||
operator ::tensorflow::Output() const { return fact; }
|
||||
operator ::tensorflow::Input() const { return fact; }
|
||||
::tensorflow::Node* node() const { return fact.node(); }
|
||||
|
||||
Operation operation;
|
||||
::tensorflow::Output fact;
|
||||
};
|
||||
|
||||
/// @}
|
||||
|
||||
} // namespace ops
|
||||
} // namespace tensorflow
|
||||
|
||||
#endif // TENSORFLOW_CC_OPS_USER_OPS_H_
|
||||
@@ -0,0 +1,28 @@
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#ifndef TENSORFLOW_CC_OPS_USER_OPS_INTERNAL_H_
|
||||
#define TENSORFLOW_CC_OPS_USER_OPS_INTERNAL_H_
|
||||
|
||||
// This file is MACHINE GENERATED! Do not edit.
|
||||
|
||||
#include "tensorflow/cc/framework/ops.h"
|
||||
#include "tensorflow/cc/framework/scope.h"
|
||||
#include "tensorflow/core/framework/tensor.h"
|
||||
#include "tensorflow/core/framework/tensor_shape.h"
|
||||
#include "tensorflow/core/framework/types.h"
|
||||
#include "tensorflow/core/lib/gtl/array_slice.h"
|
||||
|
||||
namespace tensorflow {
|
||||
namespace ops {
|
||||
namespace internal {
|
||||
// NOTE: This namespace has internal TensorFlow details that
|
||||
// are not part of TensorFlow's public API.
|
||||
|
||||
/// @defgroup user_ops_internal User Ops Internal
|
||||
/// @{
|
||||
|
||||
} // namespace internal
|
||||
} // namespace ops
|
||||
} // namespace tensorflow
|
||||
|
||||
#endif // TENSORFLOW_CC_OPS_USER_OPS_INTERNAL_H_
|
||||
@@ -0,0 +1,74 @@
|
||||
/* Copyright 2017 The TensorFlow Authors. All Rights Reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==============================================================================*/
|
||||
|
||||
#ifndef TENSORFLOW_CC_OPS_WHILE_LOOP_H_
|
||||
#define TENSORFLOW_CC_OPS_WHILE_LOOP_H_
|
||||
|
||||
#include "tensorflow/cc/framework/ops.h"
|
||||
#include "tensorflow/cc/framework/scope.h"
|
||||
|
||||
namespace tensorflow {
|
||||
namespace ops {
|
||||
|
||||
// Function that takes cond graph inputs and returns cond graph boolean output.
|
||||
// 'output' need not be set if an error is returned.
|
||||
typedef std::function<Status(const Scope&, const std::vector<Output>& inputs,
|
||||
Output* output)>
|
||||
CondGraphBuilderFn;
|
||||
|
||||
// Function that takes body graph inputs and returns body graph outputs.
|
||||
// 'outputs' need not be populated if an error is returned.
|
||||
typedef std::function<Status(const Scope&, const std::vector<Output>& inputs,
|
||||
std::vector<Output>* outputs)>
|
||||
BodyGraphBuilderFn;
|
||||
|
||||
// Constructs a while loop.
|
||||
//
|
||||
// Arguments:
|
||||
// * scope: used to construct the while loop.
|
||||
// * inputs: the initial values of the loop variables. Must be non-empty.
|
||||
// * cond: a function that builds the condition graph of the loop. Takes the
|
||||
// current loop variables as inputs and returns a scalar boolean Output
|
||||
// indicating whether the loop should continue.
|
||||
// * body: a function that builds the body graph of the loop. Takes the current
|
||||
// loop variables as inputs and returns the updated loop variables.
|
||||
// * frame_name: the frame name to use for this while loop. This should be a
|
||||
// unique name. This will be used as a prefix for created operations.
|
||||
// * outputs: output param that returns final loop variable outputs in non-error
|
||||
// case. Must be non-null and empty.
|
||||
// * create_while_ctx: if true, a WhileContext is created and populated for this
|
||||
// loop. See core/graph/while_context.h for more details on
|
||||
// WhileContexts. This is set to false for loops used as part of gradient
|
||||
// computations, since they're part of the gradient for a loop in the
|
||||
// forward-pass.
|
||||
// TODO(skyewm): revisit this. Should we create WhileContexts for all loops,
|
||||
// even if we don't need them?
|
||||
// * cond_output: if non-null, the output of the predicate is returned. This
|
||||
// will always be a LoopCond node.
|
||||
//
|
||||
// Returns an error if the while loop could not be fully constructed.
|
||||
//
|
||||
// TODO(skyewm): clean up partially-constructed loop in error case
|
||||
// TODO(skyewm): create public interface to this method
|
||||
Status BuildWhileLoop(const Scope& scope, const std::vector<Output>& inputs,
|
||||
const CondGraphBuilderFn& cond,
|
||||
const BodyGraphBuilderFn& body, const string& frame_name,
|
||||
OutputList* outputs, bool create_while_ctx = true,
|
||||
Output* cond_output = nullptr);
|
||||
|
||||
} // namespace ops
|
||||
} // namespace tensorflow
|
||||
|
||||
#endif // TENSORFLOW_CC_OPS_WHILE_LOOP_H_
|
||||
@@ -0,0 +1,97 @@
|
||||
/* Copyright 2017 The TensorFlow Authors. All Rights Reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==============================================================================*/
|
||||
|
||||
#ifndef TENSORFLOW_CC_PROFILER_PROFILER_H_
|
||||
#define TENSORFLOW_CC_PROFILER_PROFILER_H_
|
||||
|
||||
#include "tensorflow/core/framework/graph.pb.h"
|
||||
#include "tensorflow/core/lib/core/status.h"
|
||||
#include "tensorflow/core/profiler/internal/tfprof_stats.h"
|
||||
#include "tensorflow/core/profiler/tfprof_options.h"
|
||||
#include "tensorflow/core/profiler/tfprof_output.pb.h"
|
||||
|
||||
namespace tensorflow {
|
||||
namespace tfprof {
|
||||
|
||||
/// @addtogroup core
|
||||
/// @{
|
||||
|
||||
/// A `Profiler` object lets the caller profile the execution of a graph.
|
||||
///
|
||||
/// Example:
|
||||
/// // First build a graph and run tracing.
|
||||
/// Scope root = Scope::NewRootScope();
|
||||
/// auto a = Placeholder(root, DT_INT32);
|
||||
/// auto c = Add(root, a, {41});
|
||||
///
|
||||
/// ClientSession session(root);
|
||||
/// std::vector<Tensor> outputs;
|
||||
/// RunOptions run_options;
|
||||
/// run_options.set_trace_level(RunOptions::FULL_TRACE);
|
||||
/// RunMetadata run_meta;
|
||||
/// Status s = session.Run(run_options, { {a, {1}} }, {c}, &outputs,
|
||||
/// &run_meta);
|
||||
/// if (!s.ok()) { ... }
|
||||
///
|
||||
/// // Then create profiler to do profiling.
|
||||
/// GraphDef graph;
|
||||
/// root.ToGraphDef(&graph);
|
||||
/// Profiler profiler(graph);
|
||||
/// profiler.AddStep(0, run_meta);
|
||||
/// Options opts = ... // TODO(xpan): Support option building API.
|
||||
/// MultiGraphNodeProto r = profiler.ProfileOperations(opts);
|
||||
///
|
||||
class Profiler {
|
||||
public:
|
||||
/// `graph` is the model's GraphDef.
|
||||
Profiler(const GraphDef& graph);
|
||||
|
||||
/// Adds tracing information `run_meta` to profiler. A `run_meta` is
|
||||
/// generated by a TensorFlow session run call. `step` is the key
|
||||
/// to the `run_meta`. When calling ProfileXXX methods, caller can specify
|
||||
/// `step` in `options` to selectively profile the corresponding `run_meta`.
|
||||
/// Multiple different `run_meta` can be keyed by the same `step` in order
|
||||
/// to group them together.
|
||||
void AddStep(int64 step, const RunMetadata& run_meta);
|
||||
|
||||
/// Profiles the model by organizing nodes in graph structure.
|
||||
/// Each node is an op and the nodes are connected by the op inputs/outputs.
|
||||
GraphNodeProto ProfileGraph(const Options& options);
|
||||
|
||||
/// Profiles the model by organizing nodes in name scope structure.
|
||||
/// Each node is an op, and nodes are organized by the ops' name
|
||||
/// scope, similar to a file system tree.
|
||||
/// E.g. /foo is the root of operation /foo/matmul_1 and foo/conv_2.
|
||||
GraphNodeProto ProfileNameScope(const Options& options);
|
||||
|
||||
/// Profiles the model by organizing nodes by operation types.
|
||||
/// Each node is an operation type (e.g. Conv2D or MatMul), containing all
|
||||
/// ops belonging to that type in the model.
|
||||
MultiGraphNodeProto ProfileOperations(const Options& options);
|
||||
|
||||
/// Serialize the profile content (ProfileProto) into a binary string,
|
||||
/// User can write the string to file for offline analysis by
|
||||
/// tfprof command-line tools or graphical user interface.
|
||||
Status SerializeToString(string* content);
|
||||
|
||||
private:
|
||||
std::unique_ptr<TFStats> stats_;
|
||||
};
|
||||
/// @}
|
||||
|
||||
} // namespace tfprof
|
||||
} // namespace tensorflow
|
||||
|
||||
#endif // TENSORFLOW_CC_PROFILER_PROFILER_H_
|
||||
@@ -0,0 +1,50 @@
|
||||
/* Copyright 2016 The TensorFlow Authors. All Rights Reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==============================================================================*/
|
||||
|
||||
#ifndef TENSORFLOW_CC_SAVED_MODEL_CONSTANTS_H_
|
||||
#define TENSORFLOW_CC_SAVED_MODEL_CONSTANTS_H_
|
||||
|
||||
namespace tensorflow {
|
||||
|
||||
/// SavedModel assets directory.
|
||||
constexpr char kSavedModelAssetsDirectory[] = "assets";
|
||||
|
||||
/// SavedModel assets.extra directory.
|
||||
constexpr char kSavedModelAssetsExtraDirectory[] = "assets.extra";
|
||||
|
||||
/// SavedModel assets key for graph collection-def.
|
||||
constexpr char kSavedModelAssetsKey[] = "saved_model_assets";
|
||||
|
||||
/// SavedModel proto filename.
|
||||
constexpr char kSavedModelFilenamePb[] = "saved_model.pb";
|
||||
|
||||
/// SavedModel text format proto filename.
|
||||
constexpr char kSavedModelFilenamePbTxt[] = "saved_model.pbtxt";
|
||||
|
||||
/// SavedModel legacy init op key.
|
||||
constexpr char kSavedModelLegacyInitOpKey[] = "legacy_init_op";
|
||||
|
||||
/// SavedModel main op key.
|
||||
constexpr char kSavedModelMainOpKey[] = "saved_model_main_op";
|
||||
|
||||
/// Directory in which to save the SavedModel variables.
|
||||
constexpr char kSavedModelVariablesDirectory[] = "variables";
|
||||
|
||||
/// SavedModel variables filename.
|
||||
constexpr char kSavedModelVariablesFilename[] = "variables";
|
||||
|
||||
} // namespace tensorflow
|
||||
|
||||
#endif // TENSORFLOW_CC_SAVED_MODEL_CONSTANTS_H_
|
||||
@@ -0,0 +1,64 @@
|
||||
/* Copyright 2016 The TensorFlow Authors. All Rights Reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==============================================================================*/
|
||||
|
||||
/// SavedModel loading functions and SavedModelBundle struct.
|
||||
|
||||
#ifndef TENSORFLOW_CC_SAVED_MODEL_LOADER_H_
|
||||
#define TENSORFLOW_CC_SAVED_MODEL_LOADER_H_
|
||||
|
||||
#include <string>
|
||||
#include <unordered_set>
|
||||
|
||||
#include "tensorflow/core/lib/core/status.h"
|
||||
#include "tensorflow/core/protobuf/meta_graph.pb.h"
|
||||
#include "tensorflow/core/public/session.h"
|
||||
|
||||
namespace tensorflow {
|
||||
|
||||
/// SavedModel representation once the SavedModel is loaded from storage.
|
||||
struct SavedModelBundle {
|
||||
std::unique_ptr<Session> session;
|
||||
MetaGraphDef meta_graph_def;
|
||||
|
||||
/// A TensorFlow Session does not Close itself on destruction. To avoid
|
||||
/// resource leaks, we explicitly call Close on Sessions that we create.
|
||||
~SavedModelBundle() {
|
||||
if (session) {
|
||||
session->Close().IgnoreError();
|
||||
}
|
||||
}
|
||||
|
||||
SavedModelBundle() = default;
|
||||
};
|
||||
|
||||
/// Loads a SavedModel from the specified export directory. The meta graph def
|
||||
/// to be loaded is identified by the supplied tags, corresponding exactly to
|
||||
/// the set of tags used at SavedModel build time. Returns a SavedModel bundle
|
||||
/// with a session and the requested meta graph def, if found.
|
||||
Status LoadSavedModel(const SessionOptions& session_options,
|
||||
const RunOptions& run_options, const string& export_dir,
|
||||
const std::unordered_set<string>& tags,
|
||||
SavedModelBundle* const bundle);
|
||||
|
||||
/// Checks whether the provided directory could contain a SavedModel. Note that
|
||||
/// the method does not load any data by itself. If the method returns `false`,
|
||||
/// the export directory definitely does not contain a SavedModel. If the method
|
||||
/// returns `true`, the export directory may contain a SavedModel but provides
|
||||
/// no guarantee that it can be loaded.
|
||||
bool MaybeSavedModelDirectory(const string& export_dir);
|
||||
|
||||
} // namespace tensorflow
|
||||
|
||||
#endif // TENSORFLOW_CC_SAVED_MODEL_LOADER_H_
|
||||
@@ -0,0 +1,39 @@
|
||||
/* Copyright 2018 The TensorFlow Authors. All Rights Reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==============================================================================*/
|
||||
|
||||
/// Functions to read the SavedModel proto, or parts of it.
|
||||
|
||||
#ifndef TENSORFLOW_CC_SAVED_MODEL_READER_H_
|
||||
#define TENSORFLOW_CC_SAVED_MODEL_READER_H_
|
||||
|
||||
#include <string>
|
||||
#include <unordered_set>
|
||||
|
||||
#include "tensorflow/core/lib/core/status.h"
|
||||
#include "tensorflow/core/protobuf/meta_graph.pb.h"
|
||||
|
||||
namespace tensorflow {
|
||||
|
||||
// Reads the SavedModel proto from saved_model.pb(txt) in the given directory,
|
||||
// finds the MetaGraphDef that matches the given set of tags and writes it to
|
||||
// the `meta_graph_def` parameter. Returns a failure status when the SavedModel
|
||||
// file does not exist or no MetaGraphDef matches the tags.
|
||||
Status ReadMetaGraphDefFromSavedModel(const string& export_dir,
|
||||
const std::unordered_set<string>& tags,
|
||||
MetaGraphDef* const meta_graph_def);
|
||||
|
||||
} // namespace tensorflow
|
||||
|
||||
#endif // TENSORFLOW_CC_SAVED_MODEL_READER_H_
|
||||
@@ -0,0 +1,69 @@
|
||||
/* Copyright 2016 The TensorFlow Authors. All Rights Reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==============================================================================*/
|
||||
|
||||
#ifndef TENSORFLOW_CC_SAVED_MODEL_SIGNATURE_CONSTANTS_H_
|
||||
#define TENSORFLOW_CC_SAVED_MODEL_SIGNATURE_CONSTANTS_H_
|
||||
|
||||
namespace tensorflow {
|
||||
|
||||
/// Key in the signature def map for `default` serving signatures. The default
|
||||
/// signature is used in inference requests where a specific signature was not
|
||||
/// specified.
|
||||
static constexpr char kDefaultServingSignatureDefKey[] = "serving_default";
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Classification API constants.
|
||||
|
||||
/// Classification inputs.
|
||||
static constexpr char kClassifyInputs[] = "inputs";
|
||||
|
||||
/// Classification method name used in a SignatureDef.
|
||||
static constexpr char kClassifyMethodName[] = "tensorflow/serving/classify";
|
||||
|
||||
/// Classification classes output.
|
||||
static constexpr char kClassifyOutputClasses[] = "classes";
|
||||
|
||||
/// Classification scores output.
|
||||
static constexpr char kClassifyOutputScores[] = "scores";
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Predict API constants.
|
||||
|
||||
/// Predict inputs.
|
||||
static constexpr char kPredictInputs[] = "inputs";
|
||||
|
||||
/// Predict method name used in a SignatureDef.
|
||||
static constexpr char kPredictMethodName[] = "tensorflow/serving/predict";
|
||||
|
||||
/// Predict outputs.
|
||||
static constexpr char kPredictOutputs[] = "outputs";
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Regression API constants.
|
||||
|
||||
/// Regression inputs.
|
||||
static constexpr char kRegressInputs[] = "inputs";
|
||||
|
||||
/// Regression method name used in a SignatureDef.
|
||||
static constexpr char kRegressMethodName[] = "tensorflow/serving/regress";
|
||||
|
||||
/// Regression outputs.
|
||||
static constexpr char kRegressOutputs[] = "outputs";
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
} // namespace tensorflow
|
||||
|
||||
#endif // TENSORFLOW_CC_SAVED_MODEL_SIGNATURE_CONSTANTS_H_
|
||||
@@ -0,0 +1,35 @@
|
||||
/* Copyright 2016 The TensorFlow Authors. All Rights Reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==============================================================================*/
|
||||
|
||||
#ifndef TENSORFLOW_CC_SAVED_MODEL_TAG_CONSTANTS_H_
|
||||
#define TENSORFLOW_CC_SAVED_MODEL_TAG_CONSTANTS_H_
|
||||
|
||||
namespace tensorflow {
|
||||
|
||||
/// Tag for the `gpu` graph.
|
||||
constexpr char kSavedModelTagGpu[] = "gpu";
|
||||
|
||||
/// Tag for the `tpu` graph.
|
||||
constexpr char kSavedModelTagTpu[] = "tpu";
|
||||
|
||||
/// Tag for the `serving` graph.
|
||||
constexpr char kSavedModelTagServe[] = "serve";
|
||||
|
||||
/// Tag for the `training` graph.
|
||||
constexpr char kSavedModelTagTrain[] = "train";
|
||||
|
||||
} // namespace tensorflow
|
||||
|
||||
#endif // TENSORFLOW_CC_SAVED_MODEL_TAG_CONSTANTS_H_
|
||||
@@ -0,0 +1,43 @@
|
||||
/* Copyright 2017 The TensorFlow Authors. All Rights Reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==============================================================================*/
|
||||
#ifndef TENSORFLOW_CC_TOOLS_FREEZE_SAVED_MODEL_H_
|
||||
#define TENSORFLOW_CC_TOOLS_FREEZE_SAVED_MODEL_H_
|
||||
|
||||
#include <unordered_set>
|
||||
|
||||
#include "tensorflow/cc/saved_model/loader.h"
|
||||
#include "tensorflow/core/framework/graph.pb.h"
|
||||
#include "tensorflow/core/lib/core/status.h"
|
||||
|
||||
namespace tensorflow {
|
||||
|
||||
// Returns a frozen GraphDef, input tensors, and output tensors from the loaded
|
||||
// SavedModelBundle.
|
||||
// `inputs` and `outputs` consist of the union of all inputs and outputs in the
|
||||
// SignatureDefs in the SavedModelBundle.
|
||||
// FreezeSavedModel sets `frozen_graph_def` to a GraphDef of all nodes needed by
|
||||
// `outputs`. All variables in the supplied SavedModelBundle are converted to
|
||||
// constants, set to the value of the variables, by running the restored Session
|
||||
// in the SavedModelBundle.
|
||||
// WARNING: Only the variable checkpoints will be reflected in the frozen
|
||||
// graph_def. All saved_model assets will be ignored.
|
||||
Status FreezeSavedModel(const SavedModelBundle& saved_model_bundle,
|
||||
GraphDef* frozen_graph_def,
|
||||
std::unordered_set<string>* inputs,
|
||||
std::unordered_set<string>* outputs);
|
||||
|
||||
} // namespace tensorflow
|
||||
|
||||
#endif // TENSORFLOW_CC_TOOLS_FREEZE_SAVED_MODEL_H_
|
||||
@@ -0,0 +1,131 @@
|
||||
/* Copyright 2016 The TensorFlow Authors. All Rights Reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==============================================================================*/
|
||||
|
||||
#ifndef TENSORFLOW_CC_TRAINING_COORDINATOR_H_
|
||||
#define TENSORFLOW_CC_TRAINING_COORDINATOR_H_
|
||||
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
#include "tensorflow/core/framework/cost_graph.pb.h"
|
||||
#include "tensorflow/core/lib/core/error_codes.pb.h"
|
||||
#include "tensorflow/core/lib/core/status.h"
|
||||
#include "tensorflow/core/platform/macros.h"
|
||||
#include "tensorflow/core/platform/mutex.h"
|
||||
#include "tensorflow/core/protobuf/config.pb.h"
|
||||
|
||||
namespace tensorflow {
|
||||
|
||||
/// The abstract interface for runners which must implement the Join and the
|
||||
/// IsRunning function.
|
||||
class RunnerInterface {
|
||||
public:
|
||||
virtual ~RunnerInterface() {}
|
||||
virtual Status Join() = 0;
|
||||
virtual Status ExportCostGraph(CostGraphDef* cost_graph) const {
|
||||
return Status(error::INVALID_ARGUMENT, "No cost model to export.");
|
||||
}
|
||||
/// Returns true iff the runner is running, i.e. if it is trying to populate
|
||||
/// its queue.
|
||||
virtual bool IsRunning() const = 0;
|
||||
};
|
||||
|
||||
/// Coordinator class manages the termination of a collection of QueueRunners.
|
||||
/// Without a coordinator, QueueRunners have to be joined in a specific order;
|
||||
/// otherwise the QueueRunner::Join() could sometimes hang. The
|
||||
/// Coordinator::RequestStop() plays the key role which notifies all running
|
||||
/// threads under a coordinator to stop. This function could be called by any
|
||||
/// thread or any client.
|
||||
/// Usage, in the client:
|
||||
/// Coordinator coord;
|
||||
/// std::unique_ptr<QueueRunner> qr(&coord, ...);
|
||||
/// qr.Start(session);
|
||||
/// coord.RegisterRunner(std::move(qr));
|
||||
/// /// do some work
|
||||
/// TF_CHECK_OK(coord.Join());
|
||||
/// In each thread of QueueRunner, the coordinator needs to be used as:
|
||||
/// void Run() {
|
||||
/// while (!coord->ShouldStop()) {
|
||||
/// /// do some work
|
||||
/// if (error) {
|
||||
/// coord->RequestStop();
|
||||
/// coord->ReportStatus(error_status);
|
||||
/// }
|
||||
/// }
|
||||
/// }
|
||||
class Coordinator {
|
||||
public:
|
||||
Coordinator();
|
||||
|
||||
/// Constructor with a list of error codes which would not be taken as errors
|
||||
/// in status reporting.
|
||||
Coordinator(const std::vector<error::Code>& clean_stop_errors);
|
||||
|
||||
/// In the destructor, RequestStop() and Join() would be called.
|
||||
~Coordinator();
|
||||
|
||||
/// Registers a runner, i.e. a unit of running threads which is usually a
|
||||
/// QueueRunner. It takes the ownership of runner to avoid lifecycle-related
|
||||
/// problems. Note, the coordinator would not start these threads; they are
|
||||
/// supposed to be in running state when they are registered here.
|
||||
Status RegisterRunner(std::unique_ptr<RunnerInterface> runner);
|
||||
|
||||
/// Returns true iff all the registered runners have been stopped.
|
||||
bool AllRunnersStopped();
|
||||
|
||||
/// Requests all running threads to stop.
|
||||
Status RequestStop();
|
||||
|
||||
/// Returns true if its RequestStop() has been called.
|
||||
bool ShouldStop();
|
||||
|
||||
/// Joins all threads, returns OK or the first reported and unexpected status.
|
||||
Status Join();
|
||||
|
||||
/// Reports status to the coordinator. This is usually called by threads.
|
||||
void ReportStatus(const Status& status);
|
||||
|
||||
/// Returns the latest status.
|
||||
Status GetStatus();
|
||||
|
||||
/// Returns immediately if the coordinator is stopped or blocks until
|
||||
/// RequestStop() is called.
|
||||
void WaitForStop();
|
||||
|
||||
// Returns the cost graph from stored run metadata in registered runners.
|
||||
Status ExportCostGraph(CostGraphDef* cost_graph) const;
|
||||
|
||||
private:
|
||||
std::unordered_set<int> clean_stop_errors_;
|
||||
condition_variable wait_for_stop_;
|
||||
|
||||
mutex mu_;
|
||||
bool should_stop_ GUARDED_BY(mu_);
|
||||
|
||||
mutex status_lock_;
|
||||
Status status_ GUARDED_BY(status_lock_);
|
||||
|
||||
mutable mutex runners_lock_;
|
||||
std::vector<std::unique_ptr<RunnerInterface>> runners_
|
||||
GUARDED_BY(runners_lock_);
|
||||
|
||||
TF_DISALLOW_COPY_AND_ASSIGN(Coordinator);
|
||||
};
|
||||
|
||||
} // namespace tensorflow
|
||||
|
||||
#endif // TENSORFLOW_CC_TRAINING_COORDINATOR_H_
|
||||
@@ -0,0 +1,140 @@
|
||||
/* Copyright 2016 The TensorFlow Authors. All Rights Reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==============================================================================*/
|
||||
|
||||
#ifndef TENSORFLOW_CC_TRAINING_QUEUE_RUNNER_H_
|
||||
#define TENSORFLOW_CC_TRAINING_QUEUE_RUNNER_H_
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
#include "tensorflow/cc/training/coordinator.h"
|
||||
#include "tensorflow/core/lib/core/blocking_counter.h"
|
||||
#include "tensorflow/core/lib/core/error_codes.pb.h"
|
||||
#include "tensorflow/core/lib/core/status.h"
|
||||
#include "tensorflow/core/lib/core/threadpool.h"
|
||||
#include "tensorflow/core/platform/mutex.h"
|
||||
#include "tensorflow/core/protobuf/config.pb.h"
|
||||
#include "tensorflow/core/protobuf/queue_runner.pb.h"
|
||||
#include "tensorflow/core/public/session.h"
|
||||
|
||||
namespace tensorflow {
|
||||
|
||||
/// QueueRunner class imitates the behavior of the python version of QueueRunner
|
||||
/// which creates a thread for each enqueue op, runs close op on completion.
|
||||
class QueueRunner : public RunnerInterface {
|
||||
public:
|
||||
/// Creates a new QueueRunner from proto.
|
||||
// TODO(yuefengz): we may want to initialize from queues and ops in the
|
||||
// future.
|
||||
static Status New(const QueueRunnerDef& queue_runner_def,
|
||||
std::unique_ptr<QueueRunner>* result);
|
||||
|
||||
/// Creates a new QueueRunner with a coordinator, see coordinator.h for usage.
|
||||
static Status New(const QueueRunnerDef& queue_runner_def, Coordinator* coord,
|
||||
std::unique_ptr<QueueRunner>* result);
|
||||
|
||||
/// Adds a callback that the queue runner will call when it detects an error.
|
||||
void AddErrorCallback(const std::function<void(Status)>& cb);
|
||||
|
||||
/// Delete the previously registered callbacks.
|
||||
void ClearErrorCallbacks();
|
||||
|
||||
/// The destructor would join all the threads.
|
||||
~QueueRunner();
|
||||
|
||||
/// Starts the queue runner with the given session.
|
||||
Status Start(Session* sess);
|
||||
|
||||
/// Starts the queue runner with the given session and sets the run arguments
|
||||
/// for sess->Run. It also collects and stores the cost model.
|
||||
Status StartAndCollectCostGraph(Session* sess,
|
||||
const RunOptions& run_options = RunOptions());
|
||||
|
||||
/// Starts the queue runner with the given session, and wait for up to the
|
||||
/// specified time (in milliseconds) for the queues to start to fill up.
|
||||
Status Start(Session* sess, int wait_for_ms);
|
||||
Status StartAndCollectCostGraph(Session* session, int wait_for_ms,
|
||||
const RunOptions& run_options = RunOptions());
|
||||
|
||||
/// Requests to stop and runs the cancel op. It would be called in a separate
|
||||
/// thread when coordinator is set. If there is no coordinator it should be
|
||||
/// called before calling Join.
|
||||
void Stop(Session* sess);
|
||||
|
||||
/// Joins all the threads. Returns okay if all threads run successfully;
|
||||
/// otherwise returns the first captured failure status.
|
||||
Status Join() final;
|
||||
|
||||
/// Returns the latest status.
|
||||
Status GetStatus();
|
||||
|
||||
// Returns the stored cost model.
|
||||
Status ExportCostGraph(CostGraphDef* cost_graph) const override;
|
||||
|
||||
private:
|
||||
QueueRunner() : coord_(nullptr), stopped_(false), cg_mu_(nullptr) {}
|
||||
|
||||
// Initializes the instance with the QueueRunnerDef proto.
|
||||
Status Init(const QueueRunnerDef& queue_runner_def);
|
||||
|
||||
// The Run function for each thread.
|
||||
void Run(Session* sess, const string& enqueue_op);
|
||||
|
||||
// Updates the internal status; it only keeps OK or the first unexpected error
|
||||
// status.
|
||||
void UpdateStatus(const Status& status);
|
||||
|
||||
bool IsQueueClosed(Status status) const {
|
||||
return queue_closed_exception_types_.count(
|
||||
static_cast<int>(status.code())) > 0;
|
||||
}
|
||||
|
||||
bool IsRunning() const override { return !stopped_; }
|
||||
|
||||
void SetRunArgumentsAndCostGraph(const RunOptions& run_options);
|
||||
|
||||
Status RealRun(Session* sess, const string& op, bool update_costs);
|
||||
|
||||
string queue_name_;
|
||||
std::vector<string> enqueue_op_names_;
|
||||
string close_op_name_;
|
||||
string cancel_op_name_;
|
||||
// code::Code casted to int to avoid a hash function.
|
||||
std::unordered_set<int> queue_closed_exception_types_;
|
||||
|
||||
std::unique_ptr<thread::ThreadPool> thread_pool_;
|
||||
mutex mu_;
|
||||
int runs_ = 0;
|
||||
Status status_ GUARDED_BY(mu_);
|
||||
Status enqueue_status_ GUARDED_BY(mu_);
|
||||
std::unique_ptr<BlockingCounter> counter_;
|
||||
|
||||
Coordinator* coord_;
|
||||
|
||||
std::atomic<bool> stopped_;
|
||||
|
||||
mutex cb_mu_;
|
||||
std::vector<std::function<void(Status)>> callbacks_;
|
||||
|
||||
mutable std::unique_ptr<mutex> cg_mu_;
|
||||
std::unique_ptr<CostGraphDef> cost_graph_ GUARDED_BY(cg_mu_);
|
||||
RunOptions run_options_;
|
||||
};
|
||||
|
||||
} // namespace tensorflow
|
||||
|
||||
#endif // TENSORFLOW_CC_TRAINING_QUEUE_RUNNER_H_
|
||||
Reference in new issue
Block a user