Skip to content

Conversation

@lattner
Copy link
Contributor

@lattner lattner commented Jul 18, 2018

Fixes SR11079/SR11079.

ShapeList and type lists remain.

Fix SR11079/SR11079. ShapeList and type lists remain.
@lattner lattner added the tensorflow This is for "tensorflow" branch PRs. label Jul 18, 2018
@lattner lattner requested review from bgogul, mhong and rxwei July 18, 2018 15:53
@lattner
Copy link
Contributor Author

lattner commented Jul 18, 2018

@swift-ci please test tensorflow

generating diagnostic errors if the element types mismatch the dtype instead of crashing the compiler.
@lattner
Copy link
Contributor Author

lattner commented Jul 18, 2018

@swift-ci please test tensorflow

2 similar comments
@lattner
Copy link
Contributor Author

lattner commented Jul 18, 2018

@swift-ci please test tensorflow

@lattner
Copy link
Contributor Author

lattner commented Jul 18, 2018

@swift-ci please test tensorflow

Copy link

@mhong mhong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great -- One step closer!



public func testConvolution(x: Tensor<Float>, filter: Tensor<Float>) -> Tensor<Float> {
// expected-error @+1 {{FIXME: Handle array attributes}}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome!!


// TODO: TF_SetAttrTypeList

if (elementTypeString == "String") {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there any enum that we can match on, rather than doing (sub)string comparison?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, not really (that I know of). This really comes down to what types we want to allow in #tfop attribute lists. We could tighten this up to check that the types are coming from Swift module. I'll dig around to see what ASTContext has to work with here.


if (elementTypeString == "String") {
SmallVector<const void*, 4> pointers;
SmallVector<size_t, 4> sizes;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want to call reserve() for pointers and sizes as well? same for values below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, done.

SmallVector<float, 4> values;
for (auto elt : elements) {
auto value = elt.getFloatValue();
bool losesInfo = false;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a comment on why losing precision here is ok?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well it really isn't, but this is tensorflow.... :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(but sure, I'll add a comment)

for (auto elt : attrValue.getArrayValue(eltType))
addScalar(elt);
for (auto elt : attrValue.getArrayValue(eltType)) {
if (addScalar(elt))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: i'd prefer that we pass elements explicitly into addScalar call here, so that the code here looks less "magical". Thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure.

elements.push_back(floatValue.bitcastToAPInt());
}

if (elements.back().getBitWidth() != dtypeSize*8) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: dtypeSize * 8 instead of dtypeSize*8?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

// The scalar case is very simple, the shape of a scalar is 0d, and the
// data type comes from an attr that should already be processed.
auto addScalar = [&](SymbolicValue value) {
// Add a scalar to the elements list, checking that it is the right size
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"checking that it is the right size" -> should we update the comment as we are actually fixing the sizes in the impl?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@lattner
Copy link
Contributor Author

lattner commented Jul 18, 2018

Thanks for the feedback!

@lattner
Copy link
Contributor Author

lattner commented Jul 18, 2018

@swift-ci please test tensorflow

5 similar comments
@lattner
Copy link
Contributor Author

lattner commented Jul 18, 2018

@swift-ci please test tensorflow

@lattner
Copy link
Contributor Author

lattner commented Jul 18, 2018

@swift-ci please test tensorflow

@lattner
Copy link
Contributor Author

lattner commented Jul 18, 2018

@swift-ci please test tensorflow

@lattner
Copy link
Contributor Author

lattner commented Jul 18, 2018

@swift-ci please test tensorflow

@lattner
Copy link
Contributor Author

lattner commented Jul 18, 2018

@swift-ci please test tensorflow

@lattner
Copy link
Contributor Author

lattner commented Jul 18, 2018

sigh. :)

@lattner
Copy link
Contributor Author

lattner commented Jul 18, 2018

@swift-ci please test tensorflow

5 similar comments
@lattner
Copy link
Contributor Author

lattner commented Jul 18, 2018

@swift-ci please test tensorflow

@lattner
Copy link
Contributor Author

lattner commented Jul 18, 2018

@swift-ci please test tensorflow

@lattner
Copy link
Contributor Author

lattner commented Jul 18, 2018

@swift-ci please test tensorflow

@lattner
Copy link
Contributor Author

lattner commented Jul 18, 2018

@swift-ci please test tensorflow

@lattner
Copy link
Contributor Author

lattner commented Jul 18, 2018

@swift-ci please test tensorflow

@mhong
Copy link

mhong commented Jul 18, 2018

Looks like CI is busy with a time-driven run: https://ci-external.swift.org/computer/ubuntu-16.04-tensorflow/

@lattner
Copy link
Contributor Author

lattner commented Jul 18, 2018

Weird how it doesn't provide any feedback...

@lattner
Copy link
Contributor Author

lattner commented Jul 18, 2018

@swift-ci please test tensorflow

@rxwei
Copy link
Contributor

rxwei commented Jul 18, 2018

@swift-ci please test tensorflow

@rxwei
Copy link
Contributor

rxwei commented Jul 18, 2018

it's not always listening

@mhong
Copy link

mhong commented Jul 18, 2018

It's running now: https://ci-external.swift.org/job/swift-PR-TensorFlow-Linux/.

But sometimes this PR page still wouldn't show that, so I usually check the above CI link.

@lattner
Copy link
Contributor Author

lattner commented Jul 18, 2018

@swift-ci please test tensorflow

@lattner
Copy link
Contributor Author

lattner commented Jul 18, 2018

resolved merge conflict, trying again.

@lattner
Copy link
Contributor Author

lattner commented Jul 18, 2018

@swift-ci please test tensorflow

auto value = elt.getFloatValue();
// TensorFlow only supports float32 attributes, and isn't designed
// for high precision, so we force truncate down.
bool losesInfo = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Some of this could be refactored into helper functions. I guess we can do it later.

@lattner lattner merged commit bd2c450 into tensorflow Jul 18, 2018
@lattner lattner deleted the tf-lowergraph-arrays branch July 18, 2018 22:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tensorflow This is for "tensorflow" branch PRs.

5 participants