chore: import upstream snapshot with attribution
cffconvert / validate (push) Has been skipped
License Check / license-check (push) Failing after 2s

This commit is contained in:
wehub-resource-sync
2026-07-13 12:14:16 +08:00
commit 8a852e4b4e
36502 changed files with 9277225 additions and 0 deletions
+577
View File
@@ -0,0 +1,577 @@
# Description:
# Tensorflow default op definitions.
load(
"@xla//xla/tsl/mkl:build_defs.bzl",
"if_mkl",
)
load(
"//tensorflow:tensorflow.bzl",
"tf_cc_test",
)
load(
"//tensorflow:tensorflow.default.bzl",
"filegroup",
"tf_gen_op_libs",
)
load(
"//tensorflow/core/platform:rules_cc.bzl",
"cc_library",
)
# A lot of packages try to minimize binary size by depending on individual ops,\
# so they need access here.
package(
# copybara:uncomment default_applicable_licenses = ["//tensorflow:license"],
default_visibility = [
"//visibility:public",
],
features = ["-parse_headers"],
licenses = ["notice"],
)
# Export the BUILD file so automated tooling can check licenses
exports_files([
"BUILD",
"ops.pbtxt",
])
# Generates library per group of ops.
tf_gen_op_libs(
is_external = False,
op_lib_names = [
"batch_ops",
"bitwise_ops",
"boosted_trees_ops",
"candidate_sampling_ops",
"checkpoint_ops",
"clustering_ops",
"collective_ops",
"control_flow_ops",
"count_ops",
"ctc_ops",
"data_flow_ops",
"dataset_ops",
"decode_proto_ops",
"encode_proto_ops",
"experimental_dataset_ops",
"filesystem_ops",
"function_ops",
"functional_ops",
"image_ops",
"io_ops",
"linalg_ops",
"list_ops",
"map_ops",
"lookup_ops",
"manip_ops",
"math_ops",
"mkl_nn_ops",
"nccl_ops",
"nn_ops",
"no_op",
"optional_ops",
"parsing_ops",
"random_grad",
"random_index_shuffle_ops",
"random_ops",
"special_math_ops",
"stateful_random_ops",
"risc_ops",
"rnn_ops",
"scoped_allocator_ops",
"sdca_ops",
"set_ops",
"script_ops",
"sendrecv_ops",
"sparse_ops",
"spectral_ops",
"state_ops",
"stateless_random_ops",
"stateless_random_ops_v2",
"stochastic_cast_op",
"sync_ops",
"summary_ops",
"training_ops",
],
sub_directory = "",
deps = [
"//tensorflow/core:lib",
"//tensorflow/core:protos_all_cc",
"@com_google_absl//absl/strings",
],
)
tf_gen_op_libs(
is_external = False,
op_lib_names = ["sparse_csr_matrix_ops"],
sub_directory = "",
deps = [
"//tensorflow/core:lib",
"//tensorflow/core:protos_all_cc",
"@com_google_absl//absl/status",
"@com_google_absl//absl/strings",
],
)
tf_gen_op_libs(
is_external = False,
op_lib_names = [
"logging_ops",
],
sub_directory = "",
deps = [
"//tensorflow/core:lib",
"//tensorflow/core:protos_all_cc",
# TODO(b/162630222): remove this dependency.
"//tensorflow/c/kernels:histogram_summary_op_lib",
"//tensorflow/c/kernels:merge_summary_op_lib",
"//tensorflow/c/kernels:summary_op_lib",
],
)
tf_gen_op_libs(
op_lib_names = [
"string_ops",
],
sub_directory = "",
deps = [
"//tensorflow/core:lib_internal",
"//tensorflow/core:lib_proto_parsing",
"@com_google_absl//absl/strings",
],
)
tf_gen_op_libs(
op_lib_names = [
"array_ops",
],
sub_directory = "",
deps = [
"//tensorflow/core:lib",
"//tensorflow/core:protos_all_cc",
],
)
tf_gen_op_libs(
op_lib_names = [
"mkl_array_ops",
],
sub_directory = "",
deps = ["//tensorflow/core:protos_all_cc"],
)
tf_gen_op_libs(
op_lib_names = [
"audio_ops",
],
sub_directory = "",
deps = ["//tensorflow/core:lib"],
)
tf_gen_op_libs(
op_lib_names = ["debug_ops"],
sub_directory = "",
deps = ["//tensorflow/core:lib"],
)
tf_gen_op_libs(
is_external = False,
op_lib_names = [
"resource_variable_ops",
],
sub_directory = "",
deps = ["//tensorflow/core:lib"],
)
tf_gen_op_libs(
op_lib_names = [
"tpu_configuration_ops",
"tpu_cross_replica_ops",
"tpu_embedding_ops",
"tpu_embedding_load_retrieve_ops",
"tpu_functional_ops",
"tpu_heartbeat_ops",
"tpu_host_compute_ops",
"tpu_sharding_util_ops",
"tpu_infeed_ops",
"tpu_outfeed_ops",
"tpu_ordinal_selector_ops",
"tpu_replication_ops",
],
sub_directory = "",
deps = [
"//tensorflow/core:lib",
"//tensorflow/core:lib_proto_parsing",
"//tensorflow/core:protos_all_cc",
"//tensorflow/core/protobuf/tpu:optimization_parameters_proto_cc",
"//tensorflow/core/protobuf/tpu:tpu_embedding_configuration_proto_cc",
"//tensorflow/core/tpu:tpu_embedding_optimization_parameters_utils",
"//tensorflow/core/tpu:tpu_embedding_output_layout_utils",
"@com_google_absl//absl/status",
],
)
cc_library(
name = "word2vec_ops",
srcs = ["word2vec_ops.cc"],
linkstatic = 1,
deps = ["//tensorflow/core:framework"],
alwayslink = 1,
)
tf_gen_op_libs(
op_lib_names = [
"cudnn_rnn_ops",
],
sub_directory = "",
deps = [
"//tensorflow/core:lib",
],
)
tf_gen_op_libs(
op_lib_names = ["composite_tensor_ops"],
sub_directory = "",
deps = [
"//tensorflow/core:lib",
],
)
cc_library(
name = "ragged_ops",
deps = [
"//tensorflow/core:ragged_array_ops_op_lib",
"//tensorflow/core:ragged_conversion_ops_op_lib",
"//tensorflow/core:ragged_math_ops_op_lib",
],
)
tf_gen_op_libs(
op_lib_names = [
"ragged_array_ops",
"ragged_conversion_ops",
"ragged_math_ops",
],
sub_directory = "",
deps = ["//tensorflow/core/util:ragged_to_dense_util"],
)
tf_gen_op_libs(
is_external = False,
op_lib_names = [
"uniform_quant_ops",
],
sub_directory = "",
deps = [
"//tensorflow/core:lib",
"//tensorflow/core:protos_all_cc",
"//tensorflow/core/util/quantization:uniform_quant_ops_params",
],
)
cc_library(
name = "ops",
deps = [
":array_ops_op_lib",
":audio_ops_op_lib",
":batch_ops_op_lib",
":bitwise_ops_op_lib",
":boosted_trees_ops_op_lib",
":candidate_sampling_ops_op_lib",
":checkpoint_ops_op_lib",
":clustering_ops_op_lib",
":collective_ops_op_lib",
":composite_tensor_ops_op_lib",
":control_flow_ops_op_lib",
":count_ops_op_lib",
":ctc_ops_op_lib",
":cudnn_rnn_ops_op_lib",
":data_flow_ops_op_lib",
":dataset_ops_op_lib",
":debug_ops_op_lib",
":decode_proto_ops_op_lib",
":encode_proto_ops_op_lib",
":experimental_dataset_ops_op_lib",
":filesystem_ops_op_lib",
":function_ops_op_lib",
":functional_ops_op_lib",
":image_ops_op_lib",
":io_ops_op_lib",
":linalg_ops_op_lib",
":list_ops_op_lib",
":logging_ops_op_lib",
":lookup_ops_op_lib",
":manip_ops_op_lib",
":map_ops_op_lib",
":math_ops_op_lib",
":nccl_ops_op_lib",
":nn_ops_op_lib",
":no_op_op_lib",
":optional_ops_op_lib",
":parsing_ops_op_lib",
":ragged_ops",
":random_index_shuffle_ops_op_lib",
":random_ops_op_lib",
":resource_variable_ops_op_lib",
":risc_ops_op_lib",
":rnn_ops_op_lib",
":scoped_allocator_ops_op_lib",
":script_ops_op_lib",
":sdca_ops_op_lib",
":sendrecv_ops_op_lib",
":set_ops_op_lib",
":sparse_csr_matrix_ops_op_lib",
":sparse_ops_op_lib",
":special_math_ops_op_lib",
":spectral_ops_op_lib",
":state_ops_op_lib",
":stateful_random_ops_op_lib",
":stateless_random_ops_op_lib",
":stateless_random_ops_v2_op_lib",
":stochastic_cast_op_op_lib",
":string_ops_op_lib",
":summary_ops_op_lib",
":sync_ops_op_lib",
":training_ops_op_lib",
":uniform_quant_ops_op_lib",
":word2vec_ops",
] + select({
# Non-tpu platforms don't need tpu dependency.
"//tensorflow:chromiumos": [],
"//tensorflow:fuchsia": [],
"//conditions:default": [
":tpu_configuration_ops_op_lib",
":tpu_cross_replica_ops_op_lib",
":tpu_embedding_load_retrieve_ops_op_lib",
":tpu_embedding_ops_op_lib",
":tpu_functional_ops_op_lib",
":tpu_heartbeat_ops_op_lib",
":tpu_host_compute_ops_op_lib",
":tpu_infeed_ops_op_lib",
":tpu_ordinal_selector_ops_op_lib",
":tpu_outfeed_ops_op_lib",
":tpu_replication_ops_op_lib",
":tpu_sharding_util_ops_op_lib",
],
}) + if_mkl([
":mkl_array_ops_op_lib",
":mkl_nn_ops_op_lib",
]),
alwayslink = 1,
)
cc_library(
name = "array_grad",
srcs = ["array_grad.cc"],
linkstatic = 1, # Needed since alwayslink is broken in bazel b/27630669
deps = [
":array_ops_op_lib",
"//tensorflow/c/kernels:bitcast_op_lib",
"//tensorflow/core:framework",
"//tensorflow/core:lib",
],
alwayslink = 1,
)
cc_library(
name = "functional_grad",
srcs = ["functional_grad.cc"],
linkstatic = 1, # Needed since alwayslink is broken in bazel b/27630669
deps = [
":functional_ops_op_lib",
"//tensorflow/core:framework",
"//tensorflow/core:lib",
],
alwayslink = 1,
)
cc_library(
name = "math_grad",
srcs = [
"math_grad.cc",
"stateless_random_grad.cc",
],
linkstatic = 1, # Needed since alwayslink is broken in bazel b/27630669
deps = [
":math_ops_op_lib",
":random_grad_op_lib",
"//tensorflow/core:framework",
"//tensorflow/core:lib",
"//tensorflow/core:protos_all_cc",
],
alwayslink = 1,
)
cc_library(
name = "nn_grad",
srcs = ["nn_grad.cc"],
linkstatic = 1, # Needed since alwayslink is broken in bazel b/27630669
deps = [
":nn_ops_op_lib",
"//tensorflow/core:framework",
"//tensorflow/core:lib",
] + if_mkl([
":mkl_nn_ops_op_lib",
]),
alwayslink = 1,
)
filegroup(
name = "portable_op_registrations_and_gradients",
srcs = [
":mobile_hdrs",
":mobile_srcs",
],
)
filegroup(
name = "mobile_srcs",
srcs = ["//tensorflow/c/kernels:portable_all_ops"] + glob(
[
"**/*.cc",
],
exclude = [
"**/*test.cc",
"**/*testutil*",
"**/*testlib*",
"**/*main.cc",
"**/tpu_*",
],
),
)
filegroup(
name = "mobile_hdrs",
srcs = glob(
[
"**/*.h",
],
exclude = [
"**/*testutil*",
"**/*testlib*",
"**/tpu_*",
],
),
)
tf_cc_test(
name = "cudnn_rnn_ops_test_cc",
size = "small",
srcs = [
"cudnn_rnn_ops_test.cc",
],
deps = [
"//tensorflow/core",
"//tensorflow/core:framework",
"//tensorflow/core:lib",
"//tensorflow/core:test",
"//tensorflow/core:test_main",
"//tensorflow/core:testlib",
],
)
tf_cc_test(
name = "ops_array_grad_test",
size = "small",
srcs = ["array_grad_test.cc"],
deps = [
":ops",
"//tensorflow/cc:cc_ops",
"//tensorflow/core",
"//tensorflow/core:core_cpu",
"//tensorflow/core:core_cpu_internal",
"//tensorflow/core:direct_session_internal",
"//tensorflow/core:framework",
"//tensorflow/core:framework_internal",
"//tensorflow/core:lib",
"//tensorflow/core:lib_internal",
"//tensorflow/core:protos_all_cc",
"//tensorflow/core:test",
"//tensorflow/core:test_main",
"//tensorflow/core:testlib",
"//tensorflow/core/kernels:array",
"//tensorflow/core/kernels:cwise_op",
"//tensorflow/core/kernels:function_ops",
"//tensorflow/core/kernels:math",
"@eigen_archive//:eigen3",
],
)
tf_cc_test(
name = "ops_math_grad_test",
size = "small",
srcs = ["math_grad_test.cc"],
tags = ["no_gpu"],
deps = [
":ops",
"//tensorflow/cc:cc_ops",
"//tensorflow/core",
"//tensorflow/core:core_cpu",
"//tensorflow/core:core_cpu_internal",
"//tensorflow/core:direct_session_internal",
"//tensorflow/core:framework",
"//tensorflow/core:framework_internal",
"//tensorflow/core:lib",
"//tensorflow/core:lib_internal",
"//tensorflow/core:protos_all_cc",
"//tensorflow/core:test",
"//tensorflow/core:test_main",
"//tensorflow/core:testlib",
"//tensorflow/core/kernels:array",
"//tensorflow/core/kernels:data_flow",
"//tensorflow/core/kernels:function_ops",
"//tensorflow/core/kernels:math",
"@eigen_archive//:eigen3",
],
)
tf_cc_test(
name = "ops_tests",
size = "small",
srcs = [
"array_ops_test.cc",
"candidate_sampling_ops_test.cc",
"control_flow_ops_test.cc",
"ctc_ops_test.cc",
"data_flow_ops_test.cc",
"functional_ops_test.cc",
"image_ops_test.cc",
"io_ops_test.cc",
"linalg_ops_test.cc",
"lookup_ops_test.cc",
"math_ops_test.cc",
"nn_ops_test.cc",
"parsing_ops_test.cc",
"random_ops_test.cc",
"rnn_ops_test.cc",
"set_ops_test.cc",
"shape_function_test.cc",
"sparse_csr_matrix_ops_test.cc",
"sparse_ops_test.cc",
"spectral_ops_test.cc",
"state_ops_test.cc",
"stochastic_cast_op_test.cc",
"string_ops_test.cc",
"tpu_cross_replica_ops_test.cc",
"training_ops_test.cc",
"uniform_quant_ops_test.cc",
],
deps = [
":ops",
"//tensorflow/cc:cc_ops",
"//tensorflow/core",
"//tensorflow/core:core_cpu",
"//tensorflow/core:core_cpu_internal",
"//tensorflow/core:framework",
"//tensorflow/core:framework_internal",
"//tensorflow/core:lib",
"//tensorflow/core:lib_internal",
"//tensorflow/core:protos_all_cc",
"//tensorflow/core:test",
"//tensorflow/core:test_main",
"//tensorflow/core:testlib",
"//tensorflow/core/common_runtime:type_inference",
"@com_google_googletest//:gtest",
],
)
+581
View File
@@ -0,0 +1,581 @@
/* 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.
==============================================================================*/
#include <vector>
#include "tensorflow/core/framework/function.h"
#include "tensorflow/core/lib/core/errors.h"
namespace tensorflow {
typedef FunctionDefHelper FDH;
REGISTER_OP_NO_GRADIENT("Shape");
REGISTER_OP_NO_GRADIENT("Rank");
REGISTER_OP_NO_GRADIENT("Size");
REGISTER_OP_NO_GRADIENT("ZerosLike");
REGISTER_OP_NO_GRADIENT("OnesLike");
REGISTER_OP_NO_GRADIENT("Const");
REGISTER_OP_NO_GRADIENT("EditDistance");
REGISTER_OP_NO_GRADIENT("StopGradient");
REGISTER_OP_NO_GRADIENT("FakeQuantWithMinMaxArgsGradient");
REGISTER_OP_NO_GRADIENT("FakeQuantWithMinMaxVarsGradient");
REGISTER_OP_NO_GRADIENT("FakeQuantWithMinMaxVarsPerChannelGradient");
absl::Status ReshapeGrad(const AttrSlice& attrs, FunctionDef* g) {
// clang-format off
*g = FDH::Define(
// Arg defs
{"x: T", "shape: int32", "dy: T"},
// Ret val defs
{"dx: T", "dshape: int32"},
// Attr defs
{"T: type"},
// Nodes
{
{{"x_shape"}, "Shape", {"x"}, {{"T", "$T"}}},
{{"dx"}, "Reshape", {"dy", "x_shape"}, {{"T", "$T"}}},
{{"dshape"}, "ZerosLike", {"shape"}, {{"T", DT_INT32}}},
});
// clang-format on
return absl::OkStatus();
}
REGISTER_OP_GRADIENT("Reshape", ReshapeGrad);
REGISTER_OP_GRADIENT("ExpandDims", ReshapeGrad);
absl::Status SqueezeGrad(const AttrSlice& attrs, FunctionDef* g) {
// clang-format off
*g = FDH::Define(
// Arg defs
{"x: T", "dy: T"},
// Ret val defs
{"dx: T"},
// Attr defs
{"T: type"},
// Nodes
{
{{"x_shape"}, "Shape", {"x"}, {{"T", "$T"}}},
{{"dx"}, "Reshape", {"dy", "x_shape"}, {{"T", "$T"}}},
});
// clang-format on
return absl::OkStatus();
}
REGISTER_OP_GRADIENT("Squeeze", SqueezeGrad);
absl::Status IdentityGrad(const AttrSlice& attrs, FunctionDef* g) {
// clang-format off
*g = FDH::Define(
// Arg defs
{"x: T", "dy: T"},
// Ret val defs
{"dx: T"},
// Attr defs
{"T: type"},
// Nodes
{
{{"dx"}, "Identity", {"dy"}, {{"T", "$T"}}},
});
// clang-format on
VLOG(1) << "IdentityGrad " << DebugString(*g);
return absl::OkStatus();
}
REGISTER_OP_GRADIENT("Identity", IdentityGrad);
absl::Status PackGrad(const AttrSlice& attrs, FunctionDef* g) {
// clang-format off
*g = FDH::Create(
"_",
// Arg defs
{"x: N*T", "dy: T"},
// Ret val defs
{"dx: N*T"},
// Attr defs
{"T: type", "N: int", "axis: int"},
// Nodes
{
{
{"dx"},
"Unpack",
{"dy"},
{{"T", "$T"}, {"num", "$N"}, {"axis", "$axis"}}
},
},
{{"dx", "dx:output"}});
// clang-format on
VLOG(1) << "PackGrad " << DebugString(*g);
return absl::OkStatus();
}
REGISTER_OP_GRADIENT("Pack", PackGrad);
absl::Status UnpackGrad(const AttrSlice& attrs, FunctionDef* g) {
// clang-format off
*g = FDH::Define(
// Arg defs
{"x: T", "dy: num*T"},
// Ret val defs
{"dx: T"},
// Attr defs
{"T: type", "num: int", "axis: int"},
// Nodes
{
{
{"dx"},
"Pack",
{"dy"},
{{"T", "$T"}, {"N", "$num"}, {"axis", "$axis"}}
},
});
// clang-format on
VLOG(1) << "UnpackGrad " << DebugString(*g);
return absl::OkStatus();
}
REGISTER_OP_GRADIENT("Unpack", UnpackGrad);
absl::Status ConcatGradHelper(const AttrSlice& attrs, FunctionDef* g,
bool dim_is_last_arg) {
int N;
TF_RETURN_IF_ERROR(GetNodeAttr(attrs, "N", &N));
DataType T;
TF_RETURN_IF_ERROR(GetNodeAttr(attrs, "T", &T));
std::vector<std::string> shape_i;
std::vector<std::string> offset_i;
std::vector<std::string> dx_i;
for (int i = 0; i < N; ++i) {
shape_i.push_back(absl::StrCat("shapes:output:", i));
offset_i.push_back(absl::StrCat("offset:offset:", i));
dx_i.push_back(absl::StrCat("dx_", i, ":output:0"));
}
// ConcatGrad(dim, x, dy):
// for i in range(N):
// dx[i] = Slice(dy, offset[i], shape[x[i]]),
// where offset[i] is the offset of x[i] in the output y,
// which is the same as dx[i]'s offset within dy.
std::vector<FDH::Node> nodes{
{{"shapes"}, "ShapeN", {"x"}, {{"T", "$T"}, {"N", "$N"}}},
{{"offset"}, "ConcatOffset", {"dim", "shapes:output"}, {{"N", "$N"}}},
{{"d_dim"}, "ZerosLike", {"dim"}, {{"T", DT_INT32}}},
{{"dx"},
"_ListToArray",
dx_i,
{{"T", "$T"}, {"N", "$N"}, {"Tin", DataTypeVector(N, T)}}}};
// For each dx[i], we take a slice of dy. The offset and size of the
// slice is given by offset[i] and shape[i].
for (int i = 0; i < N; ++i) {
nodes.push_back({{absl::StrCat("dx_", i)},
"Slice",
{"dy", offset_i[i], shape_i[i]},
{{"T", "$T"}, {"Index", DT_INT32}}});
}
if (dim_is_last_arg) {
// clang-format off
*g = FDH::Create(
"_",
// Arg defs
{"x: N*T", "dim: int32", "dy: T"},
// Return signature
{"dx: N*T", "d_dim: int32"},
// Attr defs
{"T: type", "N: int"},
// Nodes
nodes,
// Return values
{{"dx", "dx:output"}, {"d_dim", "d_dim:y:0"}});
// clang-format on
} else {
// clang-format off
*g = FDH::Create(
"_",
// Arg defs
{"dim: int32", "x: N*T", "dy: T"},
// Return signature
{"d_dim: int32", "dx: N*T"},
// Attr defs
{"T: type", "N: int"},
// Nodes
nodes,
// Return values
{{"dx", "dx:output"}, {"d_dim", "d_dim:y:0"}});
// clang-format on
}
VLOG(1) << "ConcatGrad " << DebugString(*g);
return absl::OkStatus();
}
absl::Status ConcatGrad(const AttrSlice& attrs, FunctionDef* g) {
return ConcatGradHelper(attrs, g, false);
}
absl::Status ConcatGradV2(const AttrSlice& attrs, FunctionDef* g) {
return ConcatGradHelper(attrs, g, true);
}
REGISTER_OP_GRADIENT("Concat", ConcatGrad);
REGISTER_OP_GRADIENT("ConcatV2", ConcatGradV2);
absl::Status SplitGrad(const AttrSlice& attrs, FunctionDef* g) {
// clang-format off
*g = FDH::Define(
// Arg defs
{"dim: int32", "x: T", "dy: num_split*T"},
// Ret val defs
{"d_dim: int32", "dx: T"},
// Attr defs
{"T: type", "num_split: int"},
// Nodes
{
{{"d_dim"}, "ZerosLike", {"dim"}, {{"T", DT_INT32}}},
{{"dx"}, "Concat", {"dim", "dy"}, {{"T", "$T"}, {"N", "$num_split"}}}
});
// clang-format on
VLOG(1) << "SplitGrad " << DebugString(*g);
return absl::OkStatus();
}
REGISTER_OP_GRADIENT("Split", SplitGrad);
absl::Status SplitVGrad(const AttrSlice& attrs, FunctionDef* g) {
// clang-format off
*g = FDH::Define(
// Arg defs
{"x: T", "size_splits: Tlen", "dim: int32", "dy: num_split*T"},
// Ret val defs
{"dx: T", "d_size_splits: Tlen", "d_dim: int32"},
// Attr defs
{"T: type", "Tlen: type", "num_split: int"},
// Nodes
{
{{"dx"}, "Concat", {"dim", "dy"}, {{"T", "$T"}, {"N", "$num_split"}}},
{{"d_size_splits"}, "ZerosLike", {"size_splits"}, {{"T", "$Tlen"}}},
{{"d_dim"}, "ZerosLike", {"dim"}, {{"T", DT_INT32}}},
});
// clang-format on
VLOG(1) << "SplitVGrad " << DebugString(*g);
return absl::OkStatus();
}
REGISTER_OP_GRADIENT("SplitV", SplitVGrad);
absl::Status ArrayToListGrad(const AttrSlice& attrs, FunctionDef* g) {
int N;
TF_RETURN_IF_ERROR(GetNodeAttr(attrs, "N", &N));
std::vector<std::string> dys;
dys.reserve(N);
for (int i = 0; i < N; ++i) {
dys.push_back(absl::StrCat("dy:", i));
}
// clang-format off
*g = FDH::Define(
// Arg defs
{"x: N*T", "dy: out_types"},
// Ret val defs
{"dx: N*T"},
// Attr defs
{"T: type", "N: int", "out_types: list(type)"},
// Nodes
{
{{"dx"}, "_ListToArray", dys,
{{"T", "$T"}, {"N", "$N"}, {"Tin", "$out_types"}}}
});
// clang-format on
VLOG(1) << "ArrayToListGrad " << DebugString(*g);
return absl::OkStatus();
}
REGISTER_OP_GRADIENT("_ArrayToList", ArrayToListGrad);
absl::Status ListToArrayGrad(const AttrSlice& attrs, FunctionDef* g) {
// clang-format off
*g = FDH::Define(
// Arg defs
{"x: Tin", "dy: N*T"},
// Ret val defs
{"dx: Tin"},
// Attr defs
{"T: type", "N: int", "Tin: list(type)"},
// Nodes
{
{{"dx"}, "_ArrayToList", {"dy"},
{{"T", "$T"}, {"N", "$N"}, {"out_types", "$Tin"}}}
});
// clang-format on
VLOG(1) << "ListToArrayGrad " << DebugString(*g);
return absl::OkStatus();
}
REGISTER_OP_GRADIENT("_ListToArray", ListToArrayGrad);
absl::Status FillGrad(const AttrSlice& attrs, FunctionDef* g) {
*g = FDH::Define(
// Arg defs
{"dims: int32", "x: T", "dy: T"},
// Ret val defs
{"d_dims: int32", "dx: T"},
// Attr defs
{"T: type"},
// Nodes
{
{{"d_dims"}, "ZerosLike", {"dims"}, {{"T", DT_INT32}}},
FDH::Const("zero", 0),
{{"rank"}, "Rank", {"dy"}, {{"T", "$T"}}},
FDH::Const("one", 1),
{{"r"}, "Range", {"zero", "rank", "one"}, {}},
// dx = sum(dy)
{{"dx"}, "Sum", {"dy", "r"}, {{"T", "$T"}}},
});
VLOG(1) << "FillGrad " << DebugString(*g);
return absl::OkStatus();
}
REGISTER_OP_GRADIENT("Fill", FillGrad);
absl::Status TransposeGrad(const AttrSlice& attrs, FunctionDef* g) {
*g = FDH::Define(
// Arg defs
{"x: T", "p: int32", "dy: T"},
// Ret val defs
{"dx: T", "dp: int32"},
// Attr defs
{"T: type"},
// Nodes
{
{{"q"}, "InvertPermutation", {"p"}, {}},
{{"dx"}, "Transpose", {"dy", "q"}, {{"T", "$T"}}},
{{"dp"}, "ZerosLike", {"p"}, {{"T", DT_INT32}}},
});
VLOG(1) << "TransposeGrad " << DebugString(*g);
return absl::OkStatus();
}
REGISTER_OP_GRADIENT("Transpose", TransposeGrad);
absl::Status GatherNdGrad(const AttrSlice& attrs, FunctionDef* g) {
// clang-format off
*g = FDH::Define(
// Arg defs
{"params: Tparams", "indices: Tindices", "doutput: Tparams"},
// Ret val defs
{"dparams: Tparams", "dindices: Tindices"},
// Attr defs
{"Tparams: type", "Tindices: type"},
// Nodes
{
{{"x_shape"}, "Shape", {"params"}, {{"T", "$Tparams"}}},
{{"dparams"}, "ScatterNd", {"indices", "doutput", "x_shape"},
{{"T", "$Tparams"}, {"Tindices", "$Tindices"}}},
{{"dindices"}, "ZerosLike", {"indices"}, {{"T", "$Tindices"}}},
});
// clang-format on
return absl::OkStatus();
}
REGISTER_OP_GRADIENT("GatherNd", GatherNdGrad);
absl::Status ConjugateTransposeGrad(const AttrSlice& attrs, FunctionDef* g) {
*g = FDH::Define(
// Arg defs
{"x: T", "p: int32", "dy: T"},
// Ret val defs
{"dx: T", "dp: int32"},
// Attr defs
{"T: type"},
// Nodes
{
{{"q"}, "InvertPermutation", {"p"}, {}},
{{"dx"}, "ConjugateTranspose", {"dy", "q"}, {{"T", "$T"}}},
{{"dp"}, "ZerosLike", {"p"}, {{"T", DT_INT32}}},
});
VLOG(1) << "ConjugateTransposeGrad " << DebugString(*g);
return absl::OkStatus();
}
REGISTER_OP_GRADIENT("ConjugateTranspose", ConjugateTransposeGrad);
absl::Status ReverseGrad(const AttrSlice& attrs, FunctionDef* g) {
*g = FDH::Define(
// Arg defs
{"x: T", "d: bool", "dy: T"},
// Ret val defs
{"dx: T", "dd: bool"},
// Attr defs
{"T: type"},
// Nodes
{
{{"dx"}, "Reverse", {"dy", "d"}, {{"T", "$T"}}},
{{"dd"}, "ZerosLike", {"d"}, {{"T", DT_BOOL}}},
});
VLOG(1) << "ReverseGrad " << DebugString(*g);
return absl::OkStatus();
}
REGISTER_OP_GRADIENT("Reverse", ReverseGrad);
absl::Status ReverseV2Grad(const AttrSlice& attrs, FunctionDef* g) {
DataType itype;
TF_RETURN_IF_ERROR(GetNodeAttr(attrs, "Tidx", &itype));
if (itype != DT_INT32) {
return absl::UnimplementedError(
"ReverseV2Grad for int64 index are not supported.");
}
*g = FDH::Define(
// Arg defs
{"x: T", "d: int32", "dy: T"},
// Ret val defs
{"dx: T", "dd: int32"},
// Attr defs
{"T: type", "Tidx: {int32, int64}"},
// Nodes
{
{{"dx"}, "ReverseV2", {"dy", "d"}, {{"T", "$T"}}},
{{"dd"}, "ZerosLike", {"d"}, {{"T", "$Tidx"}}},
});
VLOG(1) << "ReverseGrad " << DebugString(*g);
return absl::OkStatus();
}
REGISTER_OP_GRADIENT("ReverseV2", ReverseV2Grad);
absl::Status SliceGrad(const AttrSlice& attrs, FunctionDef* g) {
DataType itype;
TF_RETURN_IF_ERROR(GetNodeAttr(attrs, "Index", &itype));
if (itype != DT_INT32) {
return absl::UnimplementedError(
"SliceGrad for int64 index are not supported.");
}
*g = FDH::Define(
// Arg defs
{"x: T", "begin: int32", "size: int32", "dy: T"},
// Ret val defs
{"dx: T", "begin_grad: int32", "size_grad: int32"},
// Attr defs
{"T: type"},
// Nodes
{// paddings = concat(1, [begin, shape(x) - begin - size])
FDH::Const("one", 1),
{{"b1"}, "ExpandDims", {"begin", "one"}, {{"T", DT_INT32}}},
{{"xs"}, "Shape", {"x"}, {{"T", "$T"}}},
{{"xs_b"}, "Sub", {"xs", "begin"}, {{"T", DT_INT32}}},
{{"xs_b_s"}, "Sub", {"xs_b", "size"}, {{"T", DT_INT32}}},
{{"a1"}, "ExpandDims", {"xs_b_s", "one"}, {{"T", DT_INT32}}},
{{"paddings"},
"Concat",
{"one", "b1", "a1"},
{{"N", 2}, {"T", DT_INT32}}},
// dx = Pad(dy, paddings)
{{"dx"}, "Pad", {"dy", "paddings"}, {{"T", "$T"}}},
{{"begin_grad"}, "ZerosLike", {"begin"}, {{"T", DT_INT32}}},
{{"size_grad"}, "ZerosLike", {"size"}, {{"T", DT_INT32}}}});
VLOG(1) << "SliceGrad " << DebugString(*g);
return absl::OkStatus();
}
REGISTER_OP_GRADIENT("Slice", SliceGrad);
absl::Status StridedSliceGrad(const AttrSlice& attrs, FunctionDef* g) {
DataType itype;
TF_RETURN_IF_ERROR(GetNodeAttr(attrs, "Index", &itype));
if (itype != DT_INT32) {
return absl::UnimplementedError(
"SliceGrad for int64 index are not supported.");
}
*g = FDH::Define(
// Arg defs
{"x: T", "begin: int32", "end: int32", "stride: int32", "dy: T"},
// Ret val defs
{"dx: T", "begin_grad: int32", "end_grad: int32", "stride_grad: int32"},
// Attr defs
{"T: type", "Index: {int32, int64}", "begin_mask: int", "end_mask: int",
"ellipsis_mask: int", "new_axis_mask: int", "shrink_axis_mask: int"},
{// Nodes
{{{"xs"}, "Shape", {"x"}, {{"T", "$T"}}},
{{"dx"},
"StridedSliceGrad",
{"xs", "begin", "end", "stride", "dy"},
{{"T", "$T"},
{"Index", "$Index"},
{"begin_mask", "$begin_mask"},
{"end_mask", "$end_mask"},
{"ellipsis_mask", "$ellipsis_mask"},
{"new_axis_mask", "$new_axis_mask"},
{"shrink_axis_mask", "$shrink_axis_mask"}}},
{{"begin_grad"}, "ZerosLike", {"begin"}, {{"T", DT_INT32}}},
{{"end_grad"}, "ZerosLike", {"end"}, {{"T", DT_INT32}}},
{{"stride_grad"}, "ZerosLike", {"stride"}, {{"T", DT_INT32}}}}});
VLOG(1) << "StridedSliceGrad " << DebugString(*g);
return absl::OkStatus();
}
REGISTER_OP_GRADIENT("StridedSlice", StridedSliceGrad);
absl::Status StridedSliceGradGrad(const AttrSlice& attrs, FunctionDef* g) {
DataType itype;
TF_RETURN_IF_ERROR(GetNodeAttr(attrs, "Index", &itype));
if (itype != DT_INT32) {
return absl::UnimplementedError(
"SliceGrad for int64 index are not supported.");
}
// TODO(aselle): Shouldn't the int32 tensors return zeros of shape like
// dy_grad?
// I'm following slice's behavior for now.
*g = FDH::Define(
// Arg defs
{"shape: int32", "begin: int32", "end: int32", "stride: int32", "dy: T",
"grad: T"},
// Ret val defs
{"shape_grad: int32", "begin_grad: int32", "end_grad: int32",
"stride_grad: int32", "dy_grad: T"},
// Attr defs
{"T: type", "Index: {int32, int64}", "begin_mask: int", "end_mask: int",
"ellipsis_mask: int", "new_axis_mask: int", "shrink_axis_mask: int"},
{// Nodes
{{{"shape_grad"}, "ZerosLike", {"shape"}, {{"T", DT_INT32}}},
{{"begin_grad"}, "ZerosLike", {"begin"}, {{"T", DT_INT32}}},
{{"end_grad"}, "ZerosLike", {"end"}, {{"T", DT_INT32}}},
{{"stride_grad"}, "ZerosLike", {"stride"}, {{"T", DT_INT32}}},
{{"dy_grad"},
"StridedSlice",
{"grad", "begin", "end", "stride"},
{{"T", "$T"},
{"Index", "$Index"},
{"begin_mask", "$begin_mask"},
{"end_mask", "$end_mask"},
{"ellipsis_mask", "$ellipsis_mask"},
{"new_axis_mask", "$new_axis_mask"},
{"shrink_axis_mask", "$shrink_axis_mask"}}}}});
VLOG(1) << "StridedSliceGrad " << DebugString(*g);
return absl::OkStatus();
}
REGISTER_OP_GRADIENT("StridedSliceGrad", StridedSliceGradGrad);
absl::Status BroadcastToGrad(const AttrSlice& attrs, FunctionDef* g) {
DataType itype;
TF_RETURN_IF_ERROR(GetNodeAttr(attrs, "Tidx", &itype));
if (itype != DT_INT32) {
return absl::UnimplementedError(
"BroadcastToGrad for int64 index are not supported.");
}
std::vector<FDH::Node> nodes = {
{{"sx"}, "Shape", {"x"}, {{"T", "$T"}}},
{{"rx", "ry"}, "BroadcastGradientArgs", {"sx", "shape"}},
{{"sum_gx"}, "Sum", {"dy", "rx"}, {{"T", "$T"}}},
{{"dx"}, "Reshape", {"sum_gx", "sx"}, {{"T", "$T"}}},
{{"dshape"}, "ZerosLike", {"shape"}, {{"T", "$Tidx"}}}};
*g = FDH::Define(
// Arg defs
{"x: T", "shape: int32", "dy: T"},
// Ret val defs
{"dx: T", "dshape: Tidx"},
// Attr defs
{{"T: type"}, {"Tidx: {int32, int64}"}},
// Nodes
nodes);
return absl::OkStatus();
}
REGISTER_OP_GRADIENT("BroadcastTo", BroadcastToGrad);
} // end namespace tensorflow
+807
View File
@@ -0,0 +1,807 @@
/* 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.
==============================================================================*/
#include <memory>
#include <vector>
#include "tensorflow/core/framework/function_testlib.h"
#include "tensorflow/core/framework/tensor_testutil.h"
#include "tensorflow/core/platform/test.h"
#include "tensorflow/core/public/session.h"
namespace tensorflow {
namespace {
namespace f = test::function;
using FDH = FunctionDefHelper;
std::unique_ptr<Session> NewSession() {
SessionOptions opts;
(*opts.config.mutable_device_count())["CPU"] = 1;
return std::unique_ptr<Session>(NewSession(opts));
}
std::vector<Tensor> PackGrad(const Tensor& x0, const Tensor& x1,
const Tensor& dy, int axis) {
auto T = DT_FLOAT;
auto gdef = test::function::GDef(
{f::NDef("x0", "Placeholder", {}, {{"dtype", T}}),
f::NDef("x1", "Placeholder", {}, {{"dtype", T}}),
f::NDef("axis", "Placeholder", {}, {{"dtype", DT_INT32}}),
f::NDef("dy", "Placeholder", {}, {{"dtype", T}}),
f::NDef("dx", "SymbolicGradient", {"x0", "x1", "dy"},
{{"f", FDH::FunctionRef("Pack",
{{"N", 2}, {"T", T}, {"axis", axis}})},
{"Tin", DataTypeSlice{T, T, T}},
{"Tout", DataTypeSlice{T, T}}})});
VLOG(1) << DebugStringWhole(gdef);
auto sess = NewSession();
TF_CHECK_OK(sess->Create(gdef));
std::vector<Tensor> out;
TF_CHECK_OK(sess->Run({{"x0:0", x0},
{"x1:0", x1},
{"axis:0", test::AsScalar(axis)},
{"dy:0", dy}},
{"dx:0", "dx:1"}, {}, &out));
CHECK_EQ(out.size(), 2);
TF_CHECK_OK(sess->Close());
return out;
}
TEST(ArrayGradTest, PackGrad) {
Tensor x0(DT_FLOAT, {2, 3});
x0.flat<float>().setZero();
Tensor x1(DT_FLOAT, {2, 3});
x1.flat<float>().setZero();
Tensor dy(DT_FLOAT, {2, 2, 3});
test::FillIota<float>(&dy, 0);
auto dx = PackGrad(x0, x1, dy, 0);
test::ExpectClose(dx[0],
test::AsTensor<float>({0., 1., 2., 3., 4., 5.}, {2, 3}));
test::ExpectClose(dx[1],
test::AsTensor<float>({6., 7., 8., 9., 10., 11.}, {2, 3}));
}
std::vector<Tensor> UnpackGrad(const Tensor& x, const Tensor& dy0,
const Tensor& dy1, int axis) {
auto T = DT_FLOAT;
auto gdef = test::function::GDef(
{f::NDef("x", "Placeholder", {}, {{"dtype", T}}),
f::NDef("axis", "Placeholder", {}, {{"dtype", DT_INT32}}),
f::NDef("dy0", "Placeholder", {}, {{"dtype", T}}),
f::NDef("dy1", "Placeholder", {}, {{"dtype", T}}),
f::NDef("dx", "SymbolicGradient", {"x", "dy0", "dy1"},
{{"f", FDH::FunctionRef("Unpack",
{{"num", 2}, {"T", T}, {"axis", axis}})},
{"Tin", DataTypeSlice{T, T, T}},
{"Tout", DataTypeSlice{T}}})});
VLOG(1) << DebugStringWhole(gdef);
auto sess = NewSession();
TF_CHECK_OK(sess->Create(gdef));
std::vector<Tensor> out;
TF_CHECK_OK(sess->Run({{"x:0", x},
{"axis:0", test::AsScalar(axis)},
{"dy0:0", dy0},
{"dy1:0", dy1}},
{"dx:0"}, {}, &out));
CHECK_EQ(out.size(), 1);
TF_CHECK_OK(sess->Close());
return out;
}
TEST(ArrayGradTest, UnpackGrad) {
Tensor x(DT_FLOAT, {2, 2, 3});
x.flat<float>().setZero();
Tensor dy0(DT_FLOAT, {2, 3});
Tensor dy1(DT_FLOAT, {2, 3});
test::FillIota<float>(&dy0, 0);
test::FillIota<float>(&dy1, 100);
auto dx = UnpackGrad(x, dy0, dy1, 0);
test::ExpectClose(dx[0], test::AsTensor<float>({0., 1., 2., 3., 4., 5., 100.,
101., 102., 103., 104., 105.},
{2, 2, 3}));
}
std::vector<Tensor> ConcatGrad(int dim, const Tensor& x0, const Tensor& x1,
const Tensor& dy) {
auto T = DT_FLOAT;
auto gdef = test::function::GDef(
{f::NDef("dim", "Placeholder", {}, {{"dtype", DT_INT32}}),
f::NDef("x0", "Placeholder", {}, {{"dtype", T}}),
f::NDef("x1", "Placeholder", {}, {{"dtype", T}}),
f::NDef("dy", "Placeholder", {}, {{"dtype", T}}),
f::NDef("dx", "SymbolicGradient", {"dim", "x0", "x1", "dy"},
{{"f", FDH::FunctionRef("Concat", {{"N", 2}, {"T", T}})},
{"Tin", DataTypeSlice{DT_INT32, T, T, T}},
{"Tout", DataTypeSlice{DT_INT32, T, T}}})});
VLOG(1) << DebugStringWhole(gdef);
auto sess = NewSession();
TF_CHECK_OK(sess->Create(gdef));
std::vector<Tensor> out;
TF_CHECK_OK(sess->Run(
{{"dim", test::AsScalar(dim)}, {"x0:0", x0}, {"x1:0", x1}, {"dy:0", dy}},
{"dx:0", "dx:1", "dx:2"}, {}, &out));
CHECK_EQ(out.size(), 3);
TF_CHECK_OK(sess->Close());
return out;
}
std::vector<Tensor> ConcatGradV2(int dim, const Tensor& x0, const Tensor& x1,
const Tensor& dy) {
auto T = DT_FLOAT;
auto gdef = test::function::GDef(
{f::NDef("x0", "Placeholder", {}, {{"dtype", T}}),
f::NDef("x1", "Placeholder", {}, {{"dtype", T}}),
f::NDef("dim", "Placeholder", {}, {{"dtype", DT_INT32}}),
f::NDef("dy", "Placeholder", {}, {{"dtype", T}}),
f::NDef("dx", "SymbolicGradient", {"x0", "x1", "dim", "dy"},
{{"f", FDH::FunctionRef("ConcatV2", {{"N", 2}, {"T", T}})},
{"Tin", DataTypeSlice{T, T, DT_INT32, T}},
{"Tout", DataTypeSlice{T, T, DT_INT32}}})});
VLOG(1) << DebugStringWhole(gdef);
auto sess = NewSession();
TF_CHECK_OK(sess->Create(gdef));
std::vector<Tensor> out;
TF_CHECK_OK(sess->Run(
{{"x0:0", x0}, {"x1:0", x1}, {"dim", test::AsScalar(dim)}, {"dy:0", dy}},
{"dx:0", "dx:1", "dx:2"}, {}, &out));
CHECK_EQ(out.size(), 3);
TF_CHECK_OK(sess->Close());
return out;
}
TEST(ArrayGradTest, ConcatGrad) {
Tensor x0(DT_FLOAT, {2, 3, 5});
x0.flat<float>().setZero();
Tensor x1(DT_FLOAT, {2, 1, 5});
x1.flat<float>().setZero();
Tensor dy(DT_FLOAT, {2, 4, 5});
test::FillIota<float>(&dy, 0);
// Test Concat.
auto dx = ConcatGrad(1, x0, x1, dy);
test::ExpectTensorEqual<int32_t>(dx[0], test::AsScalar(0));
test::ExpectClose(
dx[1],
test::AsTensor<float>({0., 1., 2., 3., 4., 5., 6., 7., 8., 9.,
10., 11., 12., 13., 14., 20., 21., 22., 23., 24.,
25., 26., 27., 28., 29., 30., 31., 32., 33., 34.},
{2, 3, 5}));
test::ExpectClose(dx[2], test::AsTensor<float>({15., 16., 17., 18., 19., 35.,
36., 37., 38., 39.},
{2, 1, 5}));
// Test ConcatV2 with positive concat axis.
dx = ConcatGradV2(1, x0, x1, dy);
test::ExpectTensorEqual<int32_t>(dx[dx.size() - 1], test::AsScalar(0));
test::ExpectClose(
dx[0],
test::AsTensor<float>({0., 1., 2., 3., 4., 5., 6., 7., 8., 9.,
10., 11., 12., 13., 14., 20., 21., 22., 23., 24.,
25., 26., 27., 28., 29., 30., 31., 32., 33., 34.},
{2, 3, 5}));
test::ExpectClose(dx[1], test::AsTensor<float>({15., 16., 17., 18., 19., 35.,
36., 37., 38., 39.},
{2, 1, 5}));
// Test ConcatV2 with negative concat axis.
dx = ConcatGradV2(-2, x0, x1, dy);
test::ExpectTensorEqual<int32_t>(dx[dx.size() - 1], test::AsScalar(0));
test::ExpectClose(
dx[0],
test::AsTensor<float>({0., 1., 2., 3., 4., 5., 6., 7., 8., 9.,
10., 11., 12., 13., 14., 20., 21., 22., 23., 24.,
25., 26., 27., 28., 29., 30., 31., 32., 33., 34.},
{2, 3, 5}));
test::ExpectClose(dx[1], test::AsTensor<float>({15., 16., 17., 18., 19., 35.,
36., 37., 38., 39.},
{2, 1, 5}));
}
std::vector<Tensor> SplitGrad(int dim, const Tensor& x, const Tensor& dy0,
const Tensor& dy1) {
auto T = DT_FLOAT;
auto gdef = test::function::GDef(
{f::NDef("dim", "Placeholder", {}, {{"dtype", DT_INT32}}),
f::NDef("x", "Placeholder", {}, {{"dtype", T}}),
f::NDef("dy0", "Placeholder", {}, {{"dtype", T}}),
f::NDef("dy1", "Placeholder", {}, {{"dtype", T}}),
f::NDef("dx", "SymbolicGradient", {"dim", "x", "dy0", "dy1"},
{{"f", FDH::FunctionRef(
"Split",
{{"split_dim", dim}, {"num_split", 2}, {"T", T}})},
{"Tin", DataTypeSlice{DT_INT32, T, T, T}},
{"Tout", DataTypeSlice{DT_INT32, T}}})});
VLOG(1) << DebugStringWhole(gdef);
auto sess = NewSession();
TF_CHECK_OK(sess->Create(gdef));
std::vector<Tensor> out;
TF_CHECK_OK(sess->Run({{"dim", test::AsScalar(dim)},
{"x:0", x},
{"dy0:0", dy0},
{"dy1:0", dy1}},
{"dx:0", "dx:1"}, {}, &out));
CHECK_EQ(out.size(), 2);
TF_CHECK_OK(sess->Close());
return out;
}
std::vector<Tensor> SplitVGrad(const Tensor& x, const Tensor& size_splits,
int dim, const Tensor& dy0, const Tensor& dy1) {
auto T = DT_FLOAT;
auto Tlen = DT_INT64;
auto gdef = test::function::GDef(
{f::NDef("x", "Placeholder", {}, {{"dtype", T}}),
f::NDef("size_splits", "Placeholder", {}, {{"dtype", Tlen}}),
f::NDef("dim", "Placeholder", {}, {{"dtype", DT_INT32}}),
f::NDef("dy0", "Placeholder", {}, {{"dtype", T}}),
f::NDef("dy1", "Placeholder", {}, {{"dtype", T}}),
f::NDef("dx", "SymbolicGradient",
{"x", "size_splits", "dim", "dy0", "dy1"},
{{"f", FDH::FunctionRef("SplitV", {{"split_dim", dim},
{"num_split", 2},
{"T", T},
{"Tlen", Tlen}})},
{"Tin", DataTypeSlice{T, Tlen, DT_INT32, T, T}},
{"Tout", DataTypeSlice{T, Tlen, DT_INT32}}})});
VLOG(1) << DebugStringWhole(gdef);
auto sess = NewSession();
TF_CHECK_OK(sess->Create(gdef));
std::vector<Tensor> out;
TF_CHECK_OK(sess->Run({{"x:0", x},
{"size_splits:0", size_splits},
{"dim", test::AsScalar(dim)},
{"dy0:0", dy0},
{"dy1:0", dy1}},
{"dx:0", "dx:1", "dx:2"}, {}, &out));
CHECK_EQ(out.size(), 3);
TF_CHECK_OK(sess->Close());
return out;
}
TEST(ArrayGradTest, SplitGrad) {
Tensor x(DT_FLOAT, {2, 4, 5});
x.flat<float>().setZero();
Tensor dy0(DT_FLOAT, {2, 2, 5});
Tensor dy1(DT_FLOAT, {2, 2, 5});
test::FillIota<float>(&dy0, 0);
test::FillIota<float>(&dy1, 100);
auto expected_dx = test::AsTensor<float>(
{0., 1., 2., 3., 4., 5., 6., 7., 8., 9.,
100., 101., 102., 103., 104., 105., 106., 107., 108., 109.,
10., 11., 12., 13., 14., 15., 16., 17., 18., 19.,
110., 111., 112., 113., 114., 115., 116., 117., 118., 119.},
{2, 4, 5});
auto expected_d_dim = test::AsScalar(0);
// SplitGrad
{
auto dx = SplitGrad(1, x, dy0, dy1);
test::ExpectTensorEqual<int32_t>(dx[0], expected_d_dim);
test::ExpectClose(dx[1], expected_dx);
}
// SplitVGrad
{
Tensor size_splits(DT_INT64, {2});
size_splits.flat<int64_t>().setConstant(2);
auto expected_d_size_splits = test::AsTensor<int64_t>({0, 0}, {2});
auto dx = SplitVGrad(x, size_splits, 1, dy0, dy1);
test::ExpectClose(dx[0], expected_dx);
test::ExpectTensorEqual<int64_t>(dx[1], expected_d_size_splits);
test::ExpectTensorEqual<int32_t>(dx[2], expected_d_dim);
}
}
std::vector<Tensor> ReshapeGrad(const Tensor& x, const Tensor& s,
const Tensor& dy) {
auto T = DT_FLOAT;
auto gdef = test::function::GDef(
{f::NDef("x", "Placeholder", {}, {{"dtype", T}}),
f::NDef("s", "Placeholder", {}, {{"dtype", DT_INT32}}),
f::NDef("dy", "Placeholder", {}, {{"dtype", T}}),
f::NDef("dx", "SymbolicGradient", {"x", "s", "dy"},
{{"f", FDH::FunctionRef("Reshape", {{"T", T}})},
{"Tin", DataTypeSlice{T, DT_INT32, T}},
{"Tout", DataTypeSlice{T, DT_INT32}}})});
VLOG(1) << DebugStringWhole(gdef);
auto sess = NewSession();
TF_CHECK_OK(sess->Create(gdef));
std::vector<Tensor> out;
TF_CHECK_OK(sess->Run({{"x:0", x}, {"s:0", s}, {"dy:0", dy}},
{"dx:0", "dx:1"}, {}, &out));
CHECK_EQ(out.size(), 2);
TF_CHECK_OK(sess->Close());
return out;
}
TEST(ArrayGradTest, ReshapeGrad) {
Tensor x(DT_FLOAT, {2, 4, 5});
x.flat<float>().setZero();
auto s = test::AsTensor<int32_t>({8, 5});
Tensor dy(DT_FLOAT, {8, 5});
test::FillIota<float>(&dy, 73);
auto dx = ReshapeGrad(x, s, dy);
test::ExpectClose(
dx[0], test::AsTensor<float>(
{73., 74., 75., 76., 77., 78., 79., 80., 81., 82.,
83., 84., 85., 86., 87., 88., 89., 90., 91., 92.,
93., 94., 95., 96., 97., 98., 99., 100., 101., 102.,
103., 104., 105., 106., 107., 108., 109., 110., 111., 112.},
{2, 4, 5}));
test::ExpectTensorEqual<int32_t>(dx[1], test::AsTensor<int32_t>({0, 0}));
}
std::vector<Tensor> ExpandDimsGrad(const Tensor& x, const Tensor& s,
const Tensor& dy) {
auto T = DT_FLOAT;
auto gdef = test::function::GDef(
{f::NDef("x", "Placeholder", {}, {{"dtype", T}}),
f::NDef("s", "Placeholder", {}, {{"dtype", DT_INT32}}),
f::NDef("dy", "Placeholder", {}, {{"dtype", T}}),
f::NDef("dx", "SymbolicGradient", {"x", "s", "dy"},
{{"f", FDH::FunctionRef("ExpandDims", {{"T", T}})},
{"Tin", DataTypeSlice{T, DT_INT32, T}},
{"Tout", DataTypeSlice{T, DT_INT32}}})});
VLOG(1) << DebugStringWhole(gdef);
auto sess = NewSession();
TF_CHECK_OK(sess->Create(gdef));
std::vector<Tensor> out;
TF_CHECK_OK(sess->Run({{"x:0", x}, {"s:0", s}, {"dy:0", dy}},
{"dx:0", "dx:1"}, {}, &out));
CHECK_EQ(out.size(), 2);
TF_CHECK_OK(sess->Close());
return out;
}
TEST(ArrayGradTest, ExpandDimsGrad) {
Tensor x(DT_FLOAT, {2, 4, 5});
x.flat<float>().setZero();
auto s = test::AsTensor<int32_t>({1});
Tensor dy(DT_FLOAT, {2, 1, 4, 5});
test::FillIota<float>(&dy, 73);
auto dx = ExpandDimsGrad(x, s, dy);
test::ExpectClose(
dx[0], test::AsTensor<float>(
{73., 74., 75., 76., 77., 78., 79., 80., 81., 82.,
83., 84., 85., 86., 87., 88., 89., 90., 91., 92.,
93., 94., 95., 96., 97., 98., 99., 100., 101., 102.,
103., 104., 105., 106., 107., 108., 109., 110., 111., 112.},
{2, 4, 5}));
test::ExpectTensorEqual<int32_t>(dx[1], test::AsTensor<int32_t>({0}));
}
std::vector<Tensor> SqueezeGrad(const Tensor& x, const Tensor& dy) {
auto T = DT_FLOAT;
auto gdef = test::function::GDef(
{f::NDef("x", "Placeholder", {}, {{"dtype", T}}),
f::NDef("dy", "Placeholder", {}, {{"dtype", T}}),
f::NDef("dx", "SymbolicGradient", {"x", "dy"},
{{"f", FDH::FunctionRef("Squeeze", {{"T", T}})},
{"Tin", DataTypeSlice{T, T}},
{"Tout", DataTypeSlice{T}}})});
VLOG(1) << DebugStringWhole(gdef);
auto sess = NewSession();
TF_CHECK_OK(sess->Create(gdef));
std::vector<Tensor> out;
TF_CHECK_OK(sess->Run({{"x:0", x}, {"dy:0", dy}}, {"dx:0"}, {}, &out));
CHECK_EQ(out.size(), 1);
TF_CHECK_OK(sess->Close());
return out;
}
TEST(ArrayGradTest, SqueezeGrad) {
Tensor x(DT_FLOAT, {2, 1, 3});
x.flat<float>().setZero();
Tensor dy(DT_FLOAT, {2, 3});
test::FillIota<float>(&dy, 1);
auto dx = SqueezeGrad(x, dy);
test::ExpectClose(dx[0],
test::AsTensor<float>({1., 2., 3., 4., 5., 6.}, {2, 1, 3}));
}
std::vector<Tensor> TransposeGrad(const Tensor& x, const Tensor& p,
const Tensor& dy) {
auto T = DT_FLOAT;
auto gdef = test::function::GDef(
{f::NDef("x", "Placeholder", {}, {{"dtype", T}}),
f::NDef("p", "Placeholder", {}, {{"dtype", DT_INT32}}),
f::NDef("dy", "Placeholder", {}, {{"dtype", T}}),
f::NDef("dx", "SymbolicGradient", {"x", "p", "dy"},
{{"f", FDH::FunctionRef("Transpose", {{"T", T}})},
{"Tin", DataTypeSlice{T, DT_INT32, T}},
{"Tout", DataTypeSlice{T, DT_INT32}}})});
VLOG(1) << DebugStringWhole(gdef);
auto sess = NewSession();
TF_CHECK_OK(sess->Create(gdef));
std::vector<Tensor> out;
TF_CHECK_OK(sess->Run({{"x:0", x}, {"p:0", p}, {"dy:0", dy}},
{"dx:0", "dx:1"}, {}, &out));
CHECK_EQ(out.size(), 2);
TF_CHECK_OK(sess->Close());
return out;
}
TEST(ArrayGradTest, TransposeGrad) {
Tensor x(DT_FLOAT, {2, 4, 5});
x.flat<float>().setZero();
auto p = test::AsTensor<int32_t>({2, 0, 1});
Tensor dy(DT_FLOAT, {5, 2, 4});
test::FillIota<float>(&dy, 0);
auto dx = TransposeGrad(x, p, dy);
test::ExpectClose(dx[0], test::AsTensor<float>(
{0., 8., 16., 24., 32., 1., 9., 17., 25., 33.,
2., 10., 18., 26., 34., 3., 11., 19., 27., 35.,
4., 12., 20., 28., 36., 5., 13., 21., 29., 37.,
6., 14., 22., 30., 38., 7., 15., 23., 31., 39.},
{2, 4, 5}));
test::ExpectTensorEqual<int32_t>(dx[1], test::AsTensor<int32_t>({0, 0, 0}));
}
std::vector<Tensor> ReverseGrad(const Tensor& x, const Tensor& dims,
const Tensor& dy) {
auto T = DT_FLOAT;
auto gdef = test::function::GDef(
{f::NDef("x", "Placeholder", {}, {{"dtype", T}}),
f::NDef("dims", "Placeholder", {}, {{"dtype", DT_BOOL}}),
f::NDef("dy", "Placeholder", {}, {{"dtype", T}}),
f::NDef("dx", "SymbolicGradient", {"x", "dims", "dy"},
{{"f", FDH::FunctionRef("Reverse", {{"T", T}})},
{"Tin", DataTypeSlice{T, DT_BOOL, T}},
{"Tout", DataTypeSlice{T, DT_BOOL}}})});
VLOG(1) << DebugStringWhole(gdef);
auto sess = NewSession();
TF_CHECK_OK(sess->Create(gdef));
std::vector<Tensor> out;
TF_CHECK_OK(sess->Run({{"x:0", x}, {"dims:0", dims}, {"dy:0", dy}},
{"dx:0", "dx:1"}, {}, &out));
CHECK_EQ(out.size(), 2);
TF_CHECK_OK(sess->Close());
return out;
}
TEST(ArrayGradTest, ReverseGrad) {
Tensor x(DT_FLOAT, {2, 3});
x.flat<float>().setZero();
auto dims = test::AsTensor<bool>({false, true});
Tensor dy(DT_FLOAT, {2, 3});
test::FillIota<float>(&dy, 1);
auto dx = ReverseGrad(x, dims, dy);
test::ExpectClose(dx[0],
test::AsTensor<float>({3., 2., 1., 6., 5., 4.}, {2, 3}));
test::ExpectTensorEqual<bool>(dx[1], test::AsTensor<bool>({false, false}));
}
std::vector<Tensor> ReverseV2Grad(const Tensor& x, const Tensor& axis,
const Tensor& dy) {
auto T = DT_FLOAT;
auto Tidx = DT_INT32;
auto gdef = test::function::GDef(
{f::NDef("x", "Placeholder", {}, {{"dtype", T}}),
f::NDef("axis", "Placeholder", {}, {{"dtype", DT_INT32}}),
f::NDef("dy", "Placeholder", {}, {{"dtype", T}}),
f::NDef(
"dx", "SymbolicGradient", {"x", "axis", "dy"},
{{"f", FDH::FunctionRef("ReverseV2", {{"T", T}, {"Tidx", Tidx}})},
{"Tin", DataTypeSlice{T, DT_INT32, T}},
{"Tout", DataTypeSlice{T, DT_INT32}}})});
VLOG(1) << DebugStringWhole(gdef);
auto sess = NewSession();
TF_CHECK_OK(sess->Create(gdef));
std::vector<Tensor> out;
TF_CHECK_OK(sess->Run({{"x:0", x}, {"axis:0", axis}, {"dy:0", dy}},
{"dx:0", "dx:1"}, {}, &out));
CHECK_EQ(out.size(), 2);
TF_CHECK_OK(sess->Close());
return out;
}
TEST(ArrayGradTest, ReverseV2Grad) {
Tensor x(DT_FLOAT, {2, 3});
x.flat<float>().setZero();
auto axis = test::AsTensor<int32_t>({1});
Tensor dy(DT_FLOAT, {2, 3});
test::FillIota<float>(&dy, 1);
auto dx = ReverseV2Grad(x, axis, dy);
test::ExpectTensorEqual<float>(
dx[0], test::AsTensor<float>({3., 2., 1., 6., 5., 4.}, {2, 3}));
test::ExpectTensorEqual<int32_t>(dx[1], test::AsTensor<int32_t>({0}));
}
std::vector<Tensor> SliceGrad(const Tensor& x, const Tensor& b, const Tensor& s,
const Tensor& dy) {
auto T = DT_FLOAT;
auto gdef = test::function::GDef(
{f::NDef("x", "Placeholder", {}, {{"dtype", T}}),
f::NDef("b", "Placeholder", {}, {{"dtype", DT_INT32}}),
f::NDef("s", "Placeholder", {}, {{"dtype", DT_INT32}}),
f::NDef("dy", "Placeholder", {}, {{"dtype", T}}),
f::NDef(
"dx", "SymbolicGradient", {"x", "b", "s", "dy"},
{{"f", FDH::FunctionRef("Slice", {{"T", T}, {"Index", DT_INT32}})},
{"Tin", DataTypeSlice{T, DT_INT32, DT_INT32, T}},
{"Tout", DataTypeSlice{T, DT_INT32, DT_INT32}}})});
VLOG(1) << DebugStringWhole(gdef);
auto sess = NewSession();
TF_CHECK_OK(sess->Create(gdef));
std::vector<Tensor> out;
TF_CHECK_OK(sess->Run({{"x:0", x}, {"b:0", b}, {"s:0", s}, {"dy:0", dy}},
{"dx:0", "dx:1", "dx:2"}, {}, &out));
CHECK_EQ(out.size(), 3);
TF_CHECK_OK(sess->Close());
return out;
}
TEST(ArrayGradTest, SliceGrad) {
Tensor x(DT_FLOAT, {2, 3, 4});
x.flat<float>().setZero();
auto begin = test::AsTensor<int32_t>({1, 1, 1});
auto size = test::AsTensor<int32_t>({1, 2, 2});
Tensor dy(DT_FLOAT, {1, 2, 2});
test::FillIota<float>(&dy, 1);
auto dx = SliceGrad(x, begin, size, dy);
test::ExpectClose(dx[0],
test::AsTensor<float>(
{
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 1., 2., 0., 0., 3., 4., 0.,
},
{2, 3, 4}));
test::ExpectTensorEqual<int32_t>(dx[1], test::AsTensor<int32_t>({0, 0, 0}));
test::ExpectTensorEqual<int32_t>(dx[2], test::AsTensor<int32_t>({0, 0, 0}));
}
std::vector<Tensor> StridedSliceGrad(const Tensor& x, const Tensor& begin,
const Tensor& end, const Tensor& strides,
const Tensor& dy, int32_t begin_mask,
int32_t end_mask, int32_t ellipsis_mask,
int32_t new_axis_mask,
int32_t shrink_axis_mask) {
auto T = DT_FLOAT;
auto gdef = test::function::GDef(
{f::NDef("x", "Placeholder", {}, {{"dtype", T}}),
f::NDef("begin", "Placeholder", {}, {{"dtype", DT_INT32}}),
f::NDef("end", "Placeholder", {}, {{"dtype", DT_INT32}}),
f::NDef("strides", "Placeholder", {}, {{"dtype", DT_INT32}}),
f::NDef("dy", "Placeholder", {}, {{"dtype", T}}),
f::NDef(
"dx", "SymbolicGradient", {"x", "begin", "end", "strides", "dy"},
{{"f", FDH::FunctionRef("StridedSlice",
{
{"T", T},
{"Index", DT_INT32},
{"begin_mask", begin_mask},
{"end_mask", end_mask},
{"new_axis_mask", new_axis_mask},
{"shrink_axis_mask", shrink_axis_mask},
{"ellipsis_mask", ellipsis_mask},
})},
{"Tin", DataTypeSlice{T, DT_INT32, DT_INT32, DT_INT32, T}},
{"Tout", DataTypeSlice{T, DT_INT32, DT_INT32, DT_INT32}}})});
VLOG(1) << DebugStringWhole(gdef);
auto sess = NewSession();
TF_CHECK_OK(sess->Create(gdef));
std::vector<Tensor> out;
TF_CHECK_OK(sess->Run({{"x:0", x},
{"begin:0", begin},
{"end:0", end},
{"strides:0", strides},
{"dy:0", dy}},
{"dx:0", "dx:1", "dx:2", "dx:3"}, {}, &out));
CHECK_EQ(out.size(), 4);
TF_CHECK_OK(sess->Close());
return out;
}
std::vector<Tensor> StridedSliceGradGrad(
const Tensor& shape, const Tensor& begin, const Tensor& end,
const Tensor& strides, const Tensor& dy, const Tensor& grad,
int32_t begin_mask, int32_t end_mask, int32_t ellipsis_mask,
int32_t new_axis_mask, int32_t shrink_axis_mask) {
auto T = DT_FLOAT;
auto gdef = test::function::GDef(
{f::NDef("shape", "Placeholder", {}, {{"dtype", DT_INT32}}),
f::NDef("begin", "Placeholder", {}, {{"dtype", DT_INT32}}),
f::NDef("end", "Placeholder", {}, {{"dtype", DT_INT32}}),
f::NDef("strides", "Placeholder", {}, {{"dtype", DT_INT32}}),
f::NDef("dy", "Placeholder", {}, {{"dtype", T}}),
f::NDef("grad", "Placeholder", {}, {{"dtype", T}}),
f::NDef(
"dx", "SymbolicGradient",
{"shape", "begin", "end", "strides", "dy", "grad"},
{{"f", FDH::FunctionRef("StridedSliceGrad",
{
{"T", T},
{"Index", DT_INT32},
{"begin_mask", begin_mask},
{"end_mask", end_mask},
{"new_axis_mask", new_axis_mask},
{"shrink_axis_mask", shrink_axis_mask},
{"ellipsis_mask", ellipsis_mask},
})},
{"Tin",
DataTypeSlice{DT_INT32, DT_INT32, DT_INT32, DT_INT32, T, T}},
{"Tout",
DataTypeSlice{DT_INT32, DT_INT32, DT_INT32, DT_INT32, T}}})});
VLOG(1) << DebugStringWhole(gdef);
auto sess = NewSession();
TF_CHECK_OK(sess->Create(gdef));
std::vector<Tensor> out;
TF_CHECK_OK(sess->Run({{"shape:0", shape},
{"begin:0", begin},
{"end:0", end},
{"strides:0", strides},
{"dy:0", dy},
{"grad:0", grad}},
{"dx:0", "dx:1", "dx:2", "dx:3", "dx:4"}, {}, &out));
CHECK_EQ(out.size(), 5);
TF_CHECK_OK(sess->Close());
return out;
}
TEST(ArrayGradTest, StridedSliceGrad) {
Tensor x(DT_FLOAT, {2, 3, 4});
x.flat<float>().setZero();
Tensor x_shape = test::AsTensor<int32_t>({2, 3, 4}, {3});
{
auto start = test::AsTensor<int32_t>({1, 1, 1});
auto stop = test::AsTensor<int32_t>({2, 3, 3});
auto strides = test::AsTensor<int32_t>({1, 1, 1});
Tensor dy(DT_FLOAT, {1, 2, 2});
test::FillIota<float>(&dy, 1);
int begin_mask = 0, end_mask = 0, new_axis_mask = 0, shrink_axis_mask = 0,
ellipsis_mask = 0;
auto dx =
StridedSliceGrad(x, start, stop, strides, dy, begin_mask, end_mask,
ellipsis_mask, new_axis_mask, shrink_axis_mask);
test::ExpectClose(dx[0],
test::AsTensor<float>(
{
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 1., 2., 0., 0., 3., 4., 0.,
},
{2, 3, 4}));
test::ExpectTensorEqual<int32_t>(dx[1], test::AsTensor<int32_t>({0, 0, 0}));
test::ExpectTensorEqual<int32_t>(dx[2], test::AsTensor<int32_t>({0, 0, 0}));
auto ddx = StridedSliceGradGrad(x_shape, start, stop, strides, dy, dx[0],
begin_mask, end_mask, ellipsis_mask,
new_axis_mask, shrink_axis_mask);
test::ExpectClose(ddx[4], dy);
}
// test equivalent of python tf.gradients(foo[1:2, 1:3, 1:3])
{
auto start = test::AsTensor<int32_t>({1, 1, 1});
auto stop = test::AsTensor<int32_t>({2, 3, 3});
auto strides = test::AsTensor<int32_t>({1, 1, 1});
Tensor dy(DT_FLOAT, {1, 2, 2});
test::FillIota<float>(&dy, 1);
int begin_mask = 0, end_mask = 0, new_axis_mask = 0, shrink_axis_mask = 0,
ellipsis_mask = 0;
auto dx =
StridedSliceGrad(x, start, stop, strides, dy, begin_mask, end_mask,
ellipsis_mask, new_axis_mask, shrink_axis_mask);
test::ExpectClose(dx[0],
test::AsTensor<float>(
{
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 1., 2., 0., 0., 3., 4., 0.,
},
{2, 3, 4}));
test::ExpectTensorEqual<int32_t>(dx[1], test::AsTensor<int32_t>({0, 0, 0}));
test::ExpectTensorEqual<int32_t>(dx[2], test::AsTensor<int32_t>({0, 0, 0}));
auto ddx = StridedSliceGradGrad(x_shape, start, stop, strides, dy, dx[0],
begin_mask, end_mask, ellipsis_mask,
new_axis_mask, shrink_axis_mask);
test::ExpectClose(ddx[4], dy);
}
// test equivalent of python tf.gradients(foo[1, 1:, :-2, None])
{
int dontcare = 66;
auto start = test::AsTensor<int32_t>({1, 1, dontcare, dontcare});
auto stop = test::AsTensor<int32_t>({2, dontcare, -2, dontcare});
auto strides = test::AsTensor<int32_t>({1, 1, 1, dontcare});
Tensor dy(DT_FLOAT, {2, 2, 1});
test::FillIota<float>(&dy, 1);
int begin_mask = 4, end_mask = 2, new_axis_mask = 8, shrink_axis_mask = 1,
ellipsis_mask = 0;
auto dx =
StridedSliceGrad(x, start, stop, strides, dy, begin_mask, end_mask,
ellipsis_mask, new_axis_mask, shrink_axis_mask);
test::ExpectClose(dx[0],
test::AsTensor<float>(
{
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 1., 2., 0., 0., 3., 4., 0., 0.,
},
{2, 3, 4}));
test::ExpectTensorEqual<int32_t>(dx[1],
test::AsTensor<int32_t>({0, 0, 0, 0}));
test::ExpectTensorEqual<int32_t>(dx[2],
test::AsTensor<int32_t>({0, 0, 0, 0}));
auto ddx = StridedSliceGradGrad(x_shape, start, stop, strides, dy, dx[0],
begin_mask, end_mask, ellipsis_mask,
new_axis_mask, shrink_axis_mask);
test::ExpectClose(ddx[4], dy);
}
// test equivalent of tf.gradients(foo[1, ...]) i.e. foo[1, 0:3, 0:4]
{
int dontcare = 66;
auto start = test::AsTensor<int32_t>({1, dontcare});
auto stop = test::AsTensor<int32_t>({2, dontcare});
auto strides = test::AsTensor<int32_t>({1, 1});
Tensor dy(DT_FLOAT, {3, 4});
test::FillIota<float>(&dy, 1);
int begin_mask = 0, end_mask = 0, new_axis_mask = 0, shrink_axis_mask = 1,
ellipsis_mask = 2;
auto dx =
StridedSliceGrad(x, start, stop, strides, dy, begin_mask, end_mask,
ellipsis_mask, new_axis_mask, shrink_axis_mask);
test::ExpectClose(dx[0],
test::AsTensor<float>(
{
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12.,
},
{2, 3, 4}));
test::ExpectTensorEqual<int32_t>(dx[1], test::AsTensor<int32_t>({0, 0}));
test::ExpectTensorEqual<int32_t>(dx[2], test::AsTensor<int32_t>({0, 0}));
auto ddx = StridedSliceGradGrad(x_shape, start, stop, strides, dy, dx[0],
begin_mask, end_mask, ellipsis_mask,
new_axis_mask, shrink_axis_mask);
test::ExpectClose(ddx[4], dy);
}
}
std::vector<Tensor> BroadcastToGrad(const Tensor& x, const Tensor& shape,
const Tensor& dy) {
auto T = DT_FLOAT;
auto Tidx = DT_INT32;
auto gdef = test::function::GDef(
{f::NDef("x", "Placeholder", {}, {{"dtype", T}}),
f::NDef("shape", "Placeholder", {}, {{"dtype", Tidx}}),
f::NDef("dy", "Placeholder", {}, {{"dtype", T}}),
f::NDef(
"dx", "SymbolicGradient", {"x", "shape", "dy"},
{{"f", FDH::FunctionRef("BroadcastTo", {{"T", T}, {"Tidx", Tidx}})},
{"Tin", DataTypeSlice{T, Tidx, T}},
{"Tout", DataTypeSlice{T, Tidx}}})});
VLOG(1) << DebugStringWhole(gdef);
auto sess = NewSession();
TF_CHECK_OK(sess->Create(gdef));
std::vector<Tensor> out;
TF_CHECK_OK(sess->Run({{"x:0", x}, {"shape:0", shape}, {"dy:0", dy}},
{"dx:0", "dx:1"}, {}, &out));
CHECK_EQ(out.size(), 2);
TF_CHECK_OK(sess->Close());
return out;
}
TEST(ArrayGradTest, BroadcastToGrad) {
Tensor x(DT_FLOAT, {2, 2});
x.flat<float>().setZero();
Tensor shape(DT_INT32, {3});
test::FillValues<int32_t>(&shape, {2, 2, 2});
Tensor dy(DT_FLOAT, {2, 2, 2});
test::FillIota<float>(&dy, 0);
auto dx = BroadcastToGrad(x, shape, dy);
test::ExpectClose(dx[0], test::AsTensor<float>({4., 6., 8., 10.}, {2, 2}));
test::ExpectTensorEqual<int32_t>(dx[1],
test::AsTensor<int32_t>({0, 0, 0}, {3}));
}
} // namespace
} // namespace tensorflow
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+167
View File
@@ -0,0 +1,167 @@
/* 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.
==============================================================================*/
#include "tensorflow/core/framework/common_shape_fns.h"
#include "tensorflow/core/framework/op.h"
#include "tensorflow/core/framework/shape_inference.h"
#include "tensorflow/core/lib/core/bits.h"
#include "tensorflow/core/platform/errors.h"
namespace tensorflow {
namespace {
using shape_inference::DimensionHandle;
using shape_inference::InferenceContext;
using shape_inference::ShapeHandle;
absl::Status DecodeWavShapeFn(InferenceContext* c) {
ShapeHandle unused;
TF_RETURN_IF_ERROR(c->WithRank(c->input(0), 0, &unused));
DimensionHandle channels_dim;
int32_t desired_channels;
TF_RETURN_IF_ERROR(c->GetAttr("desired_channels", &desired_channels));
if (desired_channels == -1) {
channels_dim = c->UnknownDim();
} else {
if (desired_channels < 0) {
return absl::InvalidArgumentError(absl::StrCat(
"channels must be non-negative, got ", desired_channels));
}
channels_dim = c->MakeDim(desired_channels);
}
DimensionHandle samples_dim;
int32_t desired_samples;
TF_RETURN_IF_ERROR(c->GetAttr("desired_samples", &desired_samples));
if (desired_samples == -1) {
samples_dim = c->UnknownDim();
} else {
if (desired_samples < 0) {
return absl::InvalidArgumentError(
absl::StrCat("samples must be non-negative, got ", desired_samples));
}
samples_dim = c->MakeDim(desired_samples);
}
c->set_output(0, c->MakeShape({samples_dim, channels_dim}));
c->set_output(1, c->Scalar());
return absl::OkStatus();
}
absl::Status EncodeWavShapeFn(InferenceContext* c) {
ShapeHandle unused;
TF_RETURN_IF_ERROR(c->WithRank(c->input(0), 2, &unused));
TF_RETURN_IF_ERROR(c->WithRank(c->input(1), 0, &unused));
c->set_output(0, c->Scalar());
return absl::OkStatus();
}
absl::Status SpectrogramShapeFn(InferenceContext* c) {
ShapeHandle input;
TF_RETURN_IF_ERROR(c->WithRank(c->input(0), 2, &input));
int32_t window_size;
TF_RETURN_IF_ERROR(c->GetAttr("window_size", &window_size));
if (window_size <= 1) {
return absl::InvalidArgumentError(
absl::StrCat("window size must be > 1, got ", window_size));
}
int32_t stride;
TF_RETURN_IF_ERROR(c->GetAttr("stride", &stride));
if (stride <= 0) {
return absl::InvalidArgumentError(
absl::StrCat("stride must be strictly positive, got ", stride));
}
DimensionHandle input_length = c->Dim(input, 0);
DimensionHandle input_channels = c->Dim(input, 1);
DimensionHandle output_length;
if (!c->ValueKnown(input_length)) {
output_length = c->UnknownDim();
} else {
const int64_t input_length_value = c->Value(input_length);
const int64_t length_minus_window = (input_length_value - window_size);
int64_t output_length_value;
if (length_minus_window < 0) {
output_length_value = 0;
} else {
output_length_value = 1 + (length_minus_window / stride);
}
output_length = c->MakeDim(output_length_value);
}
DimensionHandle output_channels =
c->MakeDim(1 + NextPowerOfTwo(window_size) / 2);
c->set_output(0,
c->MakeShape({input_channels, output_length, output_channels}));
return absl::OkStatus();
}
absl::Status MfccShapeFn(InferenceContext* c) {
ShapeHandle spectrogram;
TF_RETURN_IF_ERROR(c->WithRank(c->input(0), 3, &spectrogram));
ShapeHandle unused;
TF_RETURN_IF_ERROR(c->WithRank(c->input(1), 0, &unused));
int32_t dct_coefficient_count;
TF_RETURN_IF_ERROR(
c->GetAttr("dct_coefficient_count", &dct_coefficient_count));
DimensionHandle spectrogram_channels = c->Dim(spectrogram, 0);
DimensionHandle spectrogram_length = c->Dim(spectrogram, 1);
DimensionHandle output_channels = c->MakeDim(dct_coefficient_count);
c->set_output(0, c->MakeShape({spectrogram_channels, spectrogram_length,
output_channels}));
return absl::OkStatus();
}
} // namespace
REGISTER_OP("DecodeWav")
.Input("contents: string")
.Attr("desired_channels: int = -1")
.Attr("desired_samples: int = -1")
.Output("audio: float")
.Output("sample_rate: int32")
.SetShapeFn(DecodeWavShapeFn);
REGISTER_OP("EncodeWav")
.Input("audio: float")
.Input("sample_rate: int32")
.Output("contents: string")
.SetShapeFn(EncodeWavShapeFn);
REGISTER_OP("AudioSpectrogram")
.Input("input: float")
.Attr("window_size: int")
.Attr("stride: int")
.Attr("magnitude_squared: bool = false")
.Output("spectrogram: float")
.SetShapeFn(SpectrogramShapeFn);
REGISTER_OP("Mfcc")
.Input("spectrogram: float")
.Input("sample_rate: int32")
.Attr("upper_frequency_limit: float = 4000")
.Attr("lower_frequency_limit: float = 20")
.Attr("filterbank_channel_count: int = 40")
.Attr("dct_coefficient_count: int = 13")
.Output("output: float")
.SetShapeFn(MfccShapeFn);
} // namespace tensorflow
+187
View File
@@ -0,0 +1,187 @@
/* 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.
==============================================================================*/
#include "tensorflow/core/framework/common_shape_fns.h"
#include "tensorflow/core/framework/op.h"
#include "tensorflow/core/framework/shape_inference.h"
namespace tensorflow {
REGISTER_OP("BatchFunction")
.Input("in_tensors: Tin")
.Input("captured_tensors: Tcaptured")
.Output("out_tensors: Tout")
.Attr("f: func")
.Attr("num_batch_threads: int")
// 'max_batch_size' denotes the maximum batch size acceptable, i.e., inputs
// with larger batch size are simply invalidated.
// By default, 'max_batch_size' must be equal to max value of
// 'allowed_batch_sizes'.
// By setting 'enable_large_batch_splitting' (attribute below) to true,
// 'max_batch_size' can be greater than or equal to max value of
// 'allowed_batch_sizes', in other words,
// 1) input with size > 'max_batch_size' is still invalidated.
// 2) input with
// a) size <= 'max_batch_size'
// b) size > max value of 'allowed_batch_sizes'
// will automatically be split into multiple batches (with batch size in
// 'allowed_batch_sizes'), executed, and re-composed (as final output).
.Attr("max_batch_size: int")
.Attr("batch_timeout_micros: int")
.Attr("max_enqueued_batches: int = 10")
.Attr("allowed_batch_sizes: list(int) = []")
.Attr("container: string = ''")
.Attr("shared_name: string = ''")
.Attr("batching_queue: string = ''")
// A separate set of batch options for the low priority requests, which is
// used for priority queue batching.
.Attr("low_priority_max_batch_size: int = 0")
.Attr("low_priority_batch_timeout_micros: int = 0")
.Attr("low_priority_allowed_batch_sizes: list(int) = []")
.Attr("low_priority_max_enqueued_batches: int = 0")
// Policy that determines the mixed priority batching behavior when low
// priority batch parameters are present.
//
// low_priority_padding_with_next_allowed_batch_size: If high priority
// batches time out without reaching the max batch size, low priority inputs
// pad the high priority batches up to the next allowed batch size. A low
// priority only batch gets schedule only when the low priority input times
// out or reaches the max batch size while there is no high priority input
// waiting to be processed.
// low_priority_padding_with_max_batch_size: Same as above but pad up to the
// max batch size.
// priority_isolation: High priority and low priority inputs never share the
// same batch, i.e., no low priority input padding high priority batches.
// Low priority inputs get scheduled only as part of low priority only
// batches as described above.
// priority_merge: High and low priority inputs are queued separately but
// when a batch needs to be scheduled, the two queues are treated as one
// merged flat list of inputs with high priority inputs at the front of the
// list of tasks to use for the next batch. If all inputs are of the same
// priority, the behavior is the same as disabling prioritization.
.Attr(
"mixed_priority_policy: "
"{'low_priority_padding_with_max_batch_size', "
"'low_priority_padding_with_next_allowed_batch_size', "
"'priority_isolation', 'priority_merge'} = "
"'low_priority_padding_with_max_batch_size'")
// The policy that a batch scheduler is using when deciding what to do when,
// say, 18 requests need to be batched, but only 16 and 32 batch sizes are
// allowed. The following options are available.
//
// - PAD_UP: pad to size 32.
// - BATCH_DOWN: schedule a batch of size 16 and leave 2 requests in the
// batch buffer.
// - MINIMIZE_TPU_COST_PER_REQUEST: a smarter greedy policy that chooses
// to either PAD_UP or BATCH_DOWN so as to minimize the TPU costs per
// real request. In this case, it would compare (batch_16_cost / 16) and
// (batch_32_cost / 18).
//
// WARNING: Not all batch schedulers might support this attribute.
.Attr(
"batch_padding_policy: "
"{'PAD_UP', 'BATCH_DOWN', 'MINIMIZE_TPU_COST_PER_REQUEST'} = 'PAD_UP'")
.Attr("Tin: list(type)")
.Attr("Tcaptured: list(type) >= 0")
.Attr("Tout: list(type)")
// If 'enable_large_batch_splitting' is true, for input batches exceeding
// the largest value in "allowed_batch_sizes", allow the batch to be split
// into multiple batches with batch size within "allowed_batch_sizes".
// NOTE: Support for `enable_large_batch_splitting == true` is still
// developed in progress.
.Attr("enable_large_batch_splitting: bool = false")
// If true, the queue implementation will have a separate subqueue for each
// criticality.
.Attr("enable_priority_aware_batch_scheduler: bool = false")
// If true, the queue implementation will re-split tasks into subtasks with
// priority aware batch scheduler.
.Attr("enable_priority_aware_batch_scheduler_resplit: bool = false")
// If true, the priority aware batch scheduler will lazily filter out and
// cancel tasks that have been cancelled or have exceeded their deadline
// before batch formation.
.Attr("enable_batching_task_lazy_cancellation: bool = false")
// If greater than zero, a separate thread pool with this number of threads
// is used for processing warmup requests.
.Attr("num_warmup_batch_threads: int = 0")
// TODO(apassos): Fix this shape inference function. It requires shape
// inference of function calls.
.SetShapeFn(shape_inference::UnknownShape)
.SetIsDistributedCommunication();
REGISTER_OP("Batch")
.Input("in_tensors: T")
.Output("batched_tensors: T")
.Output("batch_index: int64")
.Output("id: int64")
.Attr("num_batch_threads: int")
.Attr("max_batch_size: int")
.Attr("max_enqueued_batches: int = 10")
.Attr("batch_timeout_micros: int")
.Attr("allowed_batch_sizes: list(int) = []")
.Attr("grad_timeout_micros: int")
.Attr("container: string = ''")
.Attr("shared_name: string = ''")
.Attr("batching_queue: string = ''")
.Attr("T: list(type)")
.SetShapeFn([](shape_inference::InferenceContext* c) {
std::vector<shape_inference::ShapeHandle> in_shapes;
TF_RETURN_IF_ERROR(c->input("in_tensors", &in_shapes));
std::vector<shape_inference::ShapeHandle> out_shapes(in_shapes.size());
for (int i = 0; i < in_shapes.size(); ++i) {
TF_RETURN_IF_ERROR(
c->ReplaceDim(in_shapes[i], 0, c->UnknownDim(), &out_shapes[i]));
}
TF_RETURN_IF_ERROR(c->set_output("batched_tensors", out_shapes));
TF_RETURN_IF_ERROR(c->set_output("id", {c->Scalar()}));
TF_RETURN_IF_ERROR(c->set_output(
"batch_index",
{c->MakeShape({shape_inference::DimensionOrConstant(c->UnknownDim()),
shape_inference::DimensionOrConstant(3)})}));
return absl::OkStatus();
})
.SetIsDistributedCommunication();
REGISTER_OP("Unbatch")
.Input("batched_tensor: T")
.Input("batch_index: int64")
.Input("id: int64")
.Output("unbatched_tensor: T")
.Attr("timeout_micros: int")
.Attr("container: string = ''")
.Attr("shared_name: string = ''")
.Attr("T: type")
.SetShapeFn([](shape_inference::InferenceContext* c) {
shape_inference::ShapeHandle out_shape;
TF_RETURN_IF_ERROR(
c->ReplaceDim(c->input(0), 0, c->UnknownDim(), &out_shape));
c->set_output(0, out_shape);
return absl::OkStatus();
});
REGISTER_OP("UnbatchGrad")
.Input("original_input: T")
.Input("batch_index: int64")
.Input("grad: T")
.Input("id: int64")
.Output("batched_grad: T")
.Attr("container: string = ''")
.Attr("shared_name: string = ''")
.Attr("T: type")
.SetShapeFn([](shape_inference::InferenceContext* c) {
c->set_output(0, c->UnknownShapeOfRank(c->Rank(c->input(2))));
return absl::OkStatus();
});
} // namespace tensorflow
+60
View File
@@ -0,0 +1,60 @@
/* 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.
==============================================================================*/
#include "tensorflow/core/framework/common_shape_fns.h"
#include "tensorflow/core/framework/numeric_op.h"
#include "tensorflow/core/framework/op.h"
#include "tensorflow/core/framework/shape_inference.h"
namespace tensorflow {
REGISTER_OP("Invert")
.Input("x: T")
.Output("y: T")
.Attr("T: {int8, int16, int32, int64, uint8, uint16, uint32, uint64}")
.SetShapeFn(shape_inference::UnchangedShape);
#define BINARY_BITWISE() \
Input("x: T") \
.Input("y: T") \
.Output("z: T") \
.Attr("T: {int8, int16, int32, int64, uint8, uint16, uint32, uint64}") \
.SetShapeFn(shape_inference::BroadcastBinaryOpShapeFn)
#define BINARY_BITWISE_COMMUTATIVE() \
Input("x: T") \
.Input("y: T") \
.Output("z: T") \
.SetIsCommutative() \
.Attr("T: {int8, int16, int32, int64, uint8, uint16, uint32, uint64}") \
.SetShapeFn(shape_inference::BroadcastBinaryOpShapeFn)
REGISTER_OP("PopulationCount")
.Input("x: T")
.Output("y: uint8")
.Attr("T: {int8, int16, int32, int64, uint8, uint16, uint32, uint64}")
.SetShapeFn(shape_inference::UnchangedShape);
REGISTER_OP("BitwiseAnd").BINARY_BITWISE_COMMUTATIVE();
REGISTER_OP("BitwiseOr").BINARY_BITWISE_COMMUTATIVE();
REGISTER_OP("BitwiseXor").BINARY_BITWISE_COMMUTATIVE();
REGISTER_OP("LeftShift").BINARY_BITWISE();
REGISTER_OP("RightShift").BINARY_BITWISE();
} // namespace tensorflow
+866
View File
@@ -0,0 +1,866 @@
/* 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.
==============================================================================*/
#include <vector>
#include "tensorflow/core/framework/common_shape_fns.h"
#include "tensorflow/core/framework/op.h"
#include "tensorflow/core/framework/resource_mgr.h"
#include "tensorflow/core/framework/shape_inference.h"
#include "tensorflow/core/framework/tensor_shape.h"
#include "tensorflow/core/lib/core/errors.h"
namespace tensorflow {
using shape_inference::DimensionHandle;
using shape_inference::InferenceContext;
using shape_inference::ShapeHandle;
REGISTER_RESOURCE_HANDLE_OP(BoostedTreesEnsembleResource);
REGISTER_OP("IsBoostedTreesEnsembleInitialized")
.Input("tree_ensemble_handle: resource")
.Output("is_initialized: bool")
.SetShapeFn([](shape_inference::InferenceContext* c) {
shape_inference::ShapeHandle unused_input;
TF_RETURN_IF_ERROR(c->WithRank(c->input(0), 0, &unused_input));
c->set_output(0, c->Scalar());
return absl::OkStatus();
});
REGISTER_OP("BoostedTreesCalculateBestGainsPerFeature")
.Input("node_id_range: int32")
.Input("stats_summary_list: num_features * float32")
.Input("l1: float")
.Input("l2: float")
.Input("tree_complexity: float")
.Input("min_node_weight: float")
.Attr("max_splits: int >= 1")
.Attr("num_features: int >= 1") // not passed but populated automatically.
.Output("node_ids_list: num_features * int32")
.Output("gains_list: num_features * float32")
.Output("thresholds_list: num_features * int32")
.Output("left_node_contribs_list: num_features * float32")
.Output("right_node_contribs_list: num_features * float32")
.SetShapeFn([](shape_inference::InferenceContext* c) {
// Confirms the rank of the inputs and sets the shape of the outputs.
int max_splits;
int num_features;
TF_RETURN_IF_ERROR(c->GetAttr("max_splits", &max_splits));
TF_RETURN_IF_ERROR(c->GetAttr("num_features", &num_features));
shape_inference::ShapeHandle node_id_range_shape;
shape_inference::ShapeHandle unused_shape;
TF_RETURN_IF_ERROR(c->WithRank(c->input(0), 1, &node_id_range_shape));
TF_RETURN_IF_ERROR(
c->Merge(node_id_range_shape, c->MakeShape({2}), &unused_shape));
// Checks that all stats summary entries are of the same shape.
shape_inference::ShapeHandle summary_shape_base;
TF_RETURN_IF_ERROR(c->WithRank(c->input(1), 3, &summary_shape_base));
TF_RETURN_IF_ERROR(c->Merge(summary_shape_base,
c->MakeShape({max_splits, -1, 2}),
&unused_shape));
for (int i = 1; i < num_features; ++i) {
shape_inference::ShapeHandle summary_shape;
TF_RETURN_IF_ERROR(c->WithRank(c->input(1 + i), 3, &summary_shape));
TF_RETURN_IF_ERROR(
c->Merge(summary_shape_base, summary_shape, &unused_shape));
}
TF_RETURN_IF_ERROR(
c->WithRank(c->input(num_features + 1), 0, &unused_shape));
TF_RETURN_IF_ERROR(
c->WithRank(c->input(num_features + 2), 0, &unused_shape));
TF_RETURN_IF_ERROR(
c->WithRank(c->input(num_features + 3), 0, &unused_shape));
// Sets the output lists.
std::vector<shape_inference::ShapeHandle> output_shapes_vec(
num_features, c->MakeShape({-1}));
TF_RETURN_IF_ERROR(c->set_output("node_ids_list", output_shapes_vec));
TF_RETURN_IF_ERROR(c->set_output("gains_list", output_shapes_vec));
TF_RETURN_IF_ERROR(c->set_output("thresholds_list", output_shapes_vec));
std::vector<shape_inference::ShapeHandle> output_shapes_contribs(
num_features, c->MakeShape({-1, 1}));
TF_RETURN_IF_ERROR(
c->set_output("left_node_contribs_list", output_shapes_contribs));
TF_RETURN_IF_ERROR(
c->set_output("right_node_contribs_list", output_shapes_contribs));
return absl::OkStatus();
});
REGISTER_OP("BoostedTreesCalculateBestFeatureSplit")
.Input("node_id_range: int32")
.Input("stats_summary: float32")
.Input("l1: float")
.Input("l2: float")
.Input("tree_complexity: float")
.Input("min_node_weight: float")
.Attr("logits_dimension: int >= 1")
.Attr("split_type: {'inequality', 'equality'} = 'inequality'")
.Output("node_ids: int32")
.Output("gains: float32")
.Output("feature_dimensions: int32")
.Output("thresholds: int32")
.Output("left_node_contribs: float32")
.Output("right_node_contribs: float32")
.Output("split_with_default_directions: string")
.SetShapeFn([](shape_inference::InferenceContext* c) {
shape_inference::ShapeHandle node_id_range_shape;
shape_inference::ShapeHandle unused_shape;
// node id range is rank 1 with 2 values.
TF_RETURN_IF_ERROR(c->WithRank(c->input(0), 1, &node_id_range_shape));
TF_RETURN_IF_ERROR(
c->Merge(node_id_range_shape, c->MakeShape({2}), &unused_shape));
TF_RETURN_IF_ERROR(c->WithRank(c->input(1), 4, &unused_shape));
TF_RETURN_IF_ERROR(c->WithRank(c->input(2), 0, &unused_shape));
TF_RETURN_IF_ERROR(c->WithRank(c->input(3), 0, &unused_shape));
TF_RETURN_IF_ERROR(c->WithRank(c->input(4), 0, &unused_shape));
TF_RETURN_IF_ERROR(c->WithRank(c->input(5), 0, &unused_shape));
ShapeHandle rank_1_output_shape = c->MakeShape({c->UnknownDim()});
c->set_output(0, rank_1_output_shape);
c->set_output(1, rank_1_output_shape);
c->set_output(2, rank_1_output_shape);
c->set_output(3, rank_1_output_shape);
c->set_output(6, rank_1_output_shape);
int logits_dimension;
TF_RETURN_IF_ERROR(c->GetAttr("logits_dimension", &logits_dimension));
ShapeHandle contribs_output_shape =
c->MakeShape({c->UnknownDim(), logits_dimension});
c->set_output(4, contribs_output_shape);
c->set_output(5, contribs_output_shape);
return absl::OkStatus();
});
REGISTER_OP("BoostedTreesCalculateBestFeatureSplitV2")
.Input("node_id_range: int32")
.Input("stats_summaries_list: num_features * float32")
.Input("split_types: string")
.Input("candidate_feature_ids: int32")
.Input("l1: float")
.Input("l2: float")
.Input("tree_complexity: float")
.Input("min_node_weight: float")
.Attr("num_features: int >= 1") // not passed but populated automatically.
.Attr("logits_dimension: int >= 1")
.Output("node_ids: int32")
.Output("gains: float32")
.Output("feature_ids: int32")
.Output("feature_dimensions: int32")
.Output("thresholds: int32")
.Output("left_node_contribs: float32")
.Output("right_node_contribs: float32")
.Output("split_with_default_directions: string")
.SetShapeFn([](shape_inference::InferenceContext* c) {
// Attributes.
int num_features;
TF_RETURN_IF_ERROR(c->GetAttr("num_features", &num_features));
int logits_dimension;
TF_RETURN_IF_ERROR(c->GetAttr("logits_dimension", &logits_dimension));
// Inputs.
shape_inference::ShapeHandle unused_shape;
// node id range is rank 1 with 2 values.
shape_inference::ShapeHandle node_id_range_shape;
TF_RETURN_IF_ERROR(c->WithRank(c->input(0), 1, &node_id_range_shape));
TF_RETURN_IF_ERROR(
c->Merge(node_id_range_shape, c->MakeShape({2}), &unused_shape));
// Stats summary validation.
shape_inference::ShapeHandle summary_shape_base;
TF_RETURN_IF_ERROR(c->WithRank(c->input(1), 4, &summary_shape_base));
// All stats summary entries are of the same shape.
for (int i = 1; i < num_features; ++i) {
shape_inference::ShapeHandle summary_shape;
TF_RETURN_IF_ERROR(c->WithRank(c->input(1 + i), 4, &summary_shape));
TF_RETURN_IF_ERROR(
c->Merge(summary_shape_base, summary_shape, &unused_shape));
}
// Validate rank 1 split_types.
TF_RETURN_IF_ERROR(
c->WithRank(c->input(1 + num_features), 1, &unused_shape));
// Validate rank 1 feature_ids.
TF_RETURN_IF_ERROR(
c->WithRank(c->input(2 + num_features), 1, &unused_shape));
// Validate rank 0: l1, l2, tree_complexity, min_node_weight.
for (int i = 0; i < 4; ++i) {
TF_RETURN_IF_ERROR(
c->WithRank(c->input(3 + num_features + i), 0, &unused_shape));
}
// Output shapes.
ShapeHandle rank_1_output_shape = c->MakeShape({c->UnknownDim()});
c->set_output(0, rank_1_output_shape);
c->set_output(1, rank_1_output_shape);
c->set_output(2, rank_1_output_shape);
c->set_output(3, rank_1_output_shape);
c->set_output(4, rank_1_output_shape);
ShapeHandle contribs_output_shape =
c->MakeShape({c->UnknownDim(), logits_dimension});
c->set_output(5, contribs_output_shape);
c->set_output(6, contribs_output_shape);
c->set_output(7, rank_1_output_shape);
return absl::OkStatus();
});
REGISTER_OP("BoostedTreesSparseCalculateBestFeatureSplit")
.Input("node_id_range: int32")
.Input("stats_summary_indices: int32")
.Input("stats_summary_values: float")
.Input("stats_summary_shape: int32")
.Input("l1: float")
.Input("l2: float")
.Input("tree_complexity: float")
.Input("min_node_weight: float")
.Attr("logits_dimension: int >= 1")
.Attr("split_type: {'inequality'} = 'inequality'")
.Output("node_ids: int32")
.Output("gains: float32")
.Output("feature_dimensions: int32")
.Output("thresholds: int32")
.Output("left_node_contribs: float32")
.Output("right_node_contribs: float32")
.Output("split_with_default_directions: string")
.SetShapeFn([](shape_inference::InferenceContext* c) {
shape_inference::ShapeHandle node_id_range_shape;
shape_inference::ShapeHandle unused_shape;
// node id range is rank 1 with 2 values.
TF_RETURN_IF_ERROR(c->WithRank(c->input(0), 1, &node_id_range_shape));
TF_RETURN_IF_ERROR(
c->Merge(node_id_range_shape, c->MakeShape({2}), &unused_shape));
TF_RETURN_IF_ERROR(c->WithRank(c->input(1), 2, &unused_shape));
TF_RETURN_IF_ERROR(c->WithRank(c->input(2), 1, &unused_shape));
TF_RETURN_IF_ERROR(c->WithRank(c->input(3), 1, &unused_shape));
shape_inference::ShapeHandle summary_shape;
TF_RETURN_IF_ERROR(
c->Merge(summary_shape, c->MakeShape({4}), &unused_shape));
TF_RETURN_IF_ERROR(c->WithRank(c->input(4), 0, &unused_shape));
TF_RETURN_IF_ERROR(c->WithRank(c->input(5), 0, &unused_shape));
TF_RETURN_IF_ERROR(c->WithRank(c->input(6), 0, &unused_shape));
TF_RETURN_IF_ERROR(c->WithRank(c->input(7), 0, &unused_shape));
ShapeHandle rank_1_output_shape = c->MakeShape({c->UnknownDim()});
c->set_output(0, rank_1_output_shape);
c->set_output(1, rank_1_output_shape);
c->set_output(2, rank_1_output_shape);
c->set_output(3, rank_1_output_shape);
c->set_output(6, rank_1_output_shape);
int logits_dimension;
TF_RETURN_IF_ERROR(c->GetAttr("logits_dimension", &logits_dimension));
ShapeHandle contribs_output_shape =
c->MakeShape({c->UnknownDim(), logits_dimension});
c->set_output(4, contribs_output_shape);
c->set_output(5, contribs_output_shape);
return absl::OkStatus();
});
REGISTER_OP("BoostedTreesCreateEnsemble")
.Input("tree_ensemble_handle: resource")
.Input("stamp_token: int64")
.Input("tree_ensemble_serialized: string")
.SetShapeFn([](shape_inference::InferenceContext* c) {
shape_inference::ShapeHandle unused_input;
TF_RETURN_IF_ERROR(c->WithRank(c->input(0), 0, &unused_input));
TF_RETURN_IF_ERROR(c->WithRank(c->input(1), 0, &unused_input));
TF_RETURN_IF_ERROR(c->WithRank(c->input(2), 0, &unused_input));
return absl::OkStatus();
});
REGISTER_OP("BoostedTreesDeserializeEnsemble")
.Input("tree_ensemble_handle: resource")
.Input("stamp_token: int64")
.Input("tree_ensemble_serialized: string")
.SetShapeFn([](shape_inference::InferenceContext* c) {
shape_inference::ShapeHandle unused_input;
TF_RETURN_IF_ERROR(c->WithRank(c->input(0), 0, &unused_input));
TF_RETURN_IF_ERROR(c->WithRank(c->input(1), 0, &unused_input));
TF_RETURN_IF_ERROR(c->WithRank(c->input(2), 0, &unused_input));
return absl::OkStatus();
});
REGISTER_OP("BoostedTreesGetEnsembleStates")
.Input("tree_ensemble_handle: resource")
.Output("stamp_token: int64")
.Output("num_trees: int32")
.Output("num_finalized_trees: int32")
.Output("num_attempted_layers: int32")
.Output("last_layer_nodes_range: int32")
.SetShapeFn([](shape_inference::InferenceContext* c) {
shape_inference::ShapeHandle unused_input;
TF_RETURN_IF_ERROR(c->WithRank(c->input(0), 0, &unused_input));
c->set_output(0, c->Scalar());
c->set_output(1, c->Scalar());
c->set_output(2, c->Scalar());
c->set_output(3, c->Scalar());
c->set_output(4, c->Vector(2));
return absl::OkStatus();
});
REGISTER_OP("BoostedTreesMakeStatsSummary")
.Input("node_ids: int32")
.Input("gradients: float")
.Input("hessians: float")
.Input("bucketized_features_list: num_features * int32")
.Attr("max_splits: int >= 1")
.Attr("num_buckets: int >= 1")
.Attr("num_features: int >= 1")
.Output("stats_summary: float")
.SetShapeFn([](shape_inference::InferenceContext* c) {
// Sets the shape of the output as a Rank 4 Tensor.
int max_splits;
int num_buckets;
int num_features;
TF_RETURN_IF_ERROR(c->GetAttr("max_splits", &max_splits));
TF_RETURN_IF_ERROR(c->GetAttr("num_buckets", &num_buckets));
TF_RETURN_IF_ERROR(c->GetAttr("num_features", &num_features));
shape_inference::ShapeHandle node_ids_shape;
shape_inference::ShapeHandle gradients_shape;
shape_inference::ShapeHandle hessians_shape;
shape_inference::ShapeHandle bucketized_feature_shape;
shape_inference::ShapeHandle unused_shape;
shape_inference::DimensionHandle unused_dim;
TF_RETURN_IF_ERROR(c->WithRank(c->input(0), 1, &node_ids_shape));
TF_RETURN_IF_ERROR(c->WithRank(c->input(1), 2, &gradients_shape));
TF_RETURN_IF_ERROR(c->WithRank(c->input(2), 2, &hessians_shape));
TF_RETURN_IF_ERROR(c->Merge(c->Dim(node_ids_shape, 0),
c->Dim(gradients_shape, 0), &unused_dim));
TF_RETURN_IF_ERROR(
c->Merge(gradients_shape, hessians_shape, &unused_shape));
for (int f = 0; f < num_features; ++f) {
TF_RETURN_IF_ERROR(
c->WithRank(c->input(3 + f), 1, &bucketized_feature_shape));
TF_RETURN_IF_ERROR(c->Merge(c->Dim(node_ids_shape, 0),
c->Dim(bucketized_feature_shape, 0),
&unused_dim));
}
c->set_output(0,
c->MakeShape({num_features, max_splits, num_buckets, 2}));
return absl::OkStatus();
});
// V2 of BoostedTreesMakeStatsSummary. Supports multi-dim dense Tensor and
// multi class.
REGISTER_OP("BoostedTreesAggregateStats")
.Input("node_ids: int32")
.Input("gradients: float")
.Input("hessians: float")
.Input("feature: int32")
.Attr("max_splits: int >= 1")
.Attr("num_buckets: int >= 1")
.Output("stats_summary: float")
.SetShapeFn([](shape_inference::InferenceContext* c) {
// Sets the shape of the output as a Rank 4 Tensor.
int max_splits;
int num_buckets;
TF_RETURN_IF_ERROR(c->GetAttr("max_splits", &max_splits));
TF_RETURN_IF_ERROR(c->GetAttr("num_buckets", &num_buckets));
shape_inference::ShapeHandle node_ids_shape;
shape_inference::ShapeHandle gradients_shape;
shape_inference::ShapeHandle hessians_shape;
shape_inference::ShapeHandle feature_shape;
shape_inference::DimensionHandle batch_size = c->Dim(c->input(0), 0);
TF_RETURN_IF_ERROR(c->WithRank(c->input(0), 1, &node_ids_shape));
TF_RETURN_IF_ERROR(c->WithRank(c->input(1), 2, &gradients_shape));
TF_RETURN_IF_ERROR(c->WithRank(c->input(2), 2, &hessians_shape));
TF_RETURN_IF_ERROR(c->WithRank(c->input(3), 2, &feature_shape));
// Verify all three inputs have same first dimension, i.e., batch_size.
TF_RETURN_IF_ERROR(c->Merge(c->Dim(gradients_shape, 0),
c->Dim(node_ids_shape, 0), &batch_size));
TF_RETURN_IF_ERROR(c->Merge(c->Dim(hessians_shape, 0),
c->Dim(node_ids_shape, 0), &batch_size));
TF_RETURN_IF_ERROR(c->Merge(c->Dim(feature_shape, 0),
c->Dim(node_ids_shape, 0), &batch_size));
DimensionHandle logits_dim = c->Dim(c->input(1), 1);
DimensionHandle hessian_dim = c->Dim(c->input(2), 1);
DimensionHandle feature_dim = c->Dim(c->input(3), 1);
DimensionHandle stats_dim;
TF_RETURN_IF_ERROR(c->Add(logits_dim, hessian_dim, &stats_dim));
c->set_output(0, c->MakeShape({max_splits, feature_dim,
num_buckets + 1, // +1 for missing bucket.
stats_dim}));
return absl::OkStatus();
});
// Sparse Version of BoostedTreesAggregatesStats.
REGISTER_OP("BoostedTreesSparseAggregateStats")
.Input("node_ids: int32")
.Input("gradients: float")
.Input("hessians: float")
.Input("feature_indices: int32")
.Input("feature_values: int32")
.Input("feature_shape: int32")
.Attr("max_splits: int >= 1")
.Attr("num_buckets: int >= 1")
.Output("stats_summary_indices: int32")
.Output("stats_summary_values: float")
.Output("stats_summary_shape: int32")
.SetShapeFn([](shape_inference::InferenceContext* c) {
int max_splits;
int num_buckets;
TF_RETURN_IF_ERROR(c->GetAttr("max_splits", &max_splits));
TF_RETURN_IF_ERROR(c->GetAttr("num_buckets", &num_buckets));
shape_inference::ShapeHandle node_ids_shape;
shape_inference::ShapeHandle gradients_shape;
shape_inference::ShapeHandle hessians_shape;
shape_inference::ShapeHandle feature_indices_shape;
shape_inference::ShapeHandle feature_values_shape;
shape_inference::ShapeHandle feature_shape;
TF_RETURN_IF_ERROR(c->WithRank(c->input(0), 1, &node_ids_shape));
TF_RETURN_IF_ERROR(c->WithRank(c->input(1), 2, &gradients_shape));
TF_RETURN_IF_ERROR(c->WithRank(c->input(2), 2, &hessians_shape));
TF_RETURN_IF_ERROR(c->WithRank(c->input(3), 2, &feature_indices_shape));
TF_RETURN_IF_ERROR(c->WithRank(c->input(4), 1, &feature_values_shape));
TF_RETURN_IF_ERROR(c->WithRank(c->input(5), 1, &feature_shape));
shape_inference::DimensionHandle batch_size = c->Dim(c->input(0), 0);
shape_inference::DimensionHandle num_entries;
// Verify all inputs have same first dimension, i.e., batch_size.
TF_RETURN_IF_ERROR(c->Merge(c->Dim(gradients_shape, 0),
c->Dim(node_ids_shape, 0), &batch_size));
TF_RETURN_IF_ERROR(c->Merge(c->Dim(hessians_shape, 0),
c->Dim(node_ids_shape, 0), &batch_size));
TF_RETURN_IF_ERROR(c->Merge(c->Dim(feature_indices_shape, 0),
c->Dim(feature_values_shape, 0),
&num_entries));
DimensionHandle unused;
TF_RETURN_IF_ERROR(c->WithValue(c->Dim(feature_shape, 0), 2, &unused));
DimensionHandle logits_dim = c->Dim(c->input(1), 1);
DimensionHandle hessian_dim = c->Dim(c->input(2), 1);
DimensionHandle stats_dim;
TF_RETURN_IF_ERROR(c->Add(logits_dim, hessian_dim, &stats_dim));
c->set_output(0, c->MakeShape({c->UnknownDim(), 4}));
c->set_output(1, c->Vector(InferenceContext::kUnknownDim));
c->set_output(2, c->MakeShape({4}));
return absl::OkStatus();
});
// TODO(nponomareva): when/if creating the new op for unbucketized data, rename
// bucketized_features to features.
REGISTER_OP("BoostedTreesPredict")
.Input("tree_ensemble_handle: resource")
.Input("bucketized_features: num_bucketized_features * int32")
.Attr("num_bucketized_features: int >= 1") // Inferred.
.Attr("logits_dimension: int")
.Output("logits: float")
.SetShapeFn([](shape_inference::InferenceContext* c) {
shape_inference::ShapeHandle feature_shape;
int num_bucketized_features;
TF_RETURN_IF_ERROR(
c->GetAttr("num_bucketized_features", &num_bucketized_features));
shape_inference::DimensionHandle batch_size = c->Dim(c->input(1), 0);
for (int i = 0; i < num_bucketized_features; ++i) {
TF_RETURN_IF_ERROR(
c->WithRankAtMost(c->input(i + 1), 2, &feature_shape));
// Check that all bucketized features have the same batch size.
TF_RETURN_IF_ERROR(c->Merge(c->Dim(c->input(1), 0),
c->Dim(c->input(i + 1), 0), &batch_size));
}
int logits_dimension;
TF_RETURN_IF_ERROR(c->GetAttr("logits_dimension", &logits_dimension));
auto logits_shape =
c->MakeShape({c->Dim(feature_shape, 0), logits_dimension});
// Logits.
c->set_output(0, logits_shape);
return absl::OkStatus();
});
REGISTER_OP("BoostedTreesExampleDebugOutputs")
.Input("tree_ensemble_handle: resource")
.Input("bucketized_features: num_bucketized_features * int32")
.Attr("num_bucketized_features: int >= 1") // Inferred.
.Attr("logits_dimension: int")
.Output("examples_debug_outputs_serialized: string")
.SetShapeFn([](shape_inference::InferenceContext* c) {
shape_inference::ShapeHandle feature_shape;
int num_bucketized_features;
TF_RETURN_IF_ERROR(
c->GetAttr("num_bucketized_features", &num_bucketized_features));
shape_inference::DimensionHandle batch_dim = c->Dim(c->input(1), 0);
for (int i = 0; i < num_bucketized_features; ++i) {
TF_RETURN_IF_ERROR(
c->WithRankAtMost(c->input(i + 1), 2, &feature_shape));
// Check that all bucketized features have the same batch size.
TF_RETURN_IF_ERROR(c->Merge(c->Dim(c->input(1), 0),
c->Dim(c->input(i + 1), 0), &batch_dim));
}
// Multi-class will be supported by modifying the proto.
auto batch_size = c->MakeShape({c->Dim(feature_shape, 0)});
c->set_output(0, batch_size);
return absl::OkStatus();
});
REGISTER_OP("BoostedTreesSerializeEnsemble")
.Input("tree_ensemble_handle: resource")
.Output("stamp_token: int64")
.Output("tree_ensemble_serialized: string")
.SetShapeFn([](shape_inference::InferenceContext* c) {
shape_inference::ShapeHandle unused_input;
TF_RETURN_IF_ERROR(c->WithRank(c->input(0), 0, &unused_input));
c->set_output(0, c->Scalar());
c->set_output(1, c->Scalar());
return absl::OkStatus();
});
REGISTER_OP("BoostedTreesTrainingPredict")
.Input("tree_ensemble_handle: resource")
.Input("cached_tree_ids: int32")
.Input("cached_node_ids: int32")
.Input("bucketized_features: num_bucketized_features * int32")
.Attr("num_bucketized_features: int >= 1")
.Attr("logits_dimension: int")
.Output("partial_logits: float")
.Output("tree_ids: int32")
.Output("node_ids: int32")
.SetShapeFn([](shape_inference::InferenceContext* c) {
shape_inference::ShapeHandle feature_shape;
int num_bucketized_features;
TF_RETURN_IF_ERROR(
c->GetAttr("num_bucketized_features", &num_bucketized_features));
shape_inference::ShapeHandle unused_input;
shape_inference::DimensionHandle batch_size = c->Dim(c->input(3), 0);
for (int i = 0; i < num_bucketized_features; ++i) {
TF_RETURN_IF_ERROR(
c->WithRankAtMost(c->input(i + 3), 2, &feature_shape));
TF_RETURN_IF_ERROR(
c->Merge(c->input(i + 3), feature_shape, &unused_input));
}
shape_inference::ShapeHandle tree_ids_shape;
shape_inference::ShapeHandle node_ids_shape;
TF_RETURN_IF_ERROR(c->WithRank(c->input(1), 1, &tree_ids_shape));
TF_RETURN_IF_ERROR(c->WithRank(c->input(2), 1, &node_ids_shape));
TF_RETURN_IF_ERROR(c->Merge(c->Dim(tree_ids_shape, 0),
c->Dim(node_ids_shape, 0), &batch_size));
int logits_dimension;
TF_RETURN_IF_ERROR(c->GetAttr("logits_dimension", &logits_dimension));
auto logits_shape =
c->MakeShape({c->Dim(feature_shape, 0), logits_dimension});
// Partial logits.
c->set_output(0, logits_shape);
// Tree ids.
c->set_output(1, c->MakeShape({c->Dim(feature_shape, 0)}));
// Node ids.
c->set_output(2, c->MakeShape({c->Dim(feature_shape, 0)}));
return absl::OkStatus();
});
REGISTER_OP("BoostedTreesUpdateEnsemble")
.Input("tree_ensemble_handle: resource")
.Input("feature_ids: int32")
.Input("node_ids: num_features * int32")
.Input("gains: num_features * float")
.Input("thresholds: num_features * int32")
.Input("left_node_contribs: num_features * float")
.Input("right_node_contribs: num_features * float")
.Input("max_depth: int32")
.Input("learning_rate: float")
.Attr("pruning_mode: int >=0")
.Attr("num_features: int >= 0") // Inferred.
.SetShapeFn([](shape_inference::InferenceContext* c) {
shape_inference::ShapeHandle shape_handle;
int num_features;
TF_RETURN_IF_ERROR(c->GetAttr("num_features", &num_features));
// Feature_ids, should be one for each feature.
shape_inference::ShapeHandle feature_ids_shape;
TF_RETURN_IF_ERROR(c->WithRank(c->input(1), 1, &feature_ids_shape));
TF_RETURN_IF_ERROR(
c->Merge(c->input(1), c->Vector(num_features), &shape_handle));
for (int i = 0; i < num_features; ++i) {
// Node ids.
TF_RETURN_IF_ERROR(c->WithRank(c->input(i + 2), 1, &shape_handle));
auto shape_rank_1 = c->MakeShape({c->Dim(shape_handle, 0)});
auto shape_rank_2 = c->MakeShape({c->Dim(shape_handle, 0), 1});
// Gains.
TF_RETURN_IF_ERROR(
c->WithRank(c->input(i + num_features + 2), 1, &shape_handle));
// TODO(nponomareva): replace this with input("name",vector of shapes).
TF_RETURN_IF_ERROR(c->Merge(c->input(i + num_features + 2),
shape_rank_1, &shape_handle));
// Thresholds.
TF_RETURN_IF_ERROR(
c->WithRank(c->input(i + num_features * 2 + 2), 1, &shape_handle));
TF_RETURN_IF_ERROR(c->Merge(c->input(i + num_features * 2 + 2),
shape_rank_1, &shape_handle));
// Left and right node contribs.
TF_RETURN_IF_ERROR(
c->WithRank(c->input(i + num_features * 3 + 2), 2, &shape_handle));
TF_RETURN_IF_ERROR(c->Merge(c->input(i + num_features * 3 + 2),
shape_rank_2, &shape_handle));
TF_RETURN_IF_ERROR(
c->WithRank(c->input(i + num_features * 4 + 2), 2, &shape_handle));
TF_RETURN_IF_ERROR(c->Merge(c->input(i + num_features * 4 + 2),
shape_rank_2, &shape_handle));
}
return absl::OkStatus();
});
REGISTER_OP("BoostedTreesUpdateEnsembleV2")
.Input("tree_ensemble_handle: resource")
.Input("feature_ids: num_groups * int32")
.Input("dimension_ids: num_features * int32")
.Input("node_ids: num_features * int32")
.Input("gains: num_features * float")
.Input("thresholds: num_features * int32")
.Input("left_node_contribs: num_features * float")
.Input("right_node_contribs: num_features * float")
.Input("split_types: num_features * string")
.Input("max_depth: int32")
.Input("learning_rate: float")
.Input("pruning_mode: int32")
.Attr("num_features: int >= 0") // Inferred.
.Attr("logits_dimension: int = 1")
.Attr("num_groups: int = 1") // Inferred; number of groups to process.
.SetShapeFn([](shape_inference::InferenceContext* c) {
int num_features;
int logits_dimension;
int num_groups;
TF_RETURN_IF_ERROR(c->GetAttr("num_features", &num_features));
TF_RETURN_IF_ERROR(c->GetAttr("logits_dimension", &logits_dimension));
TF_RETURN_IF_ERROR(c->GetAttr("num_groups", &num_groups));
// num_features was kept for backwards compatibility reasons. It now
// represents number of groups.
DCHECK_EQ(num_features, num_groups);
shape_inference::ShapeHandle shape_handle;
for (int i = 0; i < num_groups; ++i) {
int offset = i + 1;
// Feature ids
TF_RETURN_IF_ERROR(c->WithRank(c->input(offset), 1, &shape_handle));
// TODO(nponomareva): replace this with input("name",vector of shapes).
auto shape_rank_1 = c->MakeShape({c->Dim(shape_handle, 0)});
TF_RETURN_IF_ERROR(
c->Merge(c->input(offset), shape_rank_1, &shape_handle));
// Dimension ids.
TF_RETURN_IF_ERROR(
c->WithRank(c->input(offset + num_features), 1, &shape_handle));
TF_RETURN_IF_ERROR(
c->Merge(c->input(offset), shape_rank_1, &shape_handle));
// Node ids.
TF_RETURN_IF_ERROR(
c->WithRank(c->input(offset + num_features * 2), 1, &shape_handle));
TF_RETURN_IF_ERROR(
c->Merge(c->input(offset), shape_rank_1, &shape_handle));
// Gains.
TF_RETURN_IF_ERROR(
c->WithRank(c->input(offset + num_features * 3), 1, &shape_handle));
TF_RETURN_IF_ERROR(c->Merge(c->input(offset + num_features * 3),
shape_rank_1, &shape_handle));
// Thresholds.
TF_RETURN_IF_ERROR(
c->WithRank(c->input(offset + num_features * 4), 1, &shape_handle));
TF_RETURN_IF_ERROR(c->Merge(c->input(offset + num_features * 4),
shape_rank_1, &shape_handle));
// Left and right node contribs.
auto shape_rank_2 =
c->MakeShape({c->Dim(shape_handle, 0), logits_dimension});
TF_RETURN_IF_ERROR(
c->WithRank(c->input(offset + num_features * 5), 2, &shape_handle));
TF_RETURN_IF_ERROR(c->Merge(c->input(offset + num_features * 5),
shape_rank_2, &shape_handle));
TF_RETURN_IF_ERROR(
c->WithRank(c->input(offset + num_features * 6), 2, &shape_handle));
TF_RETURN_IF_ERROR(c->Merge(c->input(offset + num_features * 6),
shape_rank_2, &shape_handle));
// Split types.
TF_RETURN_IF_ERROR(
c->WithRank(c->input(offset + num_features * 7), 1, &shape_handle));
TF_RETURN_IF_ERROR(c->Merge(c->input(offset + num_features * 7),
shape_rank_1, &shape_handle));
}
return absl::OkStatus();
});
REGISTER_OP("BoostedTreesCenterBias")
.Input("tree_ensemble_handle: resource")
.Input("mean_gradients: float")
.Input("mean_hessians: float")
// Regularization-related.
.Input("l1: float")
.Input("l2: float")
.Output("continue_centering: bool")
.SetShapeFn([](shape_inference::InferenceContext* c) {
shape_inference::ShapeHandle gradients_shape;
shape_inference::ShapeHandle hessians_shape;
shape_inference::ShapeHandle unused_shape;
TF_RETURN_IF_ERROR(c->WithRank(c->input(1), 2, &gradients_shape));
TF_RETURN_IF_ERROR(c->WithRank(c->input(2), 2, &hessians_shape));
TF_RETURN_IF_ERROR(
c->Merge(gradients_shape, hessians_shape, &unused_shape));
TF_RETURN_IF_ERROR(c->WithRank(c->input(3), 0, &unused_shape));
TF_RETURN_IF_ERROR(c->WithRank(c->input(4), 0, &unused_shape));
c->set_output(0, c->Scalar());
return absl::OkStatus();
});
REGISTER_RESOURCE_HANDLE_OP(BoostedTreesQuantileStreamResource);
REGISTER_OP("IsBoostedTreesQuantileStreamResourceInitialized")
.Input("quantile_stream_resource_handle: resource")
.Output("is_initialized: bool")
.SetShapeFn([](shape_inference::InferenceContext* c) {
shape_inference::ShapeHandle unused_input;
TF_RETURN_IF_ERROR(c->WithRank(c->input(0), 0, &unused_input));
c->set_output(0, c->Scalar());
return absl::OkStatus();
});
REGISTER_OP("BoostedTreesCreateQuantileStreamResource")
.Attr("max_elements: int = 1099511627776") // 1 << 40
.Input("quantile_stream_resource_handle: resource")
.Input("epsilon: float")
.Input("num_streams: int64")
.SetShapeFn([](shape_inference::InferenceContext* c) {
shape_inference::ShapeHandle unused_input;
TF_RETURN_IF_ERROR(c->WithRank(c->input(0), 0, &unused_input));
TF_RETURN_IF_ERROR(c->WithRank(c->input(1), 0, &unused_input));
TF_RETURN_IF_ERROR(c->WithRank(c->input(2), 0, &unused_input));
return absl::OkStatus();
});
REGISTER_OP("BoostedTreesMakeQuantileSummaries")
.Attr("num_features: int >= 0")
.Input("float_values: num_features * float")
.Input("example_weights: float")
.Input("epsilon: float")
.Output("summaries: num_features * float")
.SetShapeFn([](InferenceContext* c) {
int num_features;
TF_RETURN_IF_ERROR(c->GetAttr("num_features", &num_features));
ShapeHandle example_weights_shape;
TF_RETURN_IF_ERROR(
c->WithRank(c->input(num_features), 1, &example_weights_shape));
for (int i = 0; i < num_features; ++i) {
ShapeHandle feature_shape;
TF_RETURN_IF_ERROR(c->WithRank(c->input(i), 1, &feature_shape));
// the columns are value, weight, min_rank, max_rank.
c->set_output(i, c->MakeShape({c->UnknownDim(), 4}));
}
// epsilon must be a scalar.
ShapeHandle unused_input;
TF_RETURN_IF_ERROR(
c->WithRank(c->input(num_features + 1), 0, &unused_input));
return absl::OkStatus();
});
REGISTER_OP("BoostedTreesFlushQuantileSummaries")
.Attr("num_features: int >= 0")
.Input("quantile_stream_resource_handle: resource")
.Output("summaries: num_features * float")
.SetShapeFn([](InferenceContext* c) {
int num_features;
TF_RETURN_IF_ERROR(c->GetAttr("num_features", &num_features));
for (int i = 0; i < num_features; ++i) {
// the columns are value, weight, min_rank, max_rank.
c->set_output(i, c->MakeShape({c->UnknownDim(), 4}));
}
return absl::OkStatus();
});
REGISTER_OP("BoostedTreesQuantileStreamResourceAddSummaries")
.Attr("num_features: int >= 0")
.Input("quantile_stream_resource_handle: resource")
.Input("summaries: num_features * float")
.SetShapeFn([](InferenceContext* c) {
int num_features;
TF_RETURN_IF_ERROR(c->GetAttr("num_features", &num_features));
// resource handle must be a scalar.
shape_inference::ShapeHandle unused_input;
TF_RETURN_IF_ERROR(c->WithRank(c->input(0), 0, &unused_input));
// each summary must be rank 2.
for (int i = 1; i < num_features + 1; i++) {
TF_RETURN_IF_ERROR(c->WithRank(c->input(i), 2, &unused_input));
}
return absl::OkStatus();
});
REGISTER_OP("BoostedTreesQuantileStreamResourceDeserialize")
.Attr("num_streams: int")
.Input("quantile_stream_resource_handle: resource")
.Input("bucket_boundaries: num_streams * float")
.SetShapeFn([](shape_inference::InferenceContext* c) {
shape_inference::ShapeHandle unused_input;
TF_RETURN_IF_ERROR(c->WithRank(c->input(0), 0, &unused_input));
TF_RETURN_IF_ERROR(c->WithRank(c->input(1), 0, &unused_input));
return absl::OkStatus();
});
REGISTER_OP("BoostedTreesQuantileStreamResourceFlush")
.Attr("generate_quantiles: bool = False")
.Input("quantile_stream_resource_handle: resource")
.Input("num_buckets: int64")
.SetShapeFn([](InferenceContext* c) {
// All the inputs are scalars.
shape_inference::ShapeHandle unused_input;
TF_RETURN_IF_ERROR(c->WithRank(c->input(0), 0, &unused_input));
TF_RETURN_IF_ERROR(c->WithRank(c->input(1), 0, &unused_input));
return absl::OkStatus();
});
REGISTER_OP("BoostedTreesQuantileStreamResourceGetBucketBoundaries")
.Attr("num_features: int >= 0")
.Input("quantile_stream_resource_handle: resource")
.Output("bucket_boundaries: num_features * float")
.SetShapeFn([](InferenceContext* c) {
int num_features;
TF_RETURN_IF_ERROR(c->GetAttr("num_features", &num_features));
shape_inference::ShapeHandle unused_input;
// resource handle must be a scalar.
TF_RETURN_IF_ERROR(c->WithRank(c->input(0), 0, &unused_input));
for (int i = 0; i < num_features; i++) {
c->set_output(i, c->Vector(c->UnknownDim()));
}
return absl::OkStatus();
});
REGISTER_OP("BoostedTreesBucketize")
.Attr("num_features: int >= 0")
.Input("float_values: num_features * float")
.Input("bucket_boundaries: num_features * float")
.Output("buckets: num_features * int32")
.SetShapeFn([](InferenceContext* c) {
int num_features;
TF_RETURN_IF_ERROR(c->GetAttr("num_features", &num_features));
ShapeHandle feature_shape;
DimensionHandle unused_dim;
for (int i = 0; i < num_features; i++) {
TF_RETURN_IF_ERROR(c->WithRank(c->input(i), 1, &feature_shape));
TF_RETURN_IF_ERROR(c->Merge(c->Dim(feature_shape, 0),
c->Dim(c->input(0), 0), &unused_dim));
}
// Bucketized result should have same dimension as input.
for (int i = 0; i < num_features; i++) {
c->set_output(i, c->MakeShape({c->Dim(c->input(i), 0)}));
}
return absl::OkStatus();
});
} // namespace tensorflow
@@ -0,0 +1,166 @@
/* 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.
==============================================================================*/
#include "tensorflow/core/framework/op.h"
#include "tensorflow/core/framework/shape_inference.h"
namespace tensorflow {
using shape_inference::DimensionHandle;
using shape_inference::InferenceContext;
using shape_inference::ShapeHandle;
namespace {
absl::Status CandidateSamplerShapeFn(InferenceContext* c) {
int64_t num_sampled;
TF_RETURN_IF_ERROR(c->GetAttr("num_sampled", &num_sampled));
int64_t num_true;
TF_RETURN_IF_ERROR(c->GetAttr("num_true", &num_true));
ShapeHandle true_classes_shape;
TF_RETURN_IF_ERROR(c->WithRank(c->input(0), 2, &true_classes_shape));
DimensionHandle batch_size = c->Dim(true_classes_shape, 0);
ShapeHandle num_sampled_v = c->Vector(num_sampled);
c->set_output(0, num_sampled_v);
c->set_output(1, c->Matrix(batch_size, num_true));
c->set_output(2, num_sampled_v);
return absl::OkStatus();
}
} // namespace
REGISTER_OP("UniformCandidateSampler")
.Input("true_classes: int64")
.Output("sampled_candidates: int64")
.Output("true_expected_count: float")
.Output("sampled_expected_count: float")
.Attr("num_true: int >= 1")
.Attr("num_sampled: int >= 1")
.Attr("unique: bool")
.Attr("range_max: int >= 1")
.Attr("seed: int = 0")
.Attr("seed2: int = 0")
.SetShapeFn(CandidateSamplerShapeFn)
.SetIsStateful();
REGISTER_OP("LogUniformCandidateSampler")
.Input("true_classes: int64")
.Output("sampled_candidates: int64")
.Output("true_expected_count: float")
.Output("sampled_expected_count: float")
.Attr("num_true: int >= 1")
.Attr("num_sampled: int >= 1")
.Attr("unique: bool")
.Attr("range_max: int >= 1")
.Attr("seed: int = 0")
.Attr("seed2: int = 0")
.SetShapeFn(CandidateSamplerShapeFn)
.SetIsStateful();
REGISTER_OP("LearnedUnigramCandidateSampler")
.Input("true_classes: int64")
.Output("sampled_candidates: int64")
.Output("true_expected_count: float")
.Output("sampled_expected_count: float")
.Attr("num_true: int >= 1")
.Attr("num_sampled: int >= 1")
.Attr("unique: bool")
.Attr("range_max: int >= 1")
.Attr("seed: int = 0")
.Attr("seed2: int = 0")
.SetShapeFn(CandidateSamplerShapeFn)
.SetIsStateful();
REGISTER_OP("ThreadUnsafeUnigramCandidateSampler")
.Input("true_classes: int64")
.Output("sampled_candidates: int64")
.Output("true_expected_count: float")
.Output("sampled_expected_count: float")
.Attr("num_true: int >= 1")
.Attr("num_sampled: int >= 1")
.Attr("unique: bool")
.Attr("range_max: int >= 1")
.Attr("seed: int = 0")
.Attr("seed2: int = 0")
.SetShapeFn(CandidateSamplerShapeFn)
.SetIsStateful();
REGISTER_OP("FixedUnigramCandidateSampler")
.Input("true_classes: int64")
.Output("sampled_candidates: int64")
.Output("true_expected_count: float")
.Output("sampled_expected_count: float")
.Attr("num_true: int >= 1")
.Attr("num_sampled: int >= 1")
.Attr("unique: bool")
.Attr("range_max: int >= 1")
.Attr("vocab_file: string = ''")
.Attr("distortion: float = 1.0")
.Attr("num_reserved_ids: int = 0")
.Attr("num_shards: int >= 1 = 1")
.Attr("shard: int >= 0 = 0")
.Attr("unigrams: list(float) = []")
.Attr("seed: int = 0")
.Attr("seed2: int = 0")
.SetShapeFn(CandidateSamplerShapeFn)
.SetIsStateful();
REGISTER_OP("AllCandidateSampler")
.Input("true_classes: int64")
.Output("sampled_candidates: int64")
.Output("true_expected_count: float")
.Output("sampled_expected_count: float")
.Attr("num_true: int >= 1")
.Attr("num_sampled: int >= 1")
.Attr("unique: bool")
.Attr("seed: int = 0")
.Attr("seed2: int = 0")
.SetShapeFn(CandidateSamplerShapeFn)
.SetIsStateful();
REGISTER_OP("ComputeAccidentalHits")
.Input("true_classes: int64")
.Input("sampled_candidates: int64")
.Output("indices: int32")
.Output("ids: int64")
.Output("weights: float")
.Attr("num_true: int")
.Attr("seed: int = 0")
.Attr("seed2: int = 0")
.SetShapeFn([](InferenceContext* c) {
int64_t num_true;
TF_RETURN_IF_ERROR(c->GetAttr("num_true", &num_true));
// Validate true_classes, must be a matrix.
ShapeHandle true_classes;
TF_RETURN_IF_ERROR(c->WithRank(c->input(0), 2, &true_classes));
DimensionHandle unused;
TF_RETURN_IF_ERROR(
c->WithValue(c->Dim(true_classes, 1), num_true, &unused));
// Validate sampled_candidates, must be a vector.
ShapeHandle sampled_candidates;
TF_RETURN_IF_ERROR(c->WithRank(c->input(1), 1, &sampled_candidates));
// All three outputs are the same shape.
ShapeHandle v = c->Vector(InferenceContext::kUnknownDim);
c->set_output(0, v);
c->set_output(1, v);
c->set_output(2, v);
return absl::OkStatus();
});
} // namespace tensorflow
@@ -0,0 +1,72 @@
/* Copyright 2016 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (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.
==============================================================================*/
#include "tensorflow/core/framework/node_def_builder.h"
#include "tensorflow/core/framework/op.h"
#include "tensorflow/core/framework/shape_inference_testutil.h"
#include "tensorflow/core/lib/core/status_test_util.h"
#include "tensorflow/core/platform/test.h"
namespace tensorflow {
TEST(CandidateSamplerOpsTest, CandidateSampler_ShapeFn) {
for (const char* op_name : {
"AllCandidateSampler",
"FixedUnigramCandidateSampler",
"LearnedUnigramCandidateSampler",
"LogUniformCandidateSampler",
"ThreadUnsafeUnigramCandidateSampler",
"UniformCandidateSampler",
}) {
ShapeInferenceTestOp op(op_name);
TF_ASSERT_OK(NodeDefBuilder("test", op.name)
.Input({"a", 0, DT_INT64})
.Attr("num_sampled", 5)
.Attr("num_true", 10)
.Finalize(&op.node_def));
// num_sampled = 5, num_true = 10.
INFER_OK(op, "?", "[5];[?,10];[5]");
// input.dim(0) becomes output[2].dim(0).
INFER_OK(op, "[?,?]", "[5];[d0_0,10];[5]");
INFER_OK(op, "[8,9]", "[5];[d0_0,10];[5]");
// Rank check.
INFER_ERROR("must be rank 2", op, "[1]");
}
}
TEST(CandidateSamplerOpsTest, ComputeAccidentalHits_ShapeFn) {
ShapeInferenceTestOp op("ComputeAccidentalHits");
TF_ASSERT_OK(NodeDefBuilder("test", op.name)
.Input({"a", 0, DT_INT64})
.Input({"b", 0, DT_INT64})
.Attr("num_true", 10)
.Finalize(&op.node_def));
// output is always 3 [?] vectors.
INFER_OK(op, "?;?", "[?];[?];[?]");
INFER_OK(op, "[?,?];?", "[?];[?];[?]");
INFER_OK(op, "[?,10];?", "[?];[?];[?]");
INFER_OK(op, "[5,?];?", "[?];[?];[?]");
// Error checks on first input -> must be rank 2, and input[0].dim(1) ==
// num_true.
INFER_ERROR("must be rank 2", op, "[1];?");
INFER_ERROR("must be 10", op, "[?,11];?");
}
} // end namespace tensorflow
+71
View File
@@ -0,0 +1,71 @@
/* 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.
==============================================================================*/
#include "tensorflow/core/framework/op.h"
#include "tensorflow/core/framework/shape_inference.h"
namespace tensorflow {
REGISTER_OP("GenerateVocabRemapping")
.Input("new_vocab_file: string")
.Input("old_vocab_file: string")
.Attr("new_vocab_offset: int >= 0")
.Attr("num_new_vocab: int >= 0")
.Attr("old_vocab_size: int >= -1 = -1")
.Output("remapping: int64")
.Output("num_present: int32")
.SetShapeFn([](shape_inference::InferenceContext* c) {
shape_inference::ShapeHandle unused;
TF_RETURN_IF_ERROR(c->WithRank(c->input(0), 0, &unused));
TF_RETURN_IF_ERROR(c->WithRank(c->input(1), 0, &unused));
int64_t new_vocab_offset;
TF_RETURN_IF_ERROR(c->GetAttr("new_vocab_offset", &new_vocab_offset));
int64_t num_new_vocab;
TF_RETURN_IF_ERROR(c->GetAttr("num_new_vocab", &num_new_vocab));
c->set_output(0, c->Vector(num_new_vocab));
c->set_output(1, c->Scalar());
return absl::OkStatus();
});
REGISTER_OP("LoadAndRemapMatrix")
.Input("ckpt_path: string")
.Input("old_tensor_name: string")
.Input("row_remapping: int64")
.Input("col_remapping: int64")
.Input("initializing_values: float")
.Attr("num_rows: int >= 0")
.Attr("num_cols: int >= 1")
.Attr("max_rows_in_memory: int = -1")
.Output("output_matrix: float")
// TODO(b/30502450): Setting the op as being stateful prevents it from being
// executed more often than expected (possibly due to stateful ops not being
// subject to constant folding?). This op is usually slow and may require
// multiple disk reads, so we want to minimize the number of times it's
// executed redundantly.
.SetIsStateful()
.SetShapeFn([](shape_inference::InferenceContext* c) {
shape_inference::ShapeHandle unused;
TF_RETURN_IF_ERROR(c->WithRank(c->input(1), 0, &unused));
int64_t num_rows;
TF_RETURN_IF_ERROR(c->GetAttr("num_rows", &num_rows));
int64_t num_cols;
TF_RETURN_IF_ERROR(c->GetAttr("num_cols", &num_cols));
c->set_output(0, c->Matrix(num_rows, num_cols));
return absl::OkStatus();
});
} // namespace tensorflow
+43
View File
@@ -0,0 +1,43 @@
// 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.
// ==============================================================================
#include "tensorflow/core/framework/common_shape_fns.h"
#include "tensorflow/core/framework/op.h"
namespace tensorflow {
REGISTER_OP("KmeansPlusPlusInitialization")
.Input("points: float32")
.Input("num_to_sample: int64")
.Input("seed: int64")
.Input("num_retries_per_sample: int64")
.Output("samples: float32")
.SetShapeFn(shape_inference::UnknownShape);
REGISTER_OP("KMC2ChainInitialization")
.Input("distances: float32")
.Input("seed: int64")
.Output("index: int64")
.SetShapeFn(shape_inference::ScalarShape);
REGISTER_OP("NearestNeighbors")
.Input("points: float32")
.Input("centers: float32")
.Input("k: int64")
.Output("nearest_center_indices: int64")
.Output("nearest_center_distances: float32")
.SetShapeFn(shape_inference::UnknownShape);
} // namespace tensorflow
+287
View File
@@ -0,0 +1,287 @@
/* 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.
==============================================================================*/
#include "tensorflow/core/framework/common_shape_fns.h"
#include "tensorflow/core/framework/op.h"
#include "tensorflow/core/framework/shape_inference.h"
namespace tensorflow {
REGISTER_OP("CollectiveReduce")
.Input("input: T")
.Output("data: T")
.Attr("T: {bfloat16, float, float16, float64, int32, int64}")
.Attr("group_size: int")
.Attr("group_key: int")
.Attr("instance_key: int")
.Attr("merge_op: {'Min', 'Max', 'Mul', 'Add'}")
.Attr("final_op: {'Id', 'Div'}")
.Attr("subdiv_offsets: list(int)")
.Attr("wait_for: list(int) = []")
.Attr("communication_hint: string = 'auto'")
.Attr("timeout_seconds: float = 0")
.SetIsStateful()
.SetIsDistributedCommunication()
.SetShapeFn(shape_inference::UnchangedShape);
REGISTER_OP("CollectiveGather")
.Input("input: T")
.Output("data: T")
.Attr("T: {float, float16, float64, int32, int64}")
.Attr("group_size: int")
.Attr("group_key: int")
.Attr("instance_key: int")
.Attr("shape: shape")
.Attr("communication_hint: string = 'auto'")
.Attr("timeout_seconds: float = 0")
.SetIsStateful()
.SetIsDistributedCommunication()
.SetShapeFn([](shape_inference::InferenceContext* c) {
// Scalar input is not supported.
shape_inference::ShapeHandle unused;
TF_RETURN_IF_ERROR(c->WithRankAtLeast(c->input(0), 1, &unused));
shape_inference::ShapeHandle in_subshape;
TF_RETURN_IF_ERROR(c->Subshape(c->input(0), 1, &in_subshape));
auto input_first_dim_value = c->Value(c->Dim(c->input(0), 0));
// This output should have the same shape as its input except the first
// dimension should be multiplied by group size.
shape_inference::ShapeHandle output_first_dim_as_shape;
if (input_first_dim_value ==
shape_inference::InferenceContext::kUnknownDim) {
output_first_dim_as_shape =
c->Vector(shape_inference::InferenceContext::kUnknownDim);
} else {
int group_size;
TF_CHECK_OK(c->GetAttr("group_size", &group_size));
std::vector<shape_inference::DimensionHandle> output_first_dim;
output_first_dim.push_back(
c->MakeDim(group_size * input_first_dim_value));
output_first_dim_as_shape = c->MakeShape(output_first_dim);
}
shape_inference::ShapeHandle out;
TF_RETURN_IF_ERROR(
c->Concatenate(output_first_dim_as_shape, in_subshape, &out));
c->set_output(0, out);
return absl::OkStatus();
});
REGISTER_OP("CollectiveBcastSend")
.Input("input: T")
.Output("data: T")
.Attr("T: {bool, float, float16, float64, int32, int64}")
.Attr("group_size: int")
.Attr("group_key: int")
.Attr("instance_key: int")
.Attr("shape: shape")
.Attr("communication_hint: string = 'auto'")
.Attr("timeout_seconds: float = 0")
.SetIsStateful()
.SetIsDistributedCommunication()
.SetShapeFn(shape_inference::ExplicitShape);
REGISTER_OP("CollectiveBcastRecv")
.Output("data: T")
.Attr("T: {bool, float, float16, float64, int32, int64}")
.Attr("group_size: int")
.Attr("group_key: int")
.Attr("instance_key: int")
.Attr("shape: shape")
.Attr("communication_hint: string = 'auto'")
.Attr("timeout_seconds: float = 0")
.SetIsStateful()
.SetIsDistributedCommunication()
.SetShapeFn(shape_inference::ExplicitShape);
REGISTER_OP("CollectiveAssignGroupV2")
.Input("group_assignment: int32")
.Input("device_index: int32")
.Input("base_key: int32")
.Output("group_size: int32")
.Output("group_key: int32")
// To avoid tensorflow::constant_folding.
.SetDoNotOptimize() // Also marked in auto_control_dep.py and
// function_optimizer.cc
.SetIsDistributedCommunication()
.SetShapeFn([](shape_inference::InferenceContext* c) {
c->set_output(0, c->Scalar());
c->set_output(1, c->Scalar());
return absl::OkStatus();
});
REGISTER_OP("CollectiveReduceV2")
.Input("input: T")
.Output("data: T")
.Attr("T: {bfloat16, float, float16, float64, int32, int64}")
.Input("group_size: int32")
.Input("group_key: int32")
.Input("instance_key: int32")
.Input("ordering_token: Nordering_token * resource")
.Attr("merge_op: {'Min', 'Max', 'Mul', 'Add'}")
.Attr("final_op: {'Id', 'Div'}")
.Attr("communication_hint: string = 'auto'")
.Attr("timeout_seconds: float = 0")
.Attr("is_stateless: bool = false")
.Attr("Nordering_token: int >= 0 = 0")
.Attr("max_subdivs_per_device: int = -1")
.SetIsStateful()
.SetIsDistributedCommunication()
.SetShapeFn(shape_inference::UnchangedShape);
REGISTER_OP("CollectiveReduceScatterV2")
.Input("input: T")
.Output("data: T")
.Attr("T: {bfloat16, float, float16, float64, int32, int64}")
.Input("group_size: int32")
.Input("group_key: int32")
.Input("instance_key: int32")
.Input("ordering_token: Nordering_token * resource")
.Attr("merge_op: {'Min', 'Max', 'Mul', 'Add'}")
.Attr("final_op: {'Id', 'Div'}")
.Attr("communication_hint: string = 'auto'")
.Attr("timeout_seconds: float = 0")
.Attr("is_stateless: bool = false")
.Attr("Nordering_token: int >= 0 = 0")
.Attr("max_subdivs_per_device: int = -1")
.SetIsStateful()
.SetIsDistributedCommunication()
.SetShapeFn([](shape_inference::InferenceContext* c) {
// Scalar input is not supported.
shape_inference::ShapeHandle unused;
TF_RETURN_IF_ERROR(c->WithRankAtLeast(c->input(0), 1, &unused));
// This output should have the same shape as its input except the first
// dimension is unknown, since the group size is unknown.
shape_inference::ShapeHandle out;
TF_RETURN_IF_ERROR(
c->ReplaceDim(c->input(0), /*dim_index=*/0, c->UnknownDim(), &out));
c->set_output(0, out);
return absl::OkStatus();
});
REGISTER_OP("CollectiveGatherV2")
.Input("input: T")
.Output("data: T")
.Attr("T: {float, float16, float64, int32, int64}")
.Input("group_size: int32")
.Input("group_key: int32")
.Input("instance_key: int32")
.Input("ordering_token: Nordering_token * resource")
.Attr("communication_hint: string = 'auto'")
.Attr("timeout_seconds: float = 0")
.Attr("is_stateless: bool = false")
.Attr("Nordering_token: int >= 0 = 0")
.SetIsStateful()
.SetIsDistributedCommunication()
.SetShapeFn([](shape_inference::InferenceContext* c) {
// Scalar input is not supported.
shape_inference::ShapeHandle unused;
TF_RETURN_IF_ERROR(c->WithRankAtLeast(c->input(0), 1, &unused));
// This output should have the same shape as its input except the first
// dimension is unknown, since the group size is unknown.
shape_inference::ShapeHandle out;
TF_RETURN_IF_ERROR(
c->ReplaceDim(c->input(0), /*dim_index*/ 0, c->UnknownDim(), &out));
c->set_output(0, out);
return absl::OkStatus();
});
REGISTER_OP("CollectiveBcastSendV2")
.Input("input: T")
.Output("data: T")
.Attr("T: {bool, float, float16, float64, int32, int64}")
.Input("group_size: int32")
.Input("group_key: int32")
.Input("instance_key: int32")
.Attr("communication_hint: string = 'auto'")
.Attr("timeout_seconds: float = 0")
.SetIsStateful()
.SetIsDistributedCommunication()
.SetShapeFn(shape_inference::UnchangedShape);
REGISTER_OP("CollectiveBcastRecvV2")
.Output("data: T")
.Attr("T: {bool, float, float16, float64, int32, int64}")
.Input("group_size: int32")
.Input("group_key: int32")
.Input("instance_key: int32")
.Input("shape: Tshape")
.Attr("Tshape: {int32, int64} = DT_INT32")
.Attr("communication_hint: string = 'auto'")
.Attr("timeout_seconds: float = 0")
.SetIsStateful()
.SetIsDistributedCommunication()
.SetShapeFn([](shape_inference::InferenceContext* c) {
// The output shape is given by the `shape` input at index 3.
shape_inference::ShapeHandle out;
TF_RETURN_IF_ERROR(c->MakeShapeFromShapeTensor(/*input_idx=*/3, &out));
c->set_output(/*idx=*/0, out);
return absl::OkStatus();
});
REGISTER_OP("CollectiveInitializeCommunicator")
.Input("group_key: int32")
.Input("rank: int32")
.Input("group_size: int32")
.Attr("communication_hint: string = 'auto'")
.Attr("timeout_seconds: float = 0")
.Output("communicator: resource")
.SetDoNotOptimize() // Also marked in auto_control_dep.py and
// function_optimizer.cc
.SetIsDistributedCommunication()
.SetShapeFn(shape_inference::ScalarShape);
REGISTER_OP("CollectiveReduceV3")
.Input("input: T")
.Input("communicator: resource")
.Input("group_assignment: int32")
.Output("data: T")
.Attr("T: {bfloat16, float, float16, float64, int32, int64}")
.Attr("reduction: {'Min', 'Max', 'Mul', 'Add'}")
.Attr("timeout_seconds: float = 0")
.SetIsStateful()
.SetIsDistributedCommunication()
.SetShapeFn(shape_inference::UnchangedShape);
REGISTER_OP("CollectiveAllToAllV2")
.Input("input: T")
.Output("data: T")
.Attr("T: {bfloat16, float, float16, float64, int32, int64}")
.Input("group_size: int32")
.Input("group_key: int32")
.Input("instance_key: int32")
.Input("ordering_token: Nordering_token * resource")
.Attr("communication_hint: string = 'auto'")
.Attr("timeout_seconds: float = 0")
.Attr("is_stateless: bool = false")
.Attr("Nordering_token: int >= 0 = 0")
.SetIsStateful()
.SetIsDistributedCommunication()
.SetShapeFn(shape_inference::UnchangedShape);
REGISTER_OP("CollectiveAllToAllV3")
.Input("input: T")
.Input("communicator: resource")
.Input("group_assignment: int32")
.Output("data: T")
.Attr("T: {bfloat16, float, float16, float64, int32, int64}")
.Attr("timeout_seconds: float = 0")
.SetIsStateful()
.SetIsDistributedCommunication()
.SetShapeFn(shape_inference::UnchangedShape);
} // namespace tensorflow
+68
View File
@@ -0,0 +1,68 @@
# Description:
# For keeping the history of OpDefs for every major version of TensorFlow,
# to validate that we don't make backwards-incompatible changes.
load(
"//tensorflow:tensorflow.bzl",
"tf_cc_binary",
"tf_cc_test",
)
load("//tensorflow/core/platform:rules_cc.bzl", "cc_library")
package(
# copybara:uncomment default_applicable_licenses = ["//tensorflow:license"],
default_visibility = ["//visibility:private"],
licenses = ["notice"],
)
cc_library(
name = "op_compatibility_lib",
srcs = ["op_compatibility_lib.cc"],
hdrs = ["op_compatibility_lib.h"],
visibility = ["//visibility:public"],
deps = [
"//tensorflow/core:framework",
"//tensorflow/core:lib",
"//tensorflow/core:ops",
"//tensorflow/core:protos_all_cc",
"//tensorflow/core/ops:debug_ops_op_lib",
],
)
tf_cc_test(
name = "backwards_compatibility_test",
size = "small",
srcs = [
"backwards_compatibility_test.cc",
],
data = [
"//tensorflow/core/ops:ops.pbtxt",
"//tensorflow/core/ops/compat/ops_history_v1:ops_history_v1_srcs",
"//tensorflow/core/ops/compat/ops_history_v2:ops_history_v2_srcs",
] + glob([
"ops_history.v*.pbtxt",
]),
tags = [
"no_windows", # TODO(b/150030420): Issues with the path separator
],
deps = [
":op_compatibility_lib",
"//tensorflow/core:framework",
"//tensorflow/core:lib",
"//tensorflow/core:test",
"//tensorflow/core:test_main",
"//tensorflow/core/public:release_version",
],
)
tf_cc_binary(
name = "update_ops",
srcs = ["update_ops_main.cc"],
deps = [
":op_compatibility_lib",
"//tensorflow/core:framework",
"//tensorflow/core:lib",
"//tensorflow/core/platform:path",
"//tensorflow/core/public:release_version",
],
)
@@ -0,0 +1,41 @@
/* 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.
==============================================================================*/
#include "tensorflow/core/lib/core/status.h"
#include "tensorflow/core/lib/core/status_test_util.h"
#include "tensorflow/core/ops/compat/op_compatibility_lib.h"
#include "tensorflow/core/platform/env.h"
#include "tensorflow/core/platform/protobuf.h"
#include "tensorflow/core/platform/test.h"
#include "tensorflow/core/public/release_version.h"
namespace tensorflow {
namespace {
TEST(BackwardsCompatibilityTest, IsCompatible) {
OpCompatibilityLib compatibility("tensorflow/core/ops",
absl::StrCat("v", TF_MAJOR_VERSION),
nullptr);
Env* env = Env::Default();
int changed_ops = 0;
int added_ops = 0;
TF_ASSERT_OK(
compatibility.ValidateCompatible(env, &changed_ops, &added_ops, nullptr));
printf("%d changed ops\n%d added ops\n", changed_ops, added_ops);
}
} // namespace
} // namespace tensorflow
@@ -0,0 +1,249 @@
/* 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.
==============================================================================*/
#include "tensorflow/core/ops/compat/op_compatibility_lib.h"
#include <stdio.h>
#include "tensorflow/core/framework/op.h"
#include "tensorflow/core/framework/op_def_util.h"
#include "tensorflow/core/lib/core/errors.h"
#include "tensorflow/core/lib/core/status.h"
#include "tensorflow/core/lib/io/path.h"
#include "tensorflow/core/lib/strings/str_util.h"
#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/platform/protobuf.h"
namespace tensorflow {
static std::string OpsHistoryDirectory(const std::string& ops_prefix,
const std::string& history_version) {
return io::JoinPath(ops_prefix,
absl::StrCat("compat/ops_history_", history_version));
}
static std::string OpsHistoryFile(const std::string& ops_prefix,
const std::string& history_version) {
return io::JoinPath(ops_prefix, absl::StrCat("compat/ops_history.",
history_version, ".pbtxt"));
}
static std::string FileNameFromOpName(const std::string& op_name) {
return absl::StrCat(op_name, ".pbtxt");
}
static void AddNewOpToHistory(const OpDef& op,
OpCompatibilityLib::OpHistory* out_op_history) {
if (out_op_history != nullptr) {
out_op_history->emplace_back(FileNameFromOpName(op.name()), OpList());
*out_op_history->back().second.add_op() = op;
}
}
static absl::Status ReadOpHistory(Env* env, const std::string& file,
const std::string& directory,
OpCompatibilityLib::OpHistory* out) {
// Read op history form `directory` if it exists there.
std::vector<std::string> matching_files;
absl::Status status = env->GetMatchingPaths(
io::JoinPath(directory, "*.pbtxt"), &matching_files);
if (status.ok() && !matching_files.empty()) {
printf("Reading op history from %s/*.pbtxt...\n", directory.c_str());
std::sort(matching_files.begin(), matching_files.end());
for (const std::string& full_file : matching_files) {
std::string op_history_str;
TF_RETURN_IF_ERROR(ReadFileToString(env, full_file, &op_history_str));
OpList in_op_history;
protobuf::TextFormat::ParseFromString(op_history_str, &in_op_history);
const std::string file_tail =
FileNameFromOpName(in_op_history.op(0).name());
const std::string expected = io::JoinPath(directory, file_tail);
if (full_file != expected) {
return absl::InternalError(
absl::StrCat("Expected file paths to match but '", full_file,
"' != '", expected, "'"));
}
out->emplace_back(file_tail, in_op_history);
}
} else { // Otherwise, fall back to reading op history from `file`.
printf("Reading op history from %s...\n", file.c_str());
std::string op_history_str;
TF_RETURN_IF_ERROR(ReadFileToString(env, file, &op_history_str));
OpList in_op_history;
protobuf::TextFormat::ParseFromString(op_history_str, &in_op_history);
// Convert from a linear OpList to OpHistory format with one OpList per
// unique op name.
int start = 0;
while (start < in_op_history.op_size()) {
int end = start + 1;
while (end < in_op_history.op_size() &&
in_op_history.op(start).name() == in_op_history.op(end).name()) {
++end;
}
AddNewOpToHistory(in_op_history.op(start), out);
for (++start; start < end; ++start) {
*out->back().second.add_op() = in_op_history.op(start);
}
}
}
return absl::OkStatus();
}
OpCompatibilityLib::OpCompatibilityLib(const std::string& ops_prefix,
const std::string& history_version,
const std::set<std::string>* stable_ops)
: ops_file_(io::JoinPath(ops_prefix, "ops.pbtxt")),
op_history_file_(OpsHistoryFile(ops_prefix, history_version)),
op_history_directory_(OpsHistoryDirectory(ops_prefix, history_version)),
stable_ops_(stable_ops) {
// Get the sorted list of all registered OpDefs.
printf("Getting all registered ops...\n");
OpRegistry::Global()->Export(false, &op_list_);
}
absl::Status OpCompatibilityLib::ValidateCompatible(Env* env, int* changed_ops,
int* added_ops,
OpHistory* out_op_history) {
*changed_ops = 0;
*added_ops = 0;
// Strip docs out of op_list_.
RemoveDescriptionsFromOpList(&op_list_);
if (stable_ops_ != nullptr) {
printf("Verifying no stable ops have been removed...\n");
std::vector<std::string> removed;
// We rely on stable_ops_ and op_list_ being in sorted order.
auto iter = stable_ops_->begin();
for (int cur = 0; iter != stable_ops_->end() && cur < op_list_.op_size();
++cur) {
const std::string& op_name = op_list_.op(cur).name();
while (op_name > *iter) {
removed.push_back(*iter);
++iter;
}
if (op_name == *iter) {
++iter;
}
}
for (; iter != stable_ops_->end(); ++iter) {
removed.push_back(*iter);
}
if (!removed.empty()) {
return absl::InvalidArgumentError(absl::StrCat(
"Error, stable op(s) removed: ", absl::StrJoin(removed, ", ")));
}
}
OpHistory in_op_history;
TF_RETURN_IF_ERROR(ReadOpHistory(env, op_history_file_, op_history_directory_,
&in_op_history));
int cur = 0;
int hist = 0;
printf("Verifying updates are compatible...\n");
// Note: Op history is one OpList per unique op name in alphabetical order.
// Within the OplList it has versions in oldest-first order.
while (cur < op_list_.op_size() && hist < in_op_history.size()) {
const OpDef& cur_op = op_list_.op(cur);
const std::string& cur_op_name = cur_op.name();
const OpList& history_op_list = in_op_history[hist].second;
const std::string& history_op_name = history_op_list.op(0).name();
if (stable_ops_ != nullptr && stable_ops_->count(cur_op_name) == 0) {
// Ignore unstable op.
for (++cur; cur < op_list_.op_size(); ++cur) {
if (op_list_.op(cur).name() != cur_op_name) break;
}
} else if (cur_op_name < history_op_name) {
// New op: add it.
AddNewOpToHistory(cur_op, out_op_history);
++*added_ops;
++cur;
} else if (cur_op_name > history_op_name) {
if (stable_ops_ != nullptr) {
// Okay to remove ops from the history that have been made unstable.
++hist;
} else {
// Op removed: error.
return absl::InvalidArgumentError(absl::StrCat(
"Error, removed op: ", SummarizeOpDef(history_op_list.op(0))));
}
} else {
// Op match.
if (out_op_history != nullptr) {
// Copy from in_op_history to *out_op_history.
out_op_history->push_back(in_op_history[hist]);
}
const int end = history_op_list.op_size();
// Is the last op in the history the same as the current op?
// Compare using their serialized representations.
std::string history_str, cur_str;
history_op_list.op(end - 1).SerializeToString(&history_str);
cur_op.SerializeToString(&cur_str);
if (history_str != cur_str) {
// Op changed, verify the change is compatible.
for (int i = 0; i < end; ++i) {
TF_RETURN_IF_ERROR(OpDefCompatible(history_op_list.op(i), cur_op));
}
// Verify default value of attrs has not been removed or modified
// as compared to only the last historical version.
TF_RETURN_IF_ERROR(
OpDefAttrDefaultsUnchanged(history_op_list.op(end - 1), cur_op));
// Check that attrs missing from history_op_list.op(0) don't change
// their defaults.
if (end > 1) {
TF_RETURN_IF_ERROR(OpDefAddedDefaultsUnchanged(
history_op_list.op(0), history_op_list.op(end - 1), cur_op));
}
// Compatible! Add changed op to the end of the history.
if (out_op_history != nullptr) {
*out_op_history->back().second.add_op() = cur_op;
}
++*changed_ops;
}
// Advance past this op.
++hist;
++cur;
}
}
// Error if missing ops.
if (stable_ops_ == nullptr && hist < in_op_history.size()) {
return absl::InvalidArgumentError(
absl::StrCat("Error, removed op: ",
SummarizeOpDef(in_op_history[hist].second.op(0))));
}
// Add remaining new ops.
for (; cur < op_list_.op_size(); ++cur) {
const std::string& op_name = op_list_.op(cur).name();
if (stable_ops_ != nullptr && stable_ops_->count(op_name) == 0) {
// Ignore unstable op.
} else {
AddNewOpToHistory(op_list_.op(cur), out_op_history);
++*added_ops;
}
}
return absl::OkStatus();
}
} // namespace tensorflow
@@ -0,0 +1,89 @@
/* 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_CORE_OPS_COMPAT_OP_COMPATIBILITY_LIB_H_
#define TENSORFLOW_CORE_OPS_COMPAT_OP_COMPATIBILITY_LIB_H_
#include <set>
#include "tensorflow/core/framework/op_def.pb.h"
#include "tensorflow/core/platform/env.h"
#include "tensorflow/core/platform/types.h"
namespace tensorflow {
class OpCompatibilityLib {
public:
// `ops_prefix` is a filename prefix indicating where to find the
// ops files.
// `history_version` is used to construct the ops history file name.
// `*stable_ops` has an optional list of ops that we care about.
// If stable_ops == nullptr, we use all registered ops.
// Otherwise ValidateCompatible() ignores ops not in *stable_ops
// and require all ops in *stable_ops to exist.
OpCompatibilityLib(const std::string& ops_prefix,
const std::string& history_version,
const std::set<std::string>* stable_ops);
// Name of the file that contains the checked-in versions of *all*
// ops, with docs.
const std::string& ops_file() const { return ops_file_; }
// Name of the file that contains all versions of *stable* ops,
// without docs. Op history is in (alphabetical, oldest-first)
// order.
const std::string& op_history_file() const { return op_history_file_; }
// Name of the directory that contains all versions of *stable* ops,
// without docs. Op history is one file per op, in oldest-first
// order within the file.
const std::string& op_history_directory() const {
return op_history_directory_;
}
// Should match the contents of ops_file(). Run before calling
// ValidateCompatible().
std::string OpsString() const {
std::string result;
google::protobuf::TextFormat::PrintToString(op_list_, &result);
return result;
}
// Returns the number of ops in OpsString(), includes all ops, not
// just stable ops.
int num_all_ops() const { return op_list_.op_size(); }
// <file name, file contents> pairs representing op history.
typedef std::vector<std::pair<std::string, OpList>> OpHistory;
// Make sure the current version of the *stable* ops are compatible
// with the historical versions, and if out_op_history != nullptr,
// generate a new history adding all changed ops. Sets
// *changed_ops/*added_ops to the number of changed/added ops
// (ignoring doc changes).
absl::Status ValidateCompatible(Env* env, int* changed_ops, int* added_ops,
OpHistory* out_op_history);
private:
const std::string ops_file_;
const std::string op_history_file_;
const std::string op_history_directory_;
const std::set<std::string>* stable_ops_;
OpList op_list_;
};
} // namespace tensorflow
#endif // TENSORFLOW_CORE_OPS_COMPAT_OP_COMPATIBILITY_LIB_H_
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,17 @@
op {
name: "Abort"
attr {
name: "error_msg"
type: "string"
default_value {
s: ""
}
}
attr {
name: "exit_without_error"
type: "bool"
default_value {
b: false
}
}
}
@@ -0,0 +1,101 @@
op {
name: "Abs"
input_arg {
name: "x"
type_attr: "T"
}
output_arg {
name: "y"
type_attr: "T"
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_HALF
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT32
type: DT_INT64
}
}
}
}
op {
name: "Abs"
input_arg {
name: "x"
type_attr: "T"
}
output_arg {
name: "y"
type_attr: "T"
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_HALF
type: DT_BFLOAT16
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT32
type: DT_INT64
}
}
}
}
op {
name: "Abs"
input_arg {
name: "x"
type_attr: "T"
}
output_arg {
name: "y"
type_attr: "T"
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_BFLOAT16
type: DT_HALF
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT32
type: DT_INT64
}
}
}
}
op {
name: "Abs"
input_arg {
name: "x"
type_attr: "T"
}
output_arg {
name: "y"
type_attr: "T"
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_BFLOAT16
type: DT_HALF
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT8
type: DT_INT16
type: DT_INT32
type: DT_INT64
}
}
}
}
@@ -0,0 +1,146 @@
op {
name: "AccumulateNV2"
input_arg {
name: "inputs"
type_attr: "T"
number_attr: "N"
}
output_arg {
name: "sum"
type_attr: "T"
}
attr {
name: "N"
type: "int"
has_minimum: true
minimum: 1
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
}
}
}
attr {
name: "shape"
type: "shape"
}
is_aggregate: true
is_commutative: true
}
op {
name: "AccumulateNV2"
input_arg {
name: "inputs"
type_attr: "T"
number_attr: "N"
}
output_arg {
name: "sum"
type_attr: "T"
}
attr {
name: "N"
type: "int"
has_minimum: true
minimum: 1
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
type: DT_BFLOAT16
}
}
}
attr {
name: "shape"
type: "shape"
}
is_aggregate: true
is_commutative: true
}
op {
name: "AccumulateNV2"
input_arg {
name: "inputs"
type_attr: "T"
number_attr: "N"
}
output_arg {
name: "sum"
type_attr: "T"
}
attr {
name: "N"
type: "int"
has_minimum: true
minimum: 1
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT32
type: DT_UINT8
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_INT64
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_BFLOAT16
type: DT_UINT16
type: DT_COMPLEX128
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
}
}
}
attr {
name: "shape"
type: "shape"
}
is_aggregate: true
is_commutative: true
}
@@ -0,0 +1,160 @@
op {
name: "AccumulatorApplyGradient"
input_arg {
name: "handle"
type: DT_STRING
is_ref: true
}
input_arg {
name: "local_step"
type: DT_INT64
}
input_arg {
name: "gradient"
type_attr: "dtype"
}
attr {
name: "dtype"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
}
}
}
}
op {
name: "AccumulatorApplyGradient"
input_arg {
name: "handle"
type: DT_STRING
is_ref: true
}
input_arg {
name: "local_step"
type: DT_INT64
}
input_arg {
name: "gradient"
type_attr: "dtype"
}
attr {
name: "dtype"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
}
}
}
}
op {
name: "AccumulatorApplyGradient"
input_arg {
name: "handle"
type: DT_STRING
is_ref: true
}
input_arg {
name: "local_step"
type: DT_INT64
}
input_arg {
name: "gradient"
type_attr: "dtype"
}
attr {
name: "dtype"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
type: DT_BFLOAT16
}
}
}
}
op {
name: "AccumulatorApplyGradient"
input_arg {
name: "handle"
type: DT_STRING
is_ref: true
}
input_arg {
name: "local_step"
type: DT_INT64
}
input_arg {
name: "gradient"
type_attr: "dtype"
}
attr {
name: "dtype"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT32
type: DT_UINT8
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_INT64
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_BFLOAT16
type: DT_UINT16
type: DT_COMPLEX128
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
}
}
}
}
@@ -0,0 +1,12 @@
op {
name: "AccumulatorNumAccumulated"
input_arg {
name: "handle"
type: DT_STRING
is_ref: true
}
output_arg {
name: "num_accumulated"
type: DT_INT32
}
}
@@ -0,0 +1,12 @@
op {
name: "AccumulatorSetGlobalStep"
input_arg {
name: "handle"
type: DT_STRING
is_ref: true
}
input_arg {
name: "new_global_step"
type: DT_INT64
}
}
@@ -0,0 +1,160 @@
op {
name: "AccumulatorTakeGradient"
input_arg {
name: "handle"
type: DT_STRING
is_ref: true
}
input_arg {
name: "num_required"
type: DT_INT32
}
output_arg {
name: "average"
type_attr: "dtype"
}
attr {
name: "dtype"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
}
}
}
}
op {
name: "AccumulatorTakeGradient"
input_arg {
name: "handle"
type: DT_STRING
is_ref: true
}
input_arg {
name: "num_required"
type: DT_INT32
}
output_arg {
name: "average"
type_attr: "dtype"
}
attr {
name: "dtype"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
}
}
}
}
op {
name: "AccumulatorTakeGradient"
input_arg {
name: "handle"
type: DT_STRING
is_ref: true
}
input_arg {
name: "num_required"
type: DT_INT32
}
output_arg {
name: "average"
type_attr: "dtype"
}
attr {
name: "dtype"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
type: DT_BFLOAT16
}
}
}
}
op {
name: "AccumulatorTakeGradient"
input_arg {
name: "handle"
type: DT_STRING
is_ref: true
}
input_arg {
name: "num_required"
type: DT_INT32
}
output_arg {
name: "average"
type_attr: "dtype"
}
attr {
name: "dtype"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT32
type: DT_UINT8
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_INT64
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_BFLOAT16
type: DT_UINT16
type: DT_COMPLEX128
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
}
}
}
}
@@ -0,0 +1,105 @@
op {
name: "Acos"
input_arg {
name: "x"
type_attr: "T"
}
output_arg {
name: "y"
type_attr: "T"
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_HALF
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT32
type: DT_INT64
type: DT_COMPLEX64
type: DT_COMPLEX128
}
}
}
}
op {
name: "Acos"
input_arg {
name: "x"
type_attr: "T"
}
output_arg {
name: "y"
type_attr: "T"
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_HALF
type: DT_BFLOAT16
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT32
type: DT_INT64
type: DT_COMPLEX64
type: DT_COMPLEX128
}
}
}
}
op {
name: "Acos"
input_arg {
name: "x"
type_attr: "T"
}
output_arg {
name: "y"
type_attr: "T"
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_BFLOAT16
type: DT_HALF
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT32
type: DT_INT64
type: DT_COMPLEX64
type: DT_COMPLEX128
}
}
}
}
op {
name: "Acos"
input_arg {
name: "x"
type_attr: "T"
}
output_arg {
name: "y"
type_attr: "T"
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_BFLOAT16
type: DT_HALF
type: DT_FLOAT
type: DT_DOUBLE
type: DT_COMPLEX64
type: DT_COMPLEX128
}
}
}
}
@@ -0,0 +1,74 @@
op {
name: "Acosh"
input_arg {
name: "x"
type_attr: "T"
}
output_arg {
name: "y"
type_attr: "T"
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_HALF
type: DT_FLOAT
type: DT_DOUBLE
type: DT_COMPLEX64
type: DT_COMPLEX128
}
}
}
}
op {
name: "Acosh"
input_arg {
name: "x"
type_attr: "T"
}
output_arg {
name: "y"
type_attr: "T"
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_HALF
type: DT_BFLOAT16
type: DT_FLOAT
type: DT_DOUBLE
type: DT_COMPLEX64
type: DT_COMPLEX128
}
}
}
}
op {
name: "Acosh"
input_arg {
name: "x"
type_attr: "T"
}
output_arg {
name: "y"
type_attr: "T"
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_BFLOAT16
type: DT_HALF
type: DT_FLOAT
type: DT_DOUBLE
type: DT_COMPLEX64
type: DT_COMPLEX128
}
}
}
}
@@ -0,0 +1,104 @@
op {
name: "Add"
input_arg {
name: "x"
type_attr: "T"
}
input_arg {
name: "y"
type_attr: "T"
}
output_arg {
name: "z"
type_attr: "T"
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_HALF
type: DT_FLOAT
type: DT_DOUBLE
type: DT_UINT8
type: DT_INT8
type: DT_INT16
type: DT_INT32
type: DT_INT64
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_STRING
}
}
}
}
op {
name: "Add"
input_arg {
name: "x"
type_attr: "T"
}
input_arg {
name: "y"
type_attr: "T"
}
output_arg {
name: "z"
type_attr: "T"
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_HALF
type: DT_BFLOAT16
type: DT_FLOAT
type: DT_DOUBLE
type: DT_UINT8
type: DT_INT8
type: DT_INT16
type: DT_INT32
type: DT_INT64
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_STRING
}
}
}
}
op {
name: "Add"
input_arg {
name: "x"
type_attr: "T"
}
input_arg {
name: "y"
type_attr: "T"
}
output_arg {
name: "z"
type_attr: "T"
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_BFLOAT16
type: DT_HALF
type: DT_FLOAT
type: DT_DOUBLE
type: DT_UINT8
type: DT_INT8
type: DT_INT16
type: DT_INT32
type: DT_INT64
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_STRING
}
}
}
}
@@ -0,0 +1,38 @@
op {
name: "AddManySparseToTensorsMap"
input_arg {
name: "sparse_indices"
type: DT_INT64
}
input_arg {
name: "sparse_values"
type_attr: "T"
}
input_arg {
name: "sparse_shape"
type: DT_INT64
}
output_arg {
name: "sparse_handles"
type: DT_INT64
}
attr {
name: "T"
type: "type"
}
attr {
name: "container"
type: "string"
default_value {
s: ""
}
}
attr {
name: "shared_name"
type: "string"
default_value {
s: ""
}
}
is_stateful: true
}
@@ -0,0 +1,222 @@
op {
name: "AddN"
input_arg {
name: "inputs"
type_attr: "T"
number_attr: "N"
}
output_arg {
name: "sum"
type_attr: "T"
}
attr {
name: "N"
type: "int"
has_minimum: true
minimum: 1
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
}
}
}
is_aggregate: true
is_commutative: true
}
op {
name: "AddN"
input_arg {
name: "inputs"
type_attr: "T"
number_attr: "N"
}
output_arg {
name: "sum"
type_attr: "T"
}
attr {
name: "N"
type: "int"
has_minimum: true
minimum: 1
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
type: DT_VARIANT
}
}
}
is_aggregate: true
is_commutative: true
}
op {
name: "AddN"
input_arg {
name: "inputs"
type_attr: "T"
number_attr: "N"
}
output_arg {
name: "sum"
type_attr: "T"
}
attr {
name: "N"
type: "int"
has_minimum: true
minimum: 1
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
type: DT_VARIANT
}
}
}
is_aggregate: true
is_commutative: true
}
op {
name: "AddN"
input_arg {
name: "inputs"
type_attr: "T"
number_attr: "N"
}
output_arg {
name: "sum"
type_attr: "T"
}
attr {
name: "N"
type: "int"
has_minimum: true
minimum: 1
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
type: DT_BFLOAT16
type: DT_VARIANT
}
}
}
is_aggregate: true
is_commutative: true
}
op {
name: "AddN"
input_arg {
name: "inputs"
type_attr: "T"
number_attr: "N"
}
output_arg {
name: "sum"
type_attr: "T"
}
attr {
name: "N"
type: "int"
has_minimum: true
minimum: 1
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT32
type: DT_UINT8
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_INT64
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_BFLOAT16
type: DT_UINT16
type: DT_COMPLEX128
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
type: DT_VARIANT
}
}
}
is_aggregate: true
is_commutative: true
}
@@ -0,0 +1,38 @@
op {
name: "AddSparseToTensorsMap"
input_arg {
name: "sparse_indices"
type: DT_INT64
}
input_arg {
name: "sparse_values"
type_attr: "T"
}
input_arg {
name: "sparse_shape"
type: DT_INT64
}
output_arg {
name: "sparse_handle"
type: DT_INT64
}
attr {
name: "T"
type: "type"
}
attr {
name: "container"
type: "string"
default_value {
s: ""
}
}
attr {
name: "shared_name"
type: "string"
default_value {
s: ""
}
}
is_stateful: true
}
@@ -0,0 +1,107 @@
op {
name: "AddV2"
input_arg {
name: "x"
type_attr: "T"
}
input_arg {
name: "y"
type_attr: "T"
}
output_arg {
name: "z"
type_attr: "T"
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_HALF
type: DT_FLOAT
type: DT_DOUBLE
type: DT_UINT8
type: DT_INT8
type: DT_INT16
type: DT_INT32
type: DT_INT64
type: DT_COMPLEX64
type: DT_COMPLEX128
}
}
}
is_aggregate: true
is_commutative: true
}
op {
name: "AddV2"
input_arg {
name: "x"
type_attr: "T"
}
input_arg {
name: "y"
type_attr: "T"
}
output_arg {
name: "z"
type_attr: "T"
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_HALF
type: DT_BFLOAT16
type: DT_FLOAT
type: DT_DOUBLE
type: DT_UINT8
type: DT_INT8
type: DT_INT16
type: DT_INT32
type: DT_INT64
type: DT_COMPLEX64
type: DT_COMPLEX128
}
}
}
is_aggregate: true
is_commutative: true
}
op {
name: "AddV2"
input_arg {
name: "x"
type_attr: "T"
}
input_arg {
name: "y"
type_attr: "T"
}
output_arg {
name: "z"
type_attr: "T"
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_BFLOAT16
type: DT_HALF
type: DT_FLOAT
type: DT_DOUBLE
type: DT_UINT8
type: DT_INT8
type: DT_INT16
type: DT_INT32
type: DT_INT64
type: DT_COMPLEX64
type: DT_COMPLEX128
}
}
}
is_aggregate: true
is_commutative: true
}
@@ -0,0 +1,41 @@
op {
name: "AdjustContrast"
input_arg {
name: "images"
type_attr: "T"
}
input_arg {
name: "contrast_factor"
type: DT_FLOAT
}
input_arg {
name: "min_value"
type: DT_FLOAT
}
input_arg {
name: "max_value"
type: DT_FLOAT
}
output_arg {
name: "output"
type: DT_FLOAT
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_UINT8
type: DT_INT8
type: DT_INT16
type: DT_INT32
type: DT_INT64
type: DT_FLOAT
type: DT_DOUBLE
}
}
}
deprecation {
version: 2
}
}
@@ -0,0 +1,43 @@
op {
name: "AdjustContrastv2"
input_arg {
name: "images"
type: DT_FLOAT
}
input_arg {
name: "contrast_factor"
type: DT_FLOAT
}
output_arg {
name: "output"
type: DT_FLOAT
}
}
op {
name: "AdjustContrastv2"
input_arg {
name: "images"
type_attr: "T"
}
input_arg {
name: "contrast_factor"
type: DT_FLOAT
}
output_arg {
name: "output"
type_attr: "T"
}
attr {
name: "T"
type: "type"
default_value {
type: DT_FLOAT
}
allowed_values {
list {
type: DT_HALF
type: DT_FLOAT
}
}
}
}
@@ -0,0 +1,43 @@
op {
name: "AdjustHue"
input_arg {
name: "images"
type: DT_FLOAT
}
input_arg {
name: "delta"
type: DT_FLOAT
}
output_arg {
name: "output"
type: DT_FLOAT
}
}
op {
name: "AdjustHue"
input_arg {
name: "images"
type_attr: "T"
}
input_arg {
name: "delta"
type: DT_FLOAT
}
output_arg {
name: "output"
type_attr: "T"
}
attr {
name: "T"
type: "type"
default_value {
type: DT_FLOAT
}
allowed_values {
list {
type: DT_HALF
type: DT_FLOAT
}
}
}
}
@@ -0,0 +1,43 @@
op {
name: "AdjustSaturation"
input_arg {
name: "images"
type: DT_FLOAT
}
input_arg {
name: "scale"
type: DT_FLOAT
}
output_arg {
name: "output"
type: DT_FLOAT
}
}
op {
name: "AdjustSaturation"
input_arg {
name: "images"
type_attr: "T"
}
input_arg {
name: "scale"
type: DT_FLOAT
}
output_arg {
name: "output"
type_attr: "T"
}
attr {
name: "T"
type: "type"
default_value {
type: DT_FLOAT
}
allowed_values {
list {
type: DT_HALF
type: DT_FLOAT
}
}
}
}
@@ -0,0 +1,35 @@
op {
name: "All"
input_arg {
name: "input"
type: DT_BOOL
}
input_arg {
name: "reduction_indices"
type_attr: "Tidx"
}
output_arg {
name: "output"
type: DT_BOOL
}
attr {
name: "keep_dims"
type: "bool"
default_value {
b: false
}
}
attr {
name: "Tidx"
type: "type"
default_value {
type: DT_INT32
}
allowed_values {
list {
type: DT_INT32
type: DT_INT64
}
}
}
}
@@ -0,0 +1,99 @@
op {
name: "AllCandidateSampler"
input_arg {
name: "true_classes"
type: DT_INT64
}
output_arg {
name: "sampled_candidates"
type: DT_INT64
}
output_arg {
name: "true_expected_count"
type: DT_FLOAT
}
output_arg {
name: "sampled_expected_count"
type: DT_FLOAT
}
attr {
name: "num_true"
type: "int"
has_minimum: true
minimum: 1
}
attr {
name: "num_sampled"
type: "int"
has_minimum: true
minimum: 1
}
attr {
name: "unique"
type: "bool"
}
attr {
name: "seed"
type: "int"
default_value {
i: 0
}
}
attr {
name: "seed2"
type: "int"
default_value {
i: 0
}
}
}
op {
name: "AllCandidateSampler"
input_arg {
name: "true_classes"
type: DT_INT64
}
output_arg {
name: "sampled_candidates"
type: DT_INT64
}
output_arg {
name: "true_expected_count"
type: DT_FLOAT
}
output_arg {
name: "sampled_expected_count"
type: DT_FLOAT
}
attr {
name: "num_true"
type: "int"
has_minimum: true
minimum: 1
}
attr {
name: "num_sampled"
type: "int"
has_minimum: true
minimum: 1
}
attr {
name: "unique"
type: "bool"
}
attr {
name: "seed"
type: "int"
default_value {
i: 0
}
}
attr {
name: "seed2"
type: "int"
default_value {
i: 0
}
}
is_stateful: true
}
@@ -0,0 +1,90 @@
op {
name: "AllToAll"
input_arg {
name: "input"
type_attr: "T"
}
input_arg {
name: "group_assignment"
type: DT_INT32
}
output_arg {
name: "output"
type_attr: "T"
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_BFLOAT16
type: DT_FLOAT
}
}
}
attr {
name: "concat_dimension"
type: "int"
}
attr {
name: "split_dimension"
type: "int"
}
attr {
name: "split_count"
type: "int"
}
}
op {
name: "AllToAll"
input_arg {
name: "input"
type_attr: "T"
}
input_arg {
name: "group_assignment"
type: DT_INT32
}
output_arg {
name: "output"
type_attr: "T"
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT32
type: DT_UINT8
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_INT64
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_BFLOAT16
type: DT_UINT16
type: DT_COMPLEX128
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
type: DT_BOOL
}
}
}
attr {
name: "concat_dimension"
type: "int"
}
attr {
name: "split_dimension"
type: "int"
}
attr {
name: "split_count"
type: "int"
}
}
@@ -0,0 +1,37 @@
op {
name: "Angle"
input_arg {
name: "input"
type_attr: "T"
}
output_arg {
name: "output"
type_attr: "Tout"
}
attr {
name: "T"
type: "type"
default_value {
type: DT_COMPLEX64
}
allowed_values {
list {
type: DT_COMPLEX64
type: DT_COMPLEX128
}
}
}
attr {
name: "Tout"
type: "type"
default_value {
type: DT_FLOAT
}
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
}
}
}
}
@@ -0,0 +1,20 @@
op {
name: "AnonymousIterator"
output_arg {
name: "handle"
type: DT_RESOURCE
}
attr {
name: "output_types"
type: "list(type)"
has_minimum: true
minimum: 1
}
attr {
name: "output_shapes"
type: "list(shape)"
has_minimum: true
minimum: 1
}
is_stateful: true
}
@@ -0,0 +1,24 @@
op {
name: "AnonymousIteratorV2"
output_arg {
name: "handle"
type: DT_RESOURCE
}
output_arg {
name: "deleter"
type: DT_VARIANT
}
attr {
name: "output_types"
type: "list(type)"
has_minimum: true
minimum: 1
}
attr {
name: "output_shapes"
type: "list(shape)"
has_minimum: true
minimum: 1
}
is_stateful: true
}
@@ -0,0 +1,12 @@
op {
name: "AnonymousMemoryCache"
output_arg {
name: "handle"
type: DT_RESOURCE
}
output_arg {
name: "deleter"
type: DT_VARIANT
}
is_stateful: true
}
@@ -0,0 +1,30 @@
op {
name: "AnonymousMultiDeviceIterator"
output_arg {
name: "handle"
type: DT_RESOURCE
}
output_arg {
name: "deleter"
type: DT_VARIANT
}
attr {
name: "devices"
type: "list(string)"
has_minimum: true
minimum: 1
}
attr {
name: "output_types"
type: "list(type)"
has_minimum: true
minimum: 1
}
attr {
name: "output_shapes"
type: "list(shape)"
has_minimum: true
minimum: 1
}
is_stateful: true
}
@@ -0,0 +1,20 @@
op {
name: "AnonymousRandomSeedGenerator"
input_arg {
name: "seed"
type: DT_INT64
}
input_arg {
name: "seed2"
type: DT_INT64
}
output_arg {
name: "handle"
type: DT_RESOURCE
}
output_arg {
name: "deleter"
type: DT_VARIANT
}
is_stateful: true
}
@@ -0,0 +1,24 @@
op {
name: "AnonymousSeedGenerator"
input_arg {
name: "seed"
type: DT_INT64
}
input_arg {
name: "seed2"
type: DT_INT64
}
input_arg {
name: "reshuffle"
type: DT_BOOL
}
output_arg {
name: "handle"
type: DT_RESOURCE
}
output_arg {
name: "deleter"
type: DT_VARIANT
}
is_stateful: true
}
@@ -0,0 +1,35 @@
op {
name: "Any"
input_arg {
name: "input"
type: DT_BOOL
}
input_arg {
name: "reduction_indices"
type_attr: "Tidx"
}
output_arg {
name: "output"
type: DT_BOOL
}
attr {
name: "keep_dims"
type: "bool"
default_value {
b: false
}
}
attr {
name: "Tidx"
type: "type"
default_value {
type: DT_INT32
}
allowed_values {
list {
type: DT_INT32
type: DT_INT64
}
}
}
}
@@ -0,0 +1,79 @@
op {
name: "ApplyAdaMax"
input_arg {
name: "var"
type_attr: "T"
is_ref: true
}
input_arg {
name: "m"
type_attr: "T"
is_ref: true
}
input_arg {
name: "v"
type_attr: "T"
is_ref: true
}
input_arg {
name: "beta1_power"
type_attr: "T"
}
input_arg {
name: "lr"
type_attr: "T"
}
input_arg {
name: "beta1"
type_attr: "T"
}
input_arg {
name: "beta2"
type_attr: "T"
}
input_arg {
name: "epsilon"
type_attr: "T"
}
input_arg {
name: "grad"
type_attr: "T"
}
output_arg {
name: "out"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT32
type: DT_UINT8
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_INT64
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_BFLOAT16
type: DT_UINT16
type: DT_COMPLEX128
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
}
@@ -0,0 +1,280 @@
op {
name: "ApplyAdadelta"
input_arg {
name: "var"
type_attr: "T"
is_ref: true
}
input_arg {
name: "accum"
type_attr: "T"
is_ref: true
}
input_arg {
name: "accum_update"
type_attr: "T"
is_ref: true
}
input_arg {
name: "lr"
type_attr: "T"
}
input_arg {
name: "rho"
type_attr: "T"
}
input_arg {
name: "epsilon"
type_attr: "T"
}
input_arg {
name: "grad"
type_attr: "T"
}
output_arg {
name: "out"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
}
op {
name: "ApplyAdadelta"
input_arg {
name: "var"
type_attr: "T"
is_ref: true
}
input_arg {
name: "accum"
type_attr: "T"
is_ref: true
}
input_arg {
name: "accum_update"
type_attr: "T"
is_ref: true
}
input_arg {
name: "lr"
type_attr: "T"
}
input_arg {
name: "rho"
type_attr: "T"
}
input_arg {
name: "epsilon"
type_attr: "T"
}
input_arg {
name: "grad"
type_attr: "T"
}
output_arg {
name: "out"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
}
op {
name: "ApplyAdadelta"
input_arg {
name: "var"
type_attr: "T"
is_ref: true
}
input_arg {
name: "accum"
type_attr: "T"
is_ref: true
}
input_arg {
name: "accum_update"
type_attr: "T"
is_ref: true
}
input_arg {
name: "lr"
type_attr: "T"
}
input_arg {
name: "rho"
type_attr: "T"
}
input_arg {
name: "epsilon"
type_attr: "T"
}
input_arg {
name: "grad"
type_attr: "T"
}
output_arg {
name: "out"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
type: DT_BFLOAT16
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
}
op {
name: "ApplyAdadelta"
input_arg {
name: "var"
type_attr: "T"
is_ref: true
}
input_arg {
name: "accum"
type_attr: "T"
is_ref: true
}
input_arg {
name: "accum_update"
type_attr: "T"
is_ref: true
}
input_arg {
name: "lr"
type_attr: "T"
}
input_arg {
name: "rho"
type_attr: "T"
}
input_arg {
name: "epsilon"
type_attr: "T"
}
input_arg {
name: "grad"
type_attr: "T"
}
output_arg {
name: "out"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT32
type: DT_UINT8
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_INT64
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_BFLOAT16
type: DT_UINT16
type: DT_COMPLEX128
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
}
@@ -0,0 +1,293 @@
op {
name: "ApplyAdagrad"
input_arg {
name: "var"
type_attr: "T"
is_ref: true
}
input_arg {
name: "accum"
type_attr: "T"
is_ref: true
}
input_arg {
name: "lr"
type_attr: "T"
}
input_arg {
name: "grad"
type_attr: "T"
}
output_arg {
name: "out"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
}
op {
name: "ApplyAdagrad"
input_arg {
name: "var"
type_attr: "T"
is_ref: true
}
input_arg {
name: "accum"
type_attr: "T"
is_ref: true
}
input_arg {
name: "lr"
type_attr: "T"
}
input_arg {
name: "grad"
type_attr: "T"
}
output_arg {
name: "out"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
}
op {
name: "ApplyAdagrad"
input_arg {
name: "var"
type_attr: "T"
is_ref: true
}
input_arg {
name: "accum"
type_attr: "T"
is_ref: true
}
input_arg {
name: "lr"
type_attr: "T"
}
input_arg {
name: "grad"
type_attr: "T"
}
output_arg {
name: "out"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
type: DT_BFLOAT16
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
}
op {
name: "ApplyAdagrad"
input_arg {
name: "var"
type_attr: "T"
is_ref: true
}
input_arg {
name: "accum"
type_attr: "T"
is_ref: true
}
input_arg {
name: "lr"
type_attr: "T"
}
input_arg {
name: "grad"
type_attr: "T"
}
output_arg {
name: "out"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT32
type: DT_UINT8
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_INT64
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_BFLOAT16
type: DT_UINT16
type: DT_COMPLEX128
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
}
op {
name: "ApplyAdagrad"
input_arg {
name: "var"
type_attr: "T"
is_ref: true
}
input_arg {
name: "accum"
type_attr: "T"
is_ref: true
}
input_arg {
name: "lr"
type_attr: "T"
}
input_arg {
name: "grad"
type_attr: "T"
}
output_arg {
name: "out"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT32
type: DT_UINT8
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_INT64
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_BFLOAT16
type: DT_UINT16
type: DT_COMPLEX128
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
attr {
name: "update_slots"
type: "bool"
default_value {
b: true
}
}
}
@@ -0,0 +1,296 @@
op {
name: "ApplyAdagradDA"
input_arg {
name: "var"
type_attr: "T"
is_ref: true
}
input_arg {
name: "gradient_accumulator"
type_attr: "T"
is_ref: true
}
input_arg {
name: "gradient_squared_accumulator"
type_attr: "T"
is_ref: true
}
input_arg {
name: "grad"
type_attr: "T"
}
input_arg {
name: "lr"
type_attr: "T"
}
input_arg {
name: "l1"
type_attr: "T"
}
input_arg {
name: "l2"
type_attr: "T"
}
input_arg {
name: "global_step"
type: DT_INT64
}
output_arg {
name: "out"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
}
op {
name: "ApplyAdagradDA"
input_arg {
name: "var"
type_attr: "T"
is_ref: true
}
input_arg {
name: "gradient_accumulator"
type_attr: "T"
is_ref: true
}
input_arg {
name: "gradient_squared_accumulator"
type_attr: "T"
is_ref: true
}
input_arg {
name: "grad"
type_attr: "T"
}
input_arg {
name: "lr"
type_attr: "T"
}
input_arg {
name: "l1"
type_attr: "T"
}
input_arg {
name: "l2"
type_attr: "T"
}
input_arg {
name: "global_step"
type: DT_INT64
}
output_arg {
name: "out"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
}
op {
name: "ApplyAdagradDA"
input_arg {
name: "var"
type_attr: "T"
is_ref: true
}
input_arg {
name: "gradient_accumulator"
type_attr: "T"
is_ref: true
}
input_arg {
name: "gradient_squared_accumulator"
type_attr: "T"
is_ref: true
}
input_arg {
name: "grad"
type_attr: "T"
}
input_arg {
name: "lr"
type_attr: "T"
}
input_arg {
name: "l1"
type_attr: "T"
}
input_arg {
name: "l2"
type_attr: "T"
}
input_arg {
name: "global_step"
type: DT_INT64
}
output_arg {
name: "out"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
type: DT_BFLOAT16
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
}
op {
name: "ApplyAdagradDA"
input_arg {
name: "var"
type_attr: "T"
is_ref: true
}
input_arg {
name: "gradient_accumulator"
type_attr: "T"
is_ref: true
}
input_arg {
name: "gradient_squared_accumulator"
type_attr: "T"
is_ref: true
}
input_arg {
name: "grad"
type_attr: "T"
}
input_arg {
name: "lr"
type_attr: "T"
}
input_arg {
name: "l1"
type_attr: "T"
}
input_arg {
name: "l2"
type_attr: "T"
}
input_arg {
name: "global_step"
type: DT_INT64
}
output_arg {
name: "out"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT32
type: DT_UINT8
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_INT64
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_BFLOAT16
type: DT_UINT16
type: DT_COMPLEX128
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
}
@@ -0,0 +1,69 @@
op {
name: "ApplyAdagradV2"
input_arg {
name: "var"
type_attr: "T"
is_ref: true
}
input_arg {
name: "accum"
type_attr: "T"
is_ref: true
}
input_arg {
name: "lr"
type_attr: "T"
}
input_arg {
name: "epsilon"
type_attr: "T"
}
input_arg {
name: "grad"
type_attr: "T"
}
output_arg {
name: "out"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT32
type: DT_UINT8
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_INT64
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_BFLOAT16
type: DT_UINT16
type: DT_COMPLEX128
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
attr {
name: "update_slots"
type: "bool"
default_value {
b: true
}
}
}
@@ -0,0 +1,436 @@
op {
name: "ApplyAdam"
input_arg {
name: "var"
type_attr: "T"
is_ref: true
}
input_arg {
name: "m"
type_attr: "T"
is_ref: true
}
input_arg {
name: "v"
type_attr: "T"
is_ref: true
}
input_arg {
name: "beta1_power"
type_attr: "T"
}
input_arg {
name: "beta2_power"
type_attr: "T"
}
input_arg {
name: "lr"
type_attr: "T"
}
input_arg {
name: "beta1"
type_attr: "T"
}
input_arg {
name: "beta2"
type_attr: "T"
}
input_arg {
name: "epsilon"
type_attr: "T"
}
input_arg {
name: "grad"
type_attr: "T"
}
output_arg {
name: "out"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
}
op {
name: "ApplyAdam"
input_arg {
name: "var"
type_attr: "T"
is_ref: true
}
input_arg {
name: "m"
type_attr: "T"
is_ref: true
}
input_arg {
name: "v"
type_attr: "T"
is_ref: true
}
input_arg {
name: "beta1_power"
type_attr: "T"
}
input_arg {
name: "beta2_power"
type_attr: "T"
}
input_arg {
name: "lr"
type_attr: "T"
}
input_arg {
name: "beta1"
type_attr: "T"
}
input_arg {
name: "beta2"
type_attr: "T"
}
input_arg {
name: "epsilon"
type_attr: "T"
}
input_arg {
name: "grad"
type_attr: "T"
}
output_arg {
name: "out"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
attr {
name: "use_nesterov"
type: "bool"
default_value {
b: false
}
}
}
op {
name: "ApplyAdam"
input_arg {
name: "var"
type_attr: "T"
is_ref: true
}
input_arg {
name: "m"
type_attr: "T"
is_ref: true
}
input_arg {
name: "v"
type_attr: "T"
is_ref: true
}
input_arg {
name: "beta1_power"
type_attr: "T"
}
input_arg {
name: "beta2_power"
type_attr: "T"
}
input_arg {
name: "lr"
type_attr: "T"
}
input_arg {
name: "beta1"
type_attr: "T"
}
input_arg {
name: "beta2"
type_attr: "T"
}
input_arg {
name: "epsilon"
type_attr: "T"
}
input_arg {
name: "grad"
type_attr: "T"
}
output_arg {
name: "out"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
attr {
name: "use_nesterov"
type: "bool"
default_value {
b: false
}
}
}
op {
name: "ApplyAdam"
input_arg {
name: "var"
type_attr: "T"
is_ref: true
}
input_arg {
name: "m"
type_attr: "T"
is_ref: true
}
input_arg {
name: "v"
type_attr: "T"
is_ref: true
}
input_arg {
name: "beta1_power"
type_attr: "T"
}
input_arg {
name: "beta2_power"
type_attr: "T"
}
input_arg {
name: "lr"
type_attr: "T"
}
input_arg {
name: "beta1"
type_attr: "T"
}
input_arg {
name: "beta2"
type_attr: "T"
}
input_arg {
name: "epsilon"
type_attr: "T"
}
input_arg {
name: "grad"
type_attr: "T"
}
output_arg {
name: "out"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
type: DT_BFLOAT16
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
attr {
name: "use_nesterov"
type: "bool"
default_value {
b: false
}
}
}
op {
name: "ApplyAdam"
input_arg {
name: "var"
type_attr: "T"
is_ref: true
}
input_arg {
name: "m"
type_attr: "T"
is_ref: true
}
input_arg {
name: "v"
type_attr: "T"
is_ref: true
}
input_arg {
name: "beta1_power"
type_attr: "T"
}
input_arg {
name: "beta2_power"
type_attr: "T"
}
input_arg {
name: "lr"
type_attr: "T"
}
input_arg {
name: "beta1"
type_attr: "T"
}
input_arg {
name: "beta2"
type_attr: "T"
}
input_arg {
name: "epsilon"
type_attr: "T"
}
input_arg {
name: "grad"
type_attr: "T"
}
output_arg {
name: "out"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT32
type: DT_UINT8
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_INT64
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_BFLOAT16
type: DT_UINT16
type: DT_COMPLEX128
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
attr {
name: "use_nesterov"
type: "bool"
default_value {
b: false
}
}
}
@@ -0,0 +1,209 @@
op {
name: "ApplyAddSign"
input_arg {
name: "var"
type_attr: "T"
is_ref: true
}
input_arg {
name: "m"
type_attr: "T"
is_ref: true
}
input_arg {
name: "lr"
type_attr: "T"
}
input_arg {
name: "alpha"
type_attr: "T"
}
input_arg {
name: "sign_decay"
type_attr: "T"
}
input_arg {
name: "beta"
type_attr: "T"
}
input_arg {
name: "grad"
type_attr: "T"
}
output_arg {
name: "out"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
}
op {
name: "ApplyAddSign"
input_arg {
name: "var"
type_attr: "T"
is_ref: true
}
input_arg {
name: "m"
type_attr: "T"
is_ref: true
}
input_arg {
name: "lr"
type_attr: "T"
}
input_arg {
name: "alpha"
type_attr: "T"
}
input_arg {
name: "sign_decay"
type_attr: "T"
}
input_arg {
name: "beta"
type_attr: "T"
}
input_arg {
name: "grad"
type_attr: "T"
}
output_arg {
name: "out"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
type: DT_BFLOAT16
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
}
op {
name: "ApplyAddSign"
input_arg {
name: "var"
type_attr: "T"
is_ref: true
}
input_arg {
name: "m"
type_attr: "T"
is_ref: true
}
input_arg {
name: "lr"
type_attr: "T"
}
input_arg {
name: "alpha"
type_attr: "T"
}
input_arg {
name: "sign_decay"
type_attr: "T"
}
input_arg {
name: "beta"
type_attr: "T"
}
input_arg {
name: "grad"
type_attr: "T"
}
output_arg {
name: "out"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT32
type: DT_UINT8
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_INT64
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_BFLOAT16
type: DT_UINT16
type: DT_COMPLEX128
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
}
@@ -0,0 +1,316 @@
op {
name: "ApplyCenteredRMSProp"
input_arg {
name: "var"
type_attr: "T"
is_ref: true
}
input_arg {
name: "mg"
type_attr: "T"
is_ref: true
}
input_arg {
name: "ms"
type_attr: "T"
is_ref: true
}
input_arg {
name: "mom"
type_attr: "T"
is_ref: true
}
input_arg {
name: "lr"
type_attr: "T"
}
input_arg {
name: "rho"
type_attr: "T"
}
input_arg {
name: "momentum"
type_attr: "T"
}
input_arg {
name: "epsilon"
type_attr: "T"
}
input_arg {
name: "grad"
type_attr: "T"
}
output_arg {
name: "out"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
}
op {
name: "ApplyCenteredRMSProp"
input_arg {
name: "var"
type_attr: "T"
is_ref: true
}
input_arg {
name: "mg"
type_attr: "T"
is_ref: true
}
input_arg {
name: "ms"
type_attr: "T"
is_ref: true
}
input_arg {
name: "mom"
type_attr: "T"
is_ref: true
}
input_arg {
name: "lr"
type_attr: "T"
}
input_arg {
name: "rho"
type_attr: "T"
}
input_arg {
name: "momentum"
type_attr: "T"
}
input_arg {
name: "epsilon"
type_attr: "T"
}
input_arg {
name: "grad"
type_attr: "T"
}
output_arg {
name: "out"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
}
op {
name: "ApplyCenteredRMSProp"
input_arg {
name: "var"
type_attr: "T"
is_ref: true
}
input_arg {
name: "mg"
type_attr: "T"
is_ref: true
}
input_arg {
name: "ms"
type_attr: "T"
is_ref: true
}
input_arg {
name: "mom"
type_attr: "T"
is_ref: true
}
input_arg {
name: "lr"
type_attr: "T"
}
input_arg {
name: "rho"
type_attr: "T"
}
input_arg {
name: "momentum"
type_attr: "T"
}
input_arg {
name: "epsilon"
type_attr: "T"
}
input_arg {
name: "grad"
type_attr: "T"
}
output_arg {
name: "out"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
type: DT_BFLOAT16
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
}
op {
name: "ApplyCenteredRMSProp"
input_arg {
name: "var"
type_attr: "T"
is_ref: true
}
input_arg {
name: "mg"
type_attr: "T"
is_ref: true
}
input_arg {
name: "ms"
type_attr: "T"
is_ref: true
}
input_arg {
name: "mom"
type_attr: "T"
is_ref: true
}
input_arg {
name: "lr"
type_attr: "T"
}
input_arg {
name: "rho"
type_attr: "T"
}
input_arg {
name: "momentum"
type_attr: "T"
}
input_arg {
name: "epsilon"
type_attr: "T"
}
input_arg {
name: "grad"
type_attr: "T"
}
output_arg {
name: "out"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT32
type: DT_UINT8
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_INT64
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_BFLOAT16
type: DT_UINT16
type: DT_COMPLEX128
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
}
@@ -0,0 +1,378 @@
op {
name: "ApplyFtrl"
input_arg {
name: "var"
type_attr: "T"
is_ref: true
}
input_arg {
name: "accum"
type_attr: "T"
is_ref: true
}
input_arg {
name: "linear"
type_attr: "T"
is_ref: true
}
input_arg {
name: "grad"
type_attr: "T"
}
input_arg {
name: "lr"
type_attr: "T"
}
input_arg {
name: "l1"
type_attr: "T"
}
input_arg {
name: "l2"
type_attr: "T"
}
input_arg {
name: "lr_power"
type_attr: "T"
}
output_arg {
name: "out"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
}
op {
name: "ApplyFtrl"
input_arg {
name: "var"
type_attr: "T"
is_ref: true
}
input_arg {
name: "accum"
type_attr: "T"
is_ref: true
}
input_arg {
name: "linear"
type_attr: "T"
is_ref: true
}
input_arg {
name: "grad"
type_attr: "T"
}
input_arg {
name: "lr"
type_attr: "T"
}
input_arg {
name: "l1"
type_attr: "T"
}
input_arg {
name: "l2"
type_attr: "T"
}
input_arg {
name: "lr_power"
type_attr: "T"
}
output_arg {
name: "out"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
}
op {
name: "ApplyFtrl"
input_arg {
name: "var"
type_attr: "T"
is_ref: true
}
input_arg {
name: "accum"
type_attr: "T"
is_ref: true
}
input_arg {
name: "linear"
type_attr: "T"
is_ref: true
}
input_arg {
name: "grad"
type_attr: "T"
}
input_arg {
name: "lr"
type_attr: "T"
}
input_arg {
name: "l1"
type_attr: "T"
}
input_arg {
name: "l2"
type_attr: "T"
}
input_arg {
name: "lr_power"
type_attr: "T"
}
output_arg {
name: "out"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
type: DT_BFLOAT16
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
}
op {
name: "ApplyFtrl"
input_arg {
name: "var"
type_attr: "T"
is_ref: true
}
input_arg {
name: "accum"
type_attr: "T"
is_ref: true
}
input_arg {
name: "linear"
type_attr: "T"
is_ref: true
}
input_arg {
name: "grad"
type_attr: "T"
}
input_arg {
name: "lr"
type_attr: "T"
}
input_arg {
name: "l1"
type_attr: "T"
}
input_arg {
name: "l2"
type_attr: "T"
}
input_arg {
name: "lr_power"
type_attr: "T"
}
output_arg {
name: "out"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT32
type: DT_UINT8
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_INT64
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_BFLOAT16
type: DT_UINT16
type: DT_COMPLEX128
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
}
op {
name: "ApplyFtrl"
input_arg {
name: "var"
type_attr: "T"
is_ref: true
}
input_arg {
name: "accum"
type_attr: "T"
is_ref: true
}
input_arg {
name: "linear"
type_attr: "T"
is_ref: true
}
input_arg {
name: "grad"
type_attr: "T"
}
input_arg {
name: "lr"
type_attr: "T"
}
input_arg {
name: "l1"
type_attr: "T"
}
input_arg {
name: "l2"
type_attr: "T"
}
input_arg {
name: "lr_power"
type_attr: "T"
}
output_arg {
name: "out"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT32
type: DT_UINT8
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_INT64
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_BFLOAT16
type: DT_UINT16
type: DT_COMPLEX128
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
attr {
name: "multiply_linear_by_lr"
type: "bool"
default_value {
b: false
}
}
}
@@ -0,0 +1,398 @@
op {
name: "ApplyFtrlV2"
input_arg {
name: "var"
type_attr: "T"
is_ref: true
}
input_arg {
name: "accum"
type_attr: "T"
is_ref: true
}
input_arg {
name: "linear"
type_attr: "T"
is_ref: true
}
input_arg {
name: "grad"
type_attr: "T"
}
input_arg {
name: "lr"
type_attr: "T"
}
input_arg {
name: "l1"
type_attr: "T"
}
input_arg {
name: "l2"
type_attr: "T"
}
input_arg {
name: "l2_shrinkage"
type_attr: "T"
}
input_arg {
name: "lr_power"
type_attr: "T"
}
output_arg {
name: "out"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
}
op {
name: "ApplyFtrlV2"
input_arg {
name: "var"
type_attr: "T"
is_ref: true
}
input_arg {
name: "accum"
type_attr: "T"
is_ref: true
}
input_arg {
name: "linear"
type_attr: "T"
is_ref: true
}
input_arg {
name: "grad"
type_attr: "T"
}
input_arg {
name: "lr"
type_attr: "T"
}
input_arg {
name: "l1"
type_attr: "T"
}
input_arg {
name: "l2"
type_attr: "T"
}
input_arg {
name: "l2_shrinkage"
type_attr: "T"
}
input_arg {
name: "lr_power"
type_attr: "T"
}
output_arg {
name: "out"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
}
op {
name: "ApplyFtrlV2"
input_arg {
name: "var"
type_attr: "T"
is_ref: true
}
input_arg {
name: "accum"
type_attr: "T"
is_ref: true
}
input_arg {
name: "linear"
type_attr: "T"
is_ref: true
}
input_arg {
name: "grad"
type_attr: "T"
}
input_arg {
name: "lr"
type_attr: "T"
}
input_arg {
name: "l1"
type_attr: "T"
}
input_arg {
name: "l2"
type_attr: "T"
}
input_arg {
name: "l2_shrinkage"
type_attr: "T"
}
input_arg {
name: "lr_power"
type_attr: "T"
}
output_arg {
name: "out"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
type: DT_BFLOAT16
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
}
op {
name: "ApplyFtrlV2"
input_arg {
name: "var"
type_attr: "T"
is_ref: true
}
input_arg {
name: "accum"
type_attr: "T"
is_ref: true
}
input_arg {
name: "linear"
type_attr: "T"
is_ref: true
}
input_arg {
name: "grad"
type_attr: "T"
}
input_arg {
name: "lr"
type_attr: "T"
}
input_arg {
name: "l1"
type_attr: "T"
}
input_arg {
name: "l2"
type_attr: "T"
}
input_arg {
name: "l2_shrinkage"
type_attr: "T"
}
input_arg {
name: "lr_power"
type_attr: "T"
}
output_arg {
name: "out"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT32
type: DT_UINT8
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_INT64
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_BFLOAT16
type: DT_UINT16
type: DT_COMPLEX128
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
}
op {
name: "ApplyFtrlV2"
input_arg {
name: "var"
type_attr: "T"
is_ref: true
}
input_arg {
name: "accum"
type_attr: "T"
is_ref: true
}
input_arg {
name: "linear"
type_attr: "T"
is_ref: true
}
input_arg {
name: "grad"
type_attr: "T"
}
input_arg {
name: "lr"
type_attr: "T"
}
input_arg {
name: "l1"
type_attr: "T"
}
input_arg {
name: "l2"
type_attr: "T"
}
input_arg {
name: "l2_shrinkage"
type_attr: "T"
}
input_arg {
name: "lr_power"
type_attr: "T"
}
output_arg {
name: "out"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT32
type: DT_UINT8
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_INT64
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_BFLOAT16
type: DT_UINT16
type: DT_COMPLEX128
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
attr {
name: "multiply_linear_by_lr"
type: "bool"
default_value {
b: false
}
}
}
@@ -0,0 +1,208 @@
op {
name: "ApplyGradientDescent"
input_arg {
name: "var"
type_attr: "T"
is_ref: true
}
input_arg {
name: "alpha"
type_attr: "T"
}
input_arg {
name: "delta"
type_attr: "T"
}
output_arg {
name: "out"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
}
op {
name: "ApplyGradientDescent"
input_arg {
name: "var"
type_attr: "T"
is_ref: true
}
input_arg {
name: "alpha"
type_attr: "T"
}
input_arg {
name: "delta"
type_attr: "T"
}
output_arg {
name: "out"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
}
op {
name: "ApplyGradientDescent"
input_arg {
name: "var"
type_attr: "T"
is_ref: true
}
input_arg {
name: "alpha"
type_attr: "T"
}
input_arg {
name: "delta"
type_attr: "T"
}
output_arg {
name: "out"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
type: DT_BFLOAT16
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
}
op {
name: "ApplyGradientDescent"
input_arg {
name: "var"
type_attr: "T"
is_ref: true
}
input_arg {
name: "alpha"
type_attr: "T"
}
input_arg {
name: "delta"
type_attr: "T"
}
output_arg {
name: "out"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT32
type: DT_UINT8
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_INT64
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_BFLOAT16
type: DT_UINT16
type: DT_COMPLEX128
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
}
@@ -0,0 +1,272 @@
op {
name: "ApplyMomentum"
input_arg {
name: "var"
type_attr: "T"
is_ref: true
}
input_arg {
name: "accum"
type_attr: "T"
is_ref: true
}
input_arg {
name: "lr"
type_attr: "T"
}
input_arg {
name: "grad"
type_attr: "T"
}
input_arg {
name: "momentum"
type_attr: "T"
}
output_arg {
name: "out"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
attr {
name: "use_nesterov"
type: "bool"
default_value {
b: false
}
}
}
op {
name: "ApplyMomentum"
input_arg {
name: "var"
type_attr: "T"
is_ref: true
}
input_arg {
name: "accum"
type_attr: "T"
is_ref: true
}
input_arg {
name: "lr"
type_attr: "T"
}
input_arg {
name: "grad"
type_attr: "T"
}
input_arg {
name: "momentum"
type_attr: "T"
}
output_arg {
name: "out"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
attr {
name: "use_nesterov"
type: "bool"
default_value {
b: false
}
}
}
op {
name: "ApplyMomentum"
input_arg {
name: "var"
type_attr: "T"
is_ref: true
}
input_arg {
name: "accum"
type_attr: "T"
is_ref: true
}
input_arg {
name: "lr"
type_attr: "T"
}
input_arg {
name: "grad"
type_attr: "T"
}
input_arg {
name: "momentum"
type_attr: "T"
}
output_arg {
name: "out"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
type: DT_BFLOAT16
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
attr {
name: "use_nesterov"
type: "bool"
default_value {
b: false
}
}
}
op {
name: "ApplyMomentum"
input_arg {
name: "var"
type_attr: "T"
is_ref: true
}
input_arg {
name: "accum"
type_attr: "T"
is_ref: true
}
input_arg {
name: "lr"
type_attr: "T"
}
input_arg {
name: "grad"
type_attr: "T"
}
input_arg {
name: "momentum"
type_attr: "T"
}
output_arg {
name: "out"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT32
type: DT_UINT8
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_INT64
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_BFLOAT16
type: DT_UINT16
type: DT_COMPLEX128
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
attr {
name: "use_nesterov"
type: "bool"
default_value {
b: false
}
}
}
@@ -0,0 +1,209 @@
op {
name: "ApplyPowerSign"
input_arg {
name: "var"
type_attr: "T"
is_ref: true
}
input_arg {
name: "m"
type_attr: "T"
is_ref: true
}
input_arg {
name: "lr"
type_attr: "T"
}
input_arg {
name: "logbase"
type_attr: "T"
}
input_arg {
name: "sign_decay"
type_attr: "T"
}
input_arg {
name: "beta"
type_attr: "T"
}
input_arg {
name: "grad"
type_attr: "T"
}
output_arg {
name: "out"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
}
op {
name: "ApplyPowerSign"
input_arg {
name: "var"
type_attr: "T"
is_ref: true
}
input_arg {
name: "m"
type_attr: "T"
is_ref: true
}
input_arg {
name: "lr"
type_attr: "T"
}
input_arg {
name: "logbase"
type_attr: "T"
}
input_arg {
name: "sign_decay"
type_attr: "T"
}
input_arg {
name: "beta"
type_attr: "T"
}
input_arg {
name: "grad"
type_attr: "T"
}
output_arg {
name: "out"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
type: DT_BFLOAT16
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
}
op {
name: "ApplyPowerSign"
input_arg {
name: "var"
type_attr: "T"
is_ref: true
}
input_arg {
name: "m"
type_attr: "T"
is_ref: true
}
input_arg {
name: "lr"
type_attr: "T"
}
input_arg {
name: "logbase"
type_attr: "T"
}
input_arg {
name: "sign_decay"
type_attr: "T"
}
input_arg {
name: "beta"
type_attr: "T"
}
input_arg {
name: "grad"
type_attr: "T"
}
output_arg {
name: "out"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT32
type: DT_UINT8
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_INT64
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_BFLOAT16
type: DT_UINT16
type: DT_COMPLEX128
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
}
@@ -0,0 +1,260 @@
op {
name: "ApplyProximalAdagrad"
input_arg {
name: "var"
type_attr: "T"
is_ref: true
}
input_arg {
name: "accum"
type_attr: "T"
is_ref: true
}
input_arg {
name: "lr"
type_attr: "T"
}
input_arg {
name: "l1"
type_attr: "T"
}
input_arg {
name: "l2"
type_attr: "T"
}
input_arg {
name: "grad"
type_attr: "T"
}
output_arg {
name: "out"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
}
op {
name: "ApplyProximalAdagrad"
input_arg {
name: "var"
type_attr: "T"
is_ref: true
}
input_arg {
name: "accum"
type_attr: "T"
is_ref: true
}
input_arg {
name: "lr"
type_attr: "T"
}
input_arg {
name: "l1"
type_attr: "T"
}
input_arg {
name: "l2"
type_attr: "T"
}
input_arg {
name: "grad"
type_attr: "T"
}
output_arg {
name: "out"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
}
op {
name: "ApplyProximalAdagrad"
input_arg {
name: "var"
type_attr: "T"
is_ref: true
}
input_arg {
name: "accum"
type_attr: "T"
is_ref: true
}
input_arg {
name: "lr"
type_attr: "T"
}
input_arg {
name: "l1"
type_attr: "T"
}
input_arg {
name: "l2"
type_attr: "T"
}
input_arg {
name: "grad"
type_attr: "T"
}
output_arg {
name: "out"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
type: DT_BFLOAT16
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
}
op {
name: "ApplyProximalAdagrad"
input_arg {
name: "var"
type_attr: "T"
is_ref: true
}
input_arg {
name: "accum"
type_attr: "T"
is_ref: true
}
input_arg {
name: "lr"
type_attr: "T"
}
input_arg {
name: "l1"
type_attr: "T"
}
input_arg {
name: "l2"
type_attr: "T"
}
input_arg {
name: "grad"
type_attr: "T"
}
output_arg {
name: "out"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT32
type: DT_UINT8
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_INT64
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_BFLOAT16
type: DT_UINT16
type: DT_COMPLEX128
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
}
@@ -0,0 +1,240 @@
op {
name: "ApplyProximalGradientDescent"
input_arg {
name: "var"
type_attr: "T"
is_ref: true
}
input_arg {
name: "alpha"
type_attr: "T"
}
input_arg {
name: "l1"
type_attr: "T"
}
input_arg {
name: "l2"
type_attr: "T"
}
input_arg {
name: "delta"
type_attr: "T"
}
output_arg {
name: "out"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
}
op {
name: "ApplyProximalGradientDescent"
input_arg {
name: "var"
type_attr: "T"
is_ref: true
}
input_arg {
name: "alpha"
type_attr: "T"
}
input_arg {
name: "l1"
type_attr: "T"
}
input_arg {
name: "l2"
type_attr: "T"
}
input_arg {
name: "delta"
type_attr: "T"
}
output_arg {
name: "out"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
}
op {
name: "ApplyProximalGradientDescent"
input_arg {
name: "var"
type_attr: "T"
is_ref: true
}
input_arg {
name: "alpha"
type_attr: "T"
}
input_arg {
name: "l1"
type_attr: "T"
}
input_arg {
name: "l2"
type_attr: "T"
}
input_arg {
name: "delta"
type_attr: "T"
}
output_arg {
name: "out"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
type: DT_BFLOAT16
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
}
op {
name: "ApplyProximalGradientDescent"
input_arg {
name: "var"
type_attr: "T"
is_ref: true
}
input_arg {
name: "alpha"
type_attr: "T"
}
input_arg {
name: "l1"
type_attr: "T"
}
input_arg {
name: "l2"
type_attr: "T"
}
input_arg {
name: "delta"
type_attr: "T"
}
output_arg {
name: "out"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT32
type: DT_UINT8
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_INT64
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_BFLOAT16
type: DT_UINT16
type: DT_COMPLEX128
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
}
@@ -0,0 +1,296 @@
op {
name: "ApplyRMSProp"
input_arg {
name: "var"
type_attr: "T"
is_ref: true
}
input_arg {
name: "ms"
type_attr: "T"
is_ref: true
}
input_arg {
name: "mom"
type_attr: "T"
is_ref: true
}
input_arg {
name: "lr"
type_attr: "T"
}
input_arg {
name: "rho"
type_attr: "T"
}
input_arg {
name: "momentum"
type_attr: "T"
}
input_arg {
name: "epsilon"
type_attr: "T"
}
input_arg {
name: "grad"
type_attr: "T"
}
output_arg {
name: "out"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
}
op {
name: "ApplyRMSProp"
input_arg {
name: "var"
type_attr: "T"
is_ref: true
}
input_arg {
name: "ms"
type_attr: "T"
is_ref: true
}
input_arg {
name: "mom"
type_attr: "T"
is_ref: true
}
input_arg {
name: "lr"
type_attr: "T"
}
input_arg {
name: "rho"
type_attr: "T"
}
input_arg {
name: "momentum"
type_attr: "T"
}
input_arg {
name: "epsilon"
type_attr: "T"
}
input_arg {
name: "grad"
type_attr: "T"
}
output_arg {
name: "out"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
}
op {
name: "ApplyRMSProp"
input_arg {
name: "var"
type_attr: "T"
is_ref: true
}
input_arg {
name: "ms"
type_attr: "T"
is_ref: true
}
input_arg {
name: "mom"
type_attr: "T"
is_ref: true
}
input_arg {
name: "lr"
type_attr: "T"
}
input_arg {
name: "rho"
type_attr: "T"
}
input_arg {
name: "momentum"
type_attr: "T"
}
input_arg {
name: "epsilon"
type_attr: "T"
}
input_arg {
name: "grad"
type_attr: "T"
}
output_arg {
name: "out"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
type: DT_BFLOAT16
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
}
op {
name: "ApplyRMSProp"
input_arg {
name: "var"
type_attr: "T"
is_ref: true
}
input_arg {
name: "ms"
type_attr: "T"
is_ref: true
}
input_arg {
name: "mom"
type_attr: "T"
is_ref: true
}
input_arg {
name: "lr"
type_attr: "T"
}
input_arg {
name: "rho"
type_attr: "T"
}
input_arg {
name: "momentum"
type_attr: "T"
}
input_arg {
name: "epsilon"
type_attr: "T"
}
input_arg {
name: "grad"
type_attr: "T"
}
output_arg {
name: "out"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT32
type: DT_UINT8
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_INT64
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_BFLOAT16
type: DT_UINT16
type: DT_COMPLEX128
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
}
@@ -0,0 +1,188 @@
op {
name: "ApproximateEqual"
input_arg {
name: "x"
type_attr: "T"
}
input_arg {
name: "y"
type_attr: "T"
}
output_arg {
name: "z"
type: DT_BOOL
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
}
}
}
attr {
name: "tolerance"
type: "float"
default_value {
f: 1e-05
}
}
is_commutative: true
}
op {
name: "ApproximateEqual"
input_arg {
name: "x"
type_attr: "T"
}
input_arg {
name: "y"
type_attr: "T"
}
output_arg {
name: "z"
type: DT_BOOL
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
}
}
}
attr {
name: "tolerance"
type: "float"
default_value {
f: 1e-05
}
}
is_commutative: true
}
op {
name: "ApproximateEqual"
input_arg {
name: "x"
type_attr: "T"
}
input_arg {
name: "y"
type_attr: "T"
}
output_arg {
name: "z"
type: DT_BOOL
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
type: DT_BFLOAT16
}
}
}
attr {
name: "tolerance"
type: "float"
default_value {
f: 1e-05
}
}
is_commutative: true
}
op {
name: "ApproximateEqual"
input_arg {
name: "x"
type_attr: "T"
}
input_arg {
name: "y"
type_attr: "T"
}
output_arg {
name: "z"
type: DT_BOOL
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT32
type: DT_UINT8
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_INT64
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_BFLOAT16
type: DT_UINT16
type: DT_COMPLEX128
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
}
}
}
attr {
name: "tolerance"
type: "float"
default_value {
f: 1e-05
}
}
is_commutative: true
}
@@ -0,0 +1,377 @@
op {
name: "ArgMax"
input_arg {
name: "input"
type_attr: "T"
}
input_arg {
name: "dimension"
type_attr: "Tidx"
}
output_arg {
name: "output"
type: DT_INT64
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
}
}
}
attr {
name: "Tidx"
type: "type"
default_value {
type: DT_INT32
}
allowed_values {
list {
type: DT_INT32
type: DT_INT64
}
}
}
}
op {
name: "ArgMax"
input_arg {
name: "input"
type_attr: "T"
}
input_arg {
name: "dimension"
type_attr: "Tidx"
}
output_arg {
name: "output"
type_attr: "output_type"
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
}
}
}
attr {
name: "Tidx"
type: "type"
default_value {
type: DT_INT32
}
allowed_values {
list {
type: DT_INT32
type: DT_INT64
}
}
}
attr {
name: "output_type"
type: "type"
default_value {
type: DT_INT64
}
allowed_values {
list {
type: DT_INT32
type: DT_INT64
}
}
}
}
op {
name: "ArgMax"
input_arg {
name: "input"
type_attr: "T"
}
input_arg {
name: "dimension"
type_attr: "Tidx"
}
output_arg {
name: "output"
type_attr: "output_type"
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
}
}
}
attr {
name: "Tidx"
type: "type"
default_value {
type: DT_INT32
}
allowed_values {
list {
type: DT_INT32
type: DT_INT64
}
}
}
attr {
name: "output_type"
type: "type"
default_value {
type: DT_INT64
}
allowed_values {
list {
type: DT_INT32
type: DT_INT64
}
}
}
}
op {
name: "ArgMax"
input_arg {
name: "input"
type_attr: "T"
}
input_arg {
name: "dimension"
type_attr: "Tidx"
}
output_arg {
name: "output"
type_attr: "output_type"
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
type: DT_BFLOAT16
}
}
}
attr {
name: "Tidx"
type: "type"
default_value {
type: DT_INT32
}
allowed_values {
list {
type: DT_INT32
type: DT_INT64
}
}
}
attr {
name: "output_type"
type: "type"
default_value {
type: DT_INT64
}
allowed_values {
list {
type: DT_INT32
type: DT_INT64
}
}
}
}
op {
name: "ArgMax"
input_arg {
name: "input"
type_attr: "T"
}
input_arg {
name: "dimension"
type_attr: "Tidx"
}
output_arg {
name: "output"
type_attr: "output_type"
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT32
type: DT_UINT8
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_INT64
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_BFLOAT16
type: DT_UINT16
type: DT_COMPLEX128
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
}
}
}
attr {
name: "Tidx"
type: "type"
default_value {
type: DT_INT32
}
allowed_values {
list {
type: DT_INT32
type: DT_INT64
}
}
}
attr {
name: "output_type"
type: "type"
default_value {
type: DT_INT64
}
allowed_values {
list {
type: DT_INT32
type: DT_INT64
}
}
}
}
op {
name: "ArgMax"
input_arg {
name: "input"
type_attr: "T"
}
input_arg {
name: "dimension"
type_attr: "Tidx"
}
output_arg {
name: "output"
type_attr: "output_type"
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT32
type: DT_UINT8
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_INT64
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_BFLOAT16
type: DT_UINT16
type: DT_COMPLEX128
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
type: DT_BOOL
}
}
}
attr {
name: "Tidx"
type: "type"
default_value {
type: DT_INT32
}
allowed_values {
list {
type: DT_INT32
type: DT_INT64
}
}
}
attr {
name: "output_type"
type: "type"
default_value {
type: DT_INT64
}
allowed_values {
list {
type: DT_INT32
type: DT_INT64
}
}
}
}
@@ -0,0 +1,377 @@
op {
name: "ArgMin"
input_arg {
name: "input"
type_attr: "T"
}
input_arg {
name: "dimension"
type_attr: "Tidx"
}
output_arg {
name: "output"
type: DT_INT64
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
}
}
}
attr {
name: "Tidx"
type: "type"
default_value {
type: DT_INT32
}
allowed_values {
list {
type: DT_INT32
type: DT_INT64
}
}
}
}
op {
name: "ArgMin"
input_arg {
name: "input"
type_attr: "T"
}
input_arg {
name: "dimension"
type_attr: "Tidx"
}
output_arg {
name: "output"
type_attr: "output_type"
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
}
}
}
attr {
name: "Tidx"
type: "type"
default_value {
type: DT_INT32
}
allowed_values {
list {
type: DT_INT32
type: DT_INT64
}
}
}
attr {
name: "output_type"
type: "type"
default_value {
type: DT_INT64
}
allowed_values {
list {
type: DT_INT32
type: DT_INT64
}
}
}
}
op {
name: "ArgMin"
input_arg {
name: "input"
type_attr: "T"
}
input_arg {
name: "dimension"
type_attr: "Tidx"
}
output_arg {
name: "output"
type_attr: "output_type"
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
}
}
}
attr {
name: "Tidx"
type: "type"
default_value {
type: DT_INT32
}
allowed_values {
list {
type: DT_INT32
type: DT_INT64
}
}
}
attr {
name: "output_type"
type: "type"
default_value {
type: DT_INT64
}
allowed_values {
list {
type: DT_INT32
type: DT_INT64
}
}
}
}
op {
name: "ArgMin"
input_arg {
name: "input"
type_attr: "T"
}
input_arg {
name: "dimension"
type_attr: "Tidx"
}
output_arg {
name: "output"
type_attr: "output_type"
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
type: DT_BFLOAT16
}
}
}
attr {
name: "Tidx"
type: "type"
default_value {
type: DT_INT32
}
allowed_values {
list {
type: DT_INT32
type: DT_INT64
}
}
}
attr {
name: "output_type"
type: "type"
default_value {
type: DT_INT64
}
allowed_values {
list {
type: DT_INT32
type: DT_INT64
}
}
}
}
op {
name: "ArgMin"
input_arg {
name: "input"
type_attr: "T"
}
input_arg {
name: "dimension"
type_attr: "Tidx"
}
output_arg {
name: "output"
type_attr: "output_type"
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT32
type: DT_UINT8
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_INT64
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_BFLOAT16
type: DT_UINT16
type: DT_COMPLEX128
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
}
}
}
attr {
name: "Tidx"
type: "type"
default_value {
type: DT_INT32
}
allowed_values {
list {
type: DT_INT32
type: DT_INT64
}
}
}
attr {
name: "output_type"
type: "type"
default_value {
type: DT_INT64
}
allowed_values {
list {
type: DT_INT32
type: DT_INT64
}
}
}
}
op {
name: "ArgMin"
input_arg {
name: "input"
type_attr: "T"
}
input_arg {
name: "dimension"
type_attr: "Tidx"
}
output_arg {
name: "output"
type_attr: "output_type"
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT32
type: DT_UINT8
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_INT64
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_BFLOAT16
type: DT_UINT16
type: DT_COMPLEX128
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
type: DT_BOOL
}
}
}
attr {
name: "Tidx"
type: "type"
default_value {
type: DT_INT32
}
allowed_values {
list {
type: DT_INT32
type: DT_INT64
}
}
}
attr {
name: "output_type"
type: "type"
default_value {
type: DT_INT64
}
allowed_values {
list {
type: DT_INT32
type: DT_INT64
}
}
}
}
@@ -0,0 +1,186 @@
op {
name: "AsString"
input_arg {
name: "input"
type_attr: "T"
}
output_arg {
name: "output"
type: DT_STRING
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_INT32
type: DT_INT64
type: DT_COMPLEX64
type: DT_FLOAT
type: DT_DOUBLE
type: DT_BOOL
type: DT_INT8
}
}
}
attr {
name: "precision"
type: "int"
default_value {
i: -1
}
}
attr {
name: "scientific"
type: "bool"
default_value {
b: false
}
}
attr {
name: "shortest"
type: "bool"
default_value {
b: false
}
}
attr {
name: "width"
type: "int"
default_value {
i: -1
}
}
attr {
name: "fill"
type: "string"
default_value {
s: ""
}
}
}
op {
name: "AsString"
input_arg {
name: "input"
type_attr: "T"
}
output_arg {
name: "output"
type: DT_STRING
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_INT8
type: DT_INT16
type: DT_INT32
type: DT_INT64
type: DT_COMPLEX64
type: DT_FLOAT
type: DT_DOUBLE
type: DT_BOOL
}
}
}
attr {
name: "precision"
type: "int"
default_value {
i: -1
}
}
attr {
name: "scientific"
type: "bool"
default_value {
b: false
}
}
attr {
name: "shortest"
type: "bool"
default_value {
b: false
}
}
attr {
name: "width"
type: "int"
default_value {
i: -1
}
}
attr {
name: "fill"
type: "string"
default_value {
s: ""
}
}
}
op {
name: "AsString"
input_arg {
name: "input"
type_attr: "T"
}
output_arg {
name: "output"
type: DT_STRING
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_INT8
type: DT_INT16
type: DT_INT32
type: DT_INT64
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_FLOAT
type: DT_DOUBLE
type: DT_BOOL
}
}
}
attr {
name: "precision"
type: "int"
default_value {
i: -1
}
}
attr {
name: "scientific"
type: "bool"
default_value {
b: false
}
}
attr {
name: "shortest"
type: "bool"
default_value {
b: false
}
}
attr {
name: "width"
type: "int"
default_value {
i: -1
}
}
attr {
name: "fill"
type: "string"
default_value {
s: ""
}
}
}
@@ -0,0 +1,105 @@
op {
name: "Asin"
input_arg {
name: "x"
type_attr: "T"
}
output_arg {
name: "y"
type_attr: "T"
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_HALF
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT32
type: DT_INT64
type: DT_COMPLEX64
type: DT_COMPLEX128
}
}
}
}
op {
name: "Asin"
input_arg {
name: "x"
type_attr: "T"
}
output_arg {
name: "y"
type_attr: "T"
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_HALF
type: DT_BFLOAT16
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT32
type: DT_INT64
type: DT_COMPLEX64
type: DT_COMPLEX128
}
}
}
}
op {
name: "Asin"
input_arg {
name: "x"
type_attr: "T"
}
output_arg {
name: "y"
type_attr: "T"
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_BFLOAT16
type: DT_HALF
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT32
type: DT_INT64
type: DT_COMPLEX64
type: DT_COMPLEX128
}
}
}
}
op {
name: "Asin"
input_arg {
name: "x"
type_attr: "T"
}
output_arg {
name: "y"
type_attr: "T"
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_BFLOAT16
type: DT_HALF
type: DT_FLOAT
type: DT_DOUBLE
type: DT_COMPLEX64
type: DT_COMPLEX128
}
}
}
}
@@ -0,0 +1,74 @@
op {
name: "Asinh"
input_arg {
name: "x"
type_attr: "T"
}
output_arg {
name: "y"
type_attr: "T"
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_HALF
type: DT_FLOAT
type: DT_DOUBLE
type: DT_COMPLEX64
type: DT_COMPLEX128
}
}
}
}
op {
name: "Asinh"
input_arg {
name: "x"
type_attr: "T"
}
output_arg {
name: "y"
type_attr: "T"
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_HALF
type: DT_BFLOAT16
type: DT_FLOAT
type: DT_DOUBLE
type: DT_COMPLEX64
type: DT_COMPLEX128
}
}
}
}
op {
name: "Asinh"
input_arg {
name: "x"
type_attr: "T"
}
output_arg {
name: "y"
type_attr: "T"
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_BFLOAT16
type: DT_HALF
type: DT_FLOAT
type: DT_DOUBLE
type: DT_COMPLEX64
type: DT_COMPLEX128
}
}
}
}
@@ -0,0 +1,25 @@
op {
name: "Assert"
input_arg {
name: "condition"
type: DT_BOOL
}
input_arg {
name: "data"
type_list_attr: "T"
}
attr {
name: "T"
type: "list(type)"
has_minimum: true
minimum: 1
}
attr {
name: "summarize"
type: "int"
default_value {
i: 3
}
}
is_stateful: true
}
@@ -0,0 +1,27 @@
op {
name: "AssertCardinalityDataset"
input_arg {
name: "input_dataset"
type: DT_VARIANT
}
input_arg {
name: "cardinality"
type: DT_INT64
}
output_arg {
name: "handle"
type: DT_VARIANT
}
attr {
name: "output_types"
type: "list(type)"
has_minimum: true
minimum: 1
}
attr {
name: "output_shapes"
type: "list(shape)"
has_minimum: true
minimum: 1
}
}
@@ -0,0 +1,27 @@
op {
name: "AssertNextDataset"
input_arg {
name: "input_dataset"
type: DT_VARIANT
}
input_arg {
name: "transformations"
type: DT_STRING
}
output_arg {
name: "handle"
type: DT_VARIANT
}
attr {
name: "output_types"
type: "list(type)"
has_minimum: true
minimum: 1
}
attr {
name: "output_shapes"
type: "list(shape)"
has_minimum: true
minimum: 1
}
}
@@ -0,0 +1,36 @@
op {
name: "Assign"
input_arg {
name: "ref"
type_attr: "T"
is_ref: true
}
input_arg {
name: "value"
type_attr: "T"
}
output_arg {
name: "output_ref"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
}
attr {
name: "validate_shape"
type: "bool"
default_value {
b: true
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: true
}
}
allows_uninitialized_input: true
}
@@ -0,0 +1,192 @@
op {
name: "AssignAdd"
input_arg {
name: "ref"
type_attr: "T"
is_ref: true
}
input_arg {
name: "value"
type_attr: "T"
}
output_arg {
name: "output_ref"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
}
op {
name: "AssignAdd"
input_arg {
name: "ref"
type_attr: "T"
is_ref: true
}
input_arg {
name: "value"
type_attr: "T"
}
output_arg {
name: "output_ref"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
}
op {
name: "AssignAdd"
input_arg {
name: "ref"
type_attr: "T"
is_ref: true
}
input_arg {
name: "value"
type_attr: "T"
}
output_arg {
name: "output_ref"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
type: DT_BFLOAT16
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
}
op {
name: "AssignAdd"
input_arg {
name: "ref"
type_attr: "T"
is_ref: true
}
input_arg {
name: "value"
type_attr: "T"
}
output_arg {
name: "output_ref"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT32
type: DT_UINT8
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_INT64
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_BFLOAT16
type: DT_UINT16
type: DT_COMPLEX128
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
}
@@ -0,0 +1,16 @@
op {
name: "AssignAddVariableOp"
input_arg {
name: "resource"
type: DT_RESOURCE
}
input_arg {
name: "value"
type_attr: "dtype"
}
attr {
name: "dtype"
type: "type"
}
is_stateful: true
}
@@ -0,0 +1,192 @@
op {
name: "AssignSub"
input_arg {
name: "ref"
type_attr: "T"
is_ref: true
}
input_arg {
name: "value"
type_attr: "T"
}
output_arg {
name: "output_ref"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
}
op {
name: "AssignSub"
input_arg {
name: "ref"
type_attr: "T"
is_ref: true
}
input_arg {
name: "value"
type_attr: "T"
}
output_arg {
name: "output_ref"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
}
op {
name: "AssignSub"
input_arg {
name: "ref"
type_attr: "T"
is_ref: true
}
input_arg {
name: "value"
type_attr: "T"
}
output_arg {
name: "output_ref"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT64
type: DT_INT32
type: DT_UINT8
type: DT_UINT16
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_COMPLEX128
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
type: DT_BFLOAT16
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
}
op {
name: "AssignSub"
input_arg {
name: "ref"
type_attr: "T"
is_ref: true
}
input_arg {
name: "value"
type_attr: "T"
}
output_arg {
name: "output_ref"
type_attr: "T"
is_ref: true
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT32
type: DT_UINT8
type: DT_INT16
type: DT_INT8
type: DT_COMPLEX64
type: DT_INT64
type: DT_QINT8
type: DT_QUINT8
type: DT_QINT32
type: DT_BFLOAT16
type: DT_UINT16
type: DT_COMPLEX128
type: DT_HALF
type: DT_UINT32
type: DT_UINT64
}
}
}
attr {
name: "use_locking"
type: "bool"
default_value {
b: false
}
}
}
@@ -0,0 +1,16 @@
op {
name: "AssignSubVariableOp"
input_arg {
name: "resource"
type: DT_RESOURCE
}
input_arg {
name: "value"
type_attr: "dtype"
}
attr {
name: "dtype"
type: "type"
}
is_stateful: true
}
@@ -0,0 +1,16 @@
op {
name: "AssignVariableOp"
input_arg {
name: "resource"
type: DT_RESOURCE
}
input_arg {
name: "value"
type_attr: "dtype"
}
attr {
name: "dtype"
type: "type"
}
is_stateful: true
}
@@ -0,0 +1,106 @@
op {
name: "Atan"
input_arg {
name: "x"
type_attr: "T"
}
output_arg {
name: "y"
type_attr: "T"
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_HALF
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT32
type: DT_INT64
type: DT_COMPLEX64
type: DT_COMPLEX128
}
}
}
}
op {
name: "Atan"
input_arg {
name: "x"
type_attr: "T"
}
output_arg {
name: "y"
type_attr: "T"
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_HALF
type: DT_BFLOAT16
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT32
type: DT_INT64
type: DT_COMPLEX64
type: DT_COMPLEX128
}
}
}
}
op {
name: "Atan"
input_arg {
name: "x"
type_attr: "T"
}
output_arg {
name: "y"
type_attr: "T"
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_BFLOAT16
type: DT_HALF
type: DT_FLOAT
type: DT_DOUBLE
type: DT_INT32
type: DT_INT64
type: DT_COMPLEX64
type: DT_COMPLEX128
}
}
}
}
op {
name: "Atan"
input_arg {
name: "x"
type_attr: "T"
}
output_arg {
name: "y"
type_attr: "T"
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_BFLOAT16
type: DT_HALF
type: DT_FLOAT
type: DT_DOUBLE
type: DT_COMPLEX64
type: DT_COMPLEX128
}
}
}
}
@@ -0,0 +1,78 @@
op {
name: "Atan2"
input_arg {
name: "y"
type_attr: "T"
}
input_arg {
name: "x"
type_attr: "T"
}
output_arg {
name: "z"
type_attr: "T"
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
}
}
}
}
op {
name: "Atan2"
input_arg {
name: "y"
type_attr: "T"
}
input_arg {
name: "x"
type_attr: "T"
}
output_arg {
name: "z"
type_attr: "T"
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_BFLOAT16
type: DT_FLOAT
type: DT_DOUBLE
}
}
}
}
op {
name: "Atan2"
input_arg {
name: "y"
type_attr: "T"
}
input_arg {
name: "x"
type_attr: "T"
}
output_arg {
name: "z"
type_attr: "T"
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_BFLOAT16
type: DT_HALF
type: DT_FLOAT
type: DT_DOUBLE
}
}
}
}
@@ -0,0 +1,74 @@
op {
name: "Atanh"
input_arg {
name: "x"
type_attr: "T"
}
output_arg {
name: "y"
type_attr: "T"
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_HALF
type: DT_FLOAT
type: DT_DOUBLE
type: DT_COMPLEX64
type: DT_COMPLEX128
}
}
}
}
op {
name: "Atanh"
input_arg {
name: "x"
type_attr: "T"
}
output_arg {
name: "y"
type_attr: "T"
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_HALF
type: DT_BFLOAT16
type: DT_FLOAT
type: DT_DOUBLE
type: DT_COMPLEX64
type: DT_COMPLEX128
}
}
}
}
op {
name: "Atanh"
input_arg {
name: "x"
type_attr: "T"
}
output_arg {
name: "y"
type_attr: "T"
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_BFLOAT16
type: DT_HALF
type: DT_FLOAT
type: DT_DOUBLE
type: DT_COMPLEX64
type: DT_COMPLEX128
}
}
}
}
@@ -0,0 +1,26 @@
op {
name: "AudioSpectrogram"
input_arg {
name: "input"
type: DT_FLOAT
}
output_arg {
name: "spectrogram"
type: DT_FLOAT
}
attr {
name: "window_size"
type: "int"
}
attr {
name: "stride"
type: "int"
}
attr {
name: "magnitude_squared"
type: "bool"
default_value {
b: false
}
}
}
@@ -0,0 +1,31 @@
op {
name: "AudioSummary"
input_arg {
name: "tag"
type: DT_STRING
}
input_arg {
name: "tensor"
type: DT_FLOAT
}
output_arg {
name: "summary"
type: DT_STRING
}
attr {
name: "sample_rate"
type: "float"
}
attr {
name: "max_outputs"
type: "int"
default_value {
i: 3
}
has_minimum: true
minimum: 1
}
deprecation {
version: 15
}
}
@@ -0,0 +1,28 @@
op {
name: "AudioSummaryV2"
input_arg {
name: "tag"
type: DT_STRING
}
input_arg {
name: "tensor"
type: DT_FLOAT
}
input_arg {
name: "sample_rate"
type: DT_FLOAT
}
output_arg {
name: "summary"
type: DT_STRING
}
attr {
name: "max_outputs"
type: "int"
default_value {
i: 3
}
has_minimum: true
minimum: 1
}
}
@@ -0,0 +1,69 @@
op {
name: "AutoShardDataset"
input_arg {
name: "input_dataset"
type: DT_VARIANT
}
input_arg {
name: "num_workers"
type: DT_INT64
}
input_arg {
name: "index"
type: DT_INT64
}
output_arg {
name: "handle"
type: DT_VARIANT
}
attr {
name: "output_types"
type: "list(type)"
has_minimum: true
minimum: 1
}
attr {
name: "output_shapes"
type: "list(shape)"
has_minimum: true
minimum: 1
}
}
op {
name: "AutoShardDataset"
input_arg {
name: "input_dataset"
type: DT_VARIANT
}
input_arg {
name: "num_workers"
type: DT_INT64
}
input_arg {
name: "index"
type: DT_INT64
}
output_arg {
name: "handle"
type: DT_VARIANT
}
attr {
name: "auto_shard_policy"
type: "int"
default_value {
i: 0
}
}
attr {
name: "output_types"
type: "list(type)"
has_minimum: true
minimum: 1
}
attr {
name: "output_shapes"
type: "list(shape)"
has_minimum: true
minimum: 1
}
}
@@ -0,0 +1,229 @@
op {
name: "AvgPool"
input_arg {
name: "value"
type_attr: "T"
}
output_arg {
name: "output"
type_attr: "T"
}
attr {
name: "ksize"
type: "list(int)"
has_minimum: true
minimum: 4
}
attr {
name: "strides"
type: "list(int)"
has_minimum: true
minimum: 4
}
attr {
name: "padding"
type: "string"
allowed_values {
list {
s: "SAME"
s: "VALID"
}
}
}
attr {
name: "data_format"
type: "string"
default_value {
s: "NHWC"
}
allowed_values {
list {
s: "NHWC"
s: "NCHW"
}
}
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_HALF
type: DT_DOUBLE
}
}
}
}
op {
name: "AvgPool"
input_arg {
name: "value"
type_attr: "T"
}
output_arg {
name: "output"
type_attr: "T"
}
attr {
name: "ksize"
type: "list(int)"
has_minimum: true
minimum: 4
}
attr {
name: "strides"
type: "list(int)"
has_minimum: true
minimum: 4
}
attr {
name: "padding"
type: "string"
allowed_values {
list {
s: "SAME"
s: "VALID"
}
}
}
attr {
name: "data_format"
type: "string"
default_value {
s: "NHWC"
}
allowed_values {
list {
s: "NHWC"
s: "NCHW"
}
}
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_HALF
}
}
}
}
op {
name: "AvgPool"
input_arg {
name: "value"
type_attr: "T"
}
output_arg {
name: "output"
type_attr: "T"
}
attr {
name: "ksize"
type: "list(int)"
has_minimum: true
minimum: 4
}
attr {
name: "strides"
type: "list(int)"
has_minimum: true
minimum: 4
}
attr {
name: "padding"
type: "string"
allowed_values {
list {
s: "SAME"
s: "VALID"
}
}
}
attr {
name: "data_format"
type: "string"
default_value {
s: "NHWC"
}
allowed_values {
list {
s: "NHWC"
s: "NCHW"
}
}
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_HALF
type: DT_FLOAT
type: DT_DOUBLE
}
}
}
}
op {
name: "AvgPool"
input_arg {
name: "value"
type_attr: "T"
}
output_arg {
name: "output"
type_attr: "T"
}
attr {
name: "ksize"
type: "list(int)"
has_minimum: true
minimum: 4
}
attr {
name: "strides"
type: "list(int)"
has_minimum: true
minimum: 4
}
attr {
name: "padding"
type: "string"
allowed_values {
list {
s: "SAME"
s: "VALID"
}
}
}
attr {
name: "data_format"
type: "string"
default_value {
s: "NHWC"
}
allowed_values {
list {
s: "NHWC"
s: "NCHW"
}
}
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_HALF
type: DT_BFLOAT16
type: DT_FLOAT
type: DT_DOUBLE
}
}
}
}
@@ -0,0 +1,214 @@
op {
name: "AvgPool3D"
input_arg {
name: "input"
type_attr: "T"
}
output_arg {
name: "output"
type_attr: "T"
}
attr {
name: "ksize"
type: "list(int)"
has_minimum: true
minimum: 5
}
attr {
name: "strides"
type: "list(int)"
has_minimum: true
minimum: 5
}
attr {
name: "padding"
type: "string"
allowed_values {
list {
s: "SAME"
s: "VALID"
}
}
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
}
}
}
}
op {
name: "AvgPool3D"
input_arg {
name: "input"
type_attr: "T"
}
output_arg {
name: "output"
type_attr: "T"
}
attr {
name: "ksize"
type: "list(int)"
has_minimum: true
minimum: 5
}
attr {
name: "strides"
type: "list(int)"
has_minimum: true
minimum: 5
}
attr {
name: "padding"
type: "string"
allowed_values {
list {
s: "SAME"
s: "VALID"
}
}
}
attr {
name: "data_format"
type: "string"
default_value {
s: "NDHWC"
}
allowed_values {
list {
s: "NDHWC"
s: "NCDHW"
}
}
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
}
}
}
}
op {
name: "AvgPool3D"
input_arg {
name: "input"
type_attr: "T"
}
output_arg {
name: "output"
type_attr: "T"
}
attr {
name: "ksize"
type: "list(int)"
has_minimum: true
minimum: 5
}
attr {
name: "strides"
type: "list(int)"
has_minimum: true
minimum: 5
}
attr {
name: "padding"
type: "string"
allowed_values {
list {
s: "SAME"
s: "VALID"
}
}
}
attr {
name: "data_format"
type: "string"
default_value {
s: "NDHWC"
}
allowed_values {
list {
s: "NDHWC"
s: "NCDHW"
}
}
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_BFLOAT16
type: DT_FLOAT
type: DT_DOUBLE
}
}
}
}
op {
name: "AvgPool3D"
input_arg {
name: "input"
type_attr: "T"
}
output_arg {
name: "output"
type_attr: "T"
}
attr {
name: "ksize"
type: "list(int)"
has_minimum: true
minimum: 5
}
attr {
name: "strides"
type: "list(int)"
has_minimum: true
minimum: 5
}
attr {
name: "padding"
type: "string"
allowed_values {
list {
s: "SAME"
s: "VALID"
}
}
}
attr {
name: "data_format"
type: "string"
default_value {
s: "NDHWC"
}
allowed_values {
list {
s: "NDHWC"
s: "NCDHW"
}
}
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_HALF
type: DT_BFLOAT16
type: DT_FLOAT
type: DT_DOUBLE
}
}
}
}
@@ -0,0 +1,230 @@
op {
name: "AvgPool3DGrad"
input_arg {
name: "orig_input_shape"
type: DT_INT32
}
input_arg {
name: "grad"
type_attr: "T"
}
output_arg {
name: "output"
type_attr: "T"
}
attr {
name: "ksize"
type: "list(int)"
has_minimum: true
minimum: 5
}
attr {
name: "strides"
type: "list(int)"
has_minimum: true
minimum: 5
}
attr {
name: "padding"
type: "string"
allowed_values {
list {
s: "SAME"
s: "VALID"
}
}
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
}
}
}
}
op {
name: "AvgPool3DGrad"
input_arg {
name: "orig_input_shape"
type: DT_INT32
}
input_arg {
name: "grad"
type_attr: "T"
}
output_arg {
name: "output"
type_attr: "T"
}
attr {
name: "ksize"
type: "list(int)"
has_minimum: true
minimum: 5
}
attr {
name: "strides"
type: "list(int)"
has_minimum: true
minimum: 5
}
attr {
name: "padding"
type: "string"
allowed_values {
list {
s: "SAME"
s: "VALID"
}
}
}
attr {
name: "data_format"
type: "string"
default_value {
s: "NDHWC"
}
allowed_values {
list {
s: "NDHWC"
s: "NCDHW"
}
}
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
}
}
}
}
op {
name: "AvgPool3DGrad"
input_arg {
name: "orig_input_shape"
type: DT_INT32
}
input_arg {
name: "grad"
type_attr: "T"
}
output_arg {
name: "output"
type_attr: "T"
}
attr {
name: "ksize"
type: "list(int)"
has_minimum: true
minimum: 5
}
attr {
name: "strides"
type: "list(int)"
has_minimum: true
minimum: 5
}
attr {
name: "padding"
type: "string"
allowed_values {
list {
s: "SAME"
s: "VALID"
}
}
}
attr {
name: "data_format"
type: "string"
default_value {
s: "NDHWC"
}
allowed_values {
list {
s: "NDHWC"
s: "NCDHW"
}
}
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_BFLOAT16
type: DT_FLOAT
type: DT_DOUBLE
}
}
}
}
op {
name: "AvgPool3DGrad"
input_arg {
name: "orig_input_shape"
type: DT_INT32
}
input_arg {
name: "grad"
type_attr: "T"
}
output_arg {
name: "output"
type_attr: "T"
}
attr {
name: "ksize"
type: "list(int)"
has_minimum: true
minimum: 5
}
attr {
name: "strides"
type: "list(int)"
has_minimum: true
minimum: 5
}
attr {
name: "padding"
type: "string"
allowed_values {
list {
s: "SAME"
s: "VALID"
}
}
}
attr {
name: "data_format"
type: "string"
default_value {
s: "NDHWC"
}
allowed_values {
list {
s: "NDHWC"
s: "NCDHW"
}
}
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_HALF
type: DT_BFLOAT16
type: DT_FLOAT
type: DT_DOUBLE
}
}
}
}
@@ -0,0 +1,245 @@
op {
name: "AvgPoolGrad"
input_arg {
name: "orig_input_shape"
type: DT_INT32
}
input_arg {
name: "grad"
type_attr: "T"
}
output_arg {
name: "output"
type_attr: "T"
}
attr {
name: "ksize"
type: "list(int)"
has_minimum: true
minimum: 4
}
attr {
name: "strides"
type: "list(int)"
has_minimum: true
minimum: 4
}
attr {
name: "padding"
type: "string"
allowed_values {
list {
s: "SAME"
s: "VALID"
}
}
}
attr {
name: "data_format"
type: "string"
default_value {
s: "NHWC"
}
allowed_values {
list {
s: "NHWC"
s: "NCHW"
}
}
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_HALF
type: DT_DOUBLE
}
}
}
}
op {
name: "AvgPoolGrad"
input_arg {
name: "orig_input_shape"
type: DT_INT32
}
input_arg {
name: "grad"
type_attr: "T"
}
output_arg {
name: "output"
type_attr: "T"
}
attr {
name: "ksize"
type: "list(int)"
has_minimum: true
minimum: 4
}
attr {
name: "strides"
type: "list(int)"
has_minimum: true
minimum: 4
}
attr {
name: "padding"
type: "string"
allowed_values {
list {
s: "SAME"
s: "VALID"
}
}
}
attr {
name: "data_format"
type: "string"
default_value {
s: "NHWC"
}
allowed_values {
list {
s: "NHWC"
s: "NCHW"
}
}
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_FLOAT
type: DT_DOUBLE
type: DT_HALF
}
}
}
}
op {
name: "AvgPoolGrad"
input_arg {
name: "orig_input_shape"
type: DT_INT32
}
input_arg {
name: "grad"
type_attr: "T"
}
output_arg {
name: "output"
type_attr: "T"
}
attr {
name: "ksize"
type: "list(int)"
has_minimum: true
minimum: 4
}
attr {
name: "strides"
type: "list(int)"
has_minimum: true
minimum: 4
}
attr {
name: "padding"
type: "string"
allowed_values {
list {
s: "SAME"
s: "VALID"
}
}
}
attr {
name: "data_format"
type: "string"
default_value {
s: "NHWC"
}
allowed_values {
list {
s: "NHWC"
s: "NCHW"
}
}
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_HALF
type: DT_FLOAT
type: DT_DOUBLE
}
}
}
}
op {
name: "AvgPoolGrad"
input_arg {
name: "orig_input_shape"
type: DT_INT32
}
input_arg {
name: "grad"
type_attr: "T"
}
output_arg {
name: "output"
type_attr: "T"
}
attr {
name: "ksize"
type: "list(int)"
has_minimum: true
minimum: 4
}
attr {
name: "strides"
type: "list(int)"
has_minimum: true
minimum: 4
}
attr {
name: "padding"
type: "string"
allowed_values {
list {
s: "SAME"
s: "VALID"
}
}
}
attr {
name: "data_format"
type: "string"
default_value {
s: "NHWC"
}
allowed_values {
list {
s: "NHWC"
s: "NCHW"
}
}
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_HALF
type: DT_BFLOAT16
type: DT_FLOAT
type: DT_DOUBLE
}
}
}
}
@@ -0,0 +1,19 @@
# Description:
# Test for keeping the history of OpDefs for every major version of TensorFlow,
# to validate that we don't make backwards-incompatible changes in particular
# for v1.
load("//tensorflow:tensorflow.default.bzl", "filegroup")
package(
# copybara:uncomment default_applicable_licenses = ["//tensorflow:license"],
licenses = ["notice"],
)
filegroup(
name = "ops_history_v1_srcs",
srcs = glob([
"*.pbtxt",
]),
visibility = ["//tensorflow/core/ops/compat:__pkg__"],
)
@@ -0,0 +1,45 @@
op {
name: "Barrier"
output_arg {
name: "handle"
type: DT_STRING
is_ref: true
}
attr {
name: "component_types"
type: "list(type)"
has_minimum: true
minimum: 1
}
attr {
name: "shapes"
type: "list(shape)"
default_value {
list {
}
}
has_minimum: true
}
attr {
name: "capacity"
type: "int"
default_value {
i: -1
}
}
attr {
name: "container"
type: "string"
default_value {
s: ""
}
}
attr {
name: "shared_name"
type: "string"
default_value {
s: ""
}
}
is_stateful: true
}
@@ -0,0 +1,15 @@
op {
name: "BarrierClose"
input_arg {
name: "handle"
type: DT_STRING
is_ref: true
}
attr {
name: "cancel_pending_enqueues"
type: "bool"
default_value {
b: false
}
}
}
@@ -0,0 +1,12 @@
op {
name: "BarrierIncompleteSize"
input_arg {
name: "handle"
type: DT_STRING
is_ref: true
}
output_arg {
name: "size"
type: DT_INT32
}
}
@@ -0,0 +1,24 @@
op {
name: "BarrierInsertMany"
input_arg {
name: "handle"
type: DT_STRING
is_ref: true
}
input_arg {
name: "keys"
type: DT_STRING
}
input_arg {
name: "values"
type_attr: "T"
}
attr {
name: "T"
type: "type"
}
attr {
name: "component_index"
type: "int"
}
}
@@ -0,0 +1,12 @@
op {
name: "BarrierReadySize"
input_arg {
name: "handle"
type: DT_STRING
is_ref: true
}
output_arg {
name: "size"
type: DT_INT32
}
}
@@ -0,0 +1,51 @@
op {
name: "BarrierTakeMany"
input_arg {
name: "handle"
type: DT_STRING
is_ref: true
}
input_arg {
name: "num_elements"
type: DT_INT32
}
output_arg {
name: "indices"
type: DT_INT64
}
output_arg {
name: "keys"
type: DT_STRING
}
output_arg {
name: "values"
type_list_attr: "component_types"
}
attr {
name: "component_types"
type: "list(type)"
has_minimum: true
minimum: 1
}
attr {
name: "allow_small_batch"
type: "bool"
default_value {
b: false
}
}
attr {
name: "wait_for_incomplete"
type: "bool"
default_value {
b: false
}
}
attr {
name: "timeout_ms"
type: "int"
default_value {
i: -1
}
}
}
@@ -0,0 +1,147 @@
op {
name: "Batch"
input_arg {
name: "in_tensors"
type_list_attr: "T"
}
output_arg {
name: "batched_tensors"
type_list_attr: "T"
}
output_arg {
name: "batch_index"
type: DT_INT64
}
output_arg {
name: "id"
type: DT_INT64
}
attr {
name: "num_batch_threads"
type: "int"
}
attr {
name: "max_batch_size"
type: "int"
}
attr {
name: "batch_timeout_micros"
type: "int"
}
attr {
name: "allowed_batch_sizes"
type: "list(int)"
default_value {
list {
}
}
}
attr {
name: "grad_timeout_micros"
type: "int"
}
attr {
name: "container"
type: "string"
default_value {
s: ""
}
}
attr {
name: "shared_name"
type: "string"
default_value {
s: ""
}
}
attr {
name: "batching_queue"
type: "string"
default_value {
s: ""
}
}
attr {
name: "T"
type: "list(type)"
has_minimum: true
minimum: 1
}
}
op {
name: "Batch"
input_arg {
name: "in_tensors"
type_list_attr: "T"
}
output_arg {
name: "batched_tensors"
type_list_attr: "T"
}
output_arg {
name: "batch_index"
type: DT_INT64
}
output_arg {
name: "id"
type: DT_INT64
}
attr {
name: "num_batch_threads"
type: "int"
}
attr {
name: "max_batch_size"
type: "int"
}
attr {
name: "max_enqueued_batches"
type: "int"
default_value {
i: 10
}
}
attr {
name: "batch_timeout_micros"
type: "int"
}
attr {
name: "allowed_batch_sizes"
type: "list(int)"
default_value {
list {
}
}
}
attr {
name: "grad_timeout_micros"
type: "int"
}
attr {
name: "container"
type: "string"
default_value {
s: ""
}
}
attr {
name: "shared_name"
type: "string"
default_value {
s: ""
}
}
attr {
name: "batching_queue"
type: "string"
default_value {
s: ""
}
}
attr {
name: "T"
type: "list(type)"
has_minimum: true
minimum: 1
}
}
@@ -0,0 +1,24 @@
op {
name: "BatchCholesky"
input_arg {
name: "input"
type_attr: "T"
}
output_arg {
name: "output"
type_attr: "T"
}
attr {
name: "T"
type: "type"
allowed_values {
list {
type: DT_DOUBLE
type: DT_FLOAT
}
}
}
deprecation {
version: 13
}
}

Some files were not shown because too many files have changed in this diff Show More