Skip to content

Commit

Permalink
Merge pull request tensorflow#7928 from andrewharp/branch_148665838
Browse files Browse the repository at this point in the history
Branch 148665838
  • Loading branch information
andrewharp committed Feb 28, 2017
2 parents d699a66 + b12764e commit dc7293f
Show file tree
Hide file tree
Showing 31 changed files with 2,368 additions and 718 deletions.
10 changes: 1 addition & 9 deletions tensorflow/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ filegroup(
"//tensorflow/java/src/main/native:all_files",
"//tensorflow/python:all_files",
"//tensorflow/python/debug:all_files",
"//tensorflow/python/estimator:all_files",
"//tensorflow/python/kernel_tests:all_files",
"//tensorflow/python/saved_model:all_files",
"//tensorflow/python/tools:all_files",
Expand Down Expand Up @@ -305,15 +306,6 @@ cc_binary(
],
)

cc_binary(
name = "libtensorflow_c.so",
linkshared = 1,
deps = [
"//tensorflow/c:c_api",
"//tensorflow/core:tensorflow",
],
)

cc_binary(
name = "libtensorflow_cc.so",
linkshared = 1,
Expand Down
22 changes: 14 additions & 8 deletions tensorflow/c/c_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -543,9 +543,8 @@ static void TF_Run_Helper(

if (handle == nullptr) {
RunOptions run_options_proto;
if (run_options != nullptr &&
!run_options_proto.ParseFromArray(run_options->data,
run_options->length)) {
if (run_options != nullptr && !run_options_proto.ParseFromArray(
run_options->data, run_options->length)) {
status->status = InvalidArgument("Unparseable RunOptions proto");
return;
}
Expand Down Expand Up @@ -2111,11 +2110,19 @@ TF_Session* TF_NewSession(TF_Graph* graph, const TF_SessionOptions* opt,
}
}

#ifndef __ANDROID__
TF_Session* TF_LoadSessionFromSavedModel(
const TF_SessionOptions* session_options, const TF_Buffer* run_options,
const char* export_dir, const char* const* tags, int tags_len,
TF_Graph* graph, TF_Buffer* meta_graph_def, TF_Status* status) {
// TODO(ashankar): Remove the __ANDROID__ guard. This will require ensuring that
// the tensorflow/cc/saved_model:loader build target is Android friendly.
#ifdef __ANDROID__
status->status = tensorflow::errors::Unimplemented(
"Loading a SavedModel is not supported in Android. File a bug at "
"https://github.com/tensorflow/tensorflow/issues if this feature is "
"important to you");
return nullptr;
#else
mutex_lock l(graph->mu);

if (!graph->name_map.empty()) {
Expand All @@ -2124,9 +2131,8 @@ TF_Session* TF_LoadSessionFromSavedModel(
}

RunOptions run_options_proto;
if (run_options != nullptr &&
!run_options_proto.ParseFromArray(run_options->data,
run_options->length)) {
if (run_options != nullptr && !run_options_proto.ParseFromArray(
run_options->data, run_options->length)) {
status->status = InvalidArgument("Unparseable RunOptions proto");
return nullptr;
}
Expand Down Expand Up @@ -2164,8 +2170,8 @@ TF_Session* TF_LoadSessionFromSavedModel(
graph->num_sessions += 1;
session->last_num_graph_nodes = graph->graph.num_node_ids();
return session;
}
#endif // __ANDROID__
}

void TF_CloseSession(TF_Session* s, TF_Status* status) {
status->status = s->session->Close();
Expand Down
5 changes: 0 additions & 5 deletions tensorflow/c/c_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -932,10 +932,6 @@ typedef struct TF_Session TF_Session;
extern TF_Session* TF_NewSession(TF_Graph* graph, const TF_SessionOptions* opts,
TF_Status* status);

#ifndef __ANDROID__
// TODO(ashankar): Remove the __ANDROID__ guard. This will require ensuring that
// the tensorflow/cc/saved_model:loader build target is Android friendly.

// This function creates a new TF_Session (which is created on success) using
// `session_options`, and then initializes state (restoring tensors and other
// assets) using `run_options`.
Expand All @@ -954,7 +950,6 @@ TF_Session* TF_LoadSessionFromSavedModel(
const TF_SessionOptions* session_options, const TF_Buffer* run_options,
const char* export_dir, const char* const* tags, int tags_len,
TF_Graph* graph, TF_Buffer* meta_graph_def, TF_Status* status);
#endif // __ANDROID__

// Close a session.
//
Expand Down
4 changes: 2 additions & 2 deletions tensorflow/compiler/xla/differential_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ limitations under the License.
#ifndef TENSORFLOW_COMPILER_XLA_DIFFERENTIAL_SET_H_
#define TENSORFLOW_COMPILER_XLA_DIFFERENTIAL_SET_H_

#include <set>
#include <unordered_set>

#include "tensorflow/core/platform/macros.h"

Expand Down Expand Up @@ -50,7 +50,7 @@ class DifferentialSet {

private:
// Values held directly by this node in the chain of sets.
std::set<T> held_;
std::unordered_set<T> held_;

// Parent node in the chain of sets.
const DifferentialSet* parent_;
Expand Down
6 changes: 5 additions & 1 deletion tensorflow/compiler/xla/service/cpu/cpu_compiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,11 @@ Status CpuCompiler::RunHloPasses(HloModule* hlo_module,
HloDumper dump_hlo) {
// Optimization pipeline.
HloPassPipeline pipeline("CPU", dump_hlo);
pipeline.AddPass<Inliner>();

// TODO(b/35786417): Re-enable inliner pass after fixing the bug and deciding
// where we will take this pass in future.
// pipeline.AddPass<Inliner>();

pipeline.AddPass<ConvCanonicalization>();
{
auto& pass = pipeline.AddPass<HloPassFix<HloPassPipeline>>("simplification",
Expand Down
47 changes: 47 additions & 0 deletions tensorflow/compiler/xla/tests/map_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,53 @@ TEST_F(MapTestWithFullOpt, MapScalarPower) {
ErrorSpec(0.01f));
}

// Regression test for b/35786417, where the inliner would not notice the change
// of parameter order inside the map.
TEST_F(MapTestWithFullOpt, MapSubtractOppositeOrder) {
ComputationBuilder builder(client_, TestName());

auto sub_builder = builder.CreateSubBuilder("power");
auto x = sub_builder->Parameter(0, ShapeUtil::MakeShape(F32, {}), "x");
auto y = sub_builder->Parameter(1, ShapeUtil::MakeShape(F32, {}), "y");
sub_builder->Sub(y, x); // note that this is y - x, not x - y
auto sub_opposite = sub_builder->BuildAndNoteError();

std::unique_ptr<Literal> param0_literal = LiteralUtil::CreateR0<float>(2.0f);
std::unique_ptr<Literal> param1_literal = LiteralUtil::CreateR0<float>(5.0f);
std::unique_ptr<GlobalData> param0_data =
client_->TransferToServer(*param0_literal).ConsumeValueOrDie();
std::unique_ptr<GlobalData> param1_data =
client_->TransferToServer(*param1_literal).ConsumeValueOrDie();

auto param0 = builder.Parameter(0, param0_literal->shape(), "param0");
auto param1 = builder.Parameter(1, param1_literal->shape(), "param1");
builder.Map({param0, param1}, sub_opposite);

ComputeAndCompareR0<float>(
&builder, 3.0f, {param0_data.get(), param1_data.get()}, ErrorSpec(0.01f));
}

// Regression test for b/35786417, where the inliner would CHECK-fail due to the
// mul inside the map having more parameters than the map does.
TEST_F(MapTestWithFullOpt, MapSquare) {
ComputationBuilder builder(client_, TestName());

auto sub_builder = builder.CreateSubBuilder("power");
auto x = sub_builder->Parameter(0, ShapeUtil::MakeShape(F32, {}), "x");
sub_builder->Mul(x, x);
auto square = sub_builder->BuildAndNoteError();

std::unique_ptr<Literal> param0_literal = LiteralUtil::CreateR0<float>(10.0f);
std::unique_ptr<GlobalData> param0_data =
client_->TransferToServer(*param0_literal).ConsumeValueOrDie();

auto param0 = builder.Parameter(0, param0_literal->shape(), "param0");
builder.Map({param0}, square);

ComputeAndCompareR0<float>(&builder, 100.0f, {param0_data.get()},
ErrorSpec(0.01f));
}

} // namespace
} // namespace xla

Expand Down
1 change: 1 addition & 0 deletions tensorflow/contrib/learn/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ py_library(
"//tensorflow/python:util",
"//tensorflow/python:variable_scope",
"//tensorflow/python:variables",
"//tensorflow/python/estimator:inputs",
"//tensorflow/python/saved_model:builder",
"//tensorflow/python/saved_model:loader",
"//tensorflow/python/saved_model:signature_constants",
Expand Down
Loading

0 comments on commit dc7293f

Please sign in to comment.