Repository navigation
Simplify generic parameterization on some operations #176
Description
Activity
I think it would be worth it to make this simplification yes, but the rule might be a bit more tricky. In fact, a generic parameter should be enforced if any input or output of the method should share the same parameter. In other words:
- the returned value parameter must match the parameter of an input
- more than one input must share the same parameter
Even if a single parameter is not bound to
TTypebut to one of its subtype (likeTNumber), we can handle it with a wildcard, e.g. for a hypothetictoFloatoperation:Operand<TFloat> toFloat(Operand<? extends TNumber> input)
So this logic must be added to the C++ op generator.
@karllessard do you have any idea when you would get to this? Should we wait for it before merging in the Kotlin API?
Hey @rnett , I was not necessarily planning to do this work anytime soon, do you want to give it a try?
I can take a look, at least. Do you have any recommendations on IDE setup? I had issues getting bazel to work with CLion when I tried it.
When I was doing more C/C++ code than Java for TensorFlow, I was using Eclipse which supports well both languages, even in the same project (at that time, I had to edit the project file manually to enable this hybridity, I don't know if that can be done differently now).
@karllessard I've got this mostly working, I think, but Javadocs aren't being generated any more, even on
master. I'm running with./bazel-out/k8-opt/bin/external/org_tensorflow/tensorflow/libtensorflow_cc.so --output_dir=./src/gen/java --api_dirs=./src/bazel/api_def, any idea what would cause this? Usingbazel-tensorflow-core-api/external/org_tensorflow/tensorflow/core/api_defdoesn't work either, and makes everything acoreop.I'm not sure to understand, you are running thelibtensorflow_cc.solibrary? or that's probably a mistake, should be thegen_op_javabinary or something like that.(oh yes I recall now, you need to pass the path to the library as well as an argument, that's something relatively new.)
But you need to pass both dirs in the
api_dirsoption, separated by commas if I recall correctly. Also the order matters (sorry for not being more clear in my instructions but I'm not in front of my computer right now)Ok, It looks like it should be
bazel-tensorflow-core-api/external/org_tensorflow/tensorflow/core/api_def/base_api,src/bazel/api_def. This doesn't generate a few ops (DummySeedGenerator,TensorScatterMax, andTensorScatterMin), should I be concerned? The other order doesn't generate them either and misses the group for some data ops.Also, for anyone else trying to use the bazel project, I got it working w/ an old version of CLion (so that I could use the bazel plugin), as long as ran
./configurein a clonedtensorflowproject, and copied the resulting.tf_configure.bazelrctotensorflow-core-api.@karllessard do you think we should make a
CONTRIBUTORS.mdstyle file with build tips like this, the exact command to use for cc op generation, etc?@karllessard do you think we should make a CONTRIBUTORS.md style file with build tips like this, the exact command to use for cc op generation, etc?
Yes, we've mentioned that during the last meeting, we definitely need better documentation when it comes to build from sources and guide the users in the process, we have a lot of issues raised by them that would probably be avoided by just having this documentation, please feel free to start it!
I'm working on the
reifiedgeneration for the Kotlin API, and I'm noticing that lots of methods have unnecessary type parameters that makes thereifiedusage much less nice (since you have to specify all type parameters if you specify one). The best example is probablycast, which has the signiture:Tis completely unnecessary and could be replaced with?without issue, but it preventscast<TInx32>(x)usage from Kotlin. This shows up in a number of Ops, mostly with the unnecessary type parameters on the input. It essentially needs a "is this type param only bounded by TType and only used on inputs" check.Originally posted by @rnett in #174 (comment)