-
Notifications
You must be signed in to change notification settings - Fork 699
[PH] Port the C2/ONNX loader to using Placeholders. #1783
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
2dd86dc
to
4ef6be5
Compare
Testing ONNXIFI changes are not trivial (yet), once we are closer to complete state on the PR I'll run those. |
assert(outputVarsByName_.size() == 1); | ||
return outputVarsByName_.begin()->second; | ||
} | ||
|
||
/// \returns the Variable for the external output with \p name. | ||
/// \pre outputVarsByName_.find(name) != outputVarsByName_.end() | ||
Variable *getOutputByName(llvm::StringRef name) const; | ||
Storage *getOutputByName(llvm::StringRef name) const; |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
2b708c9
to
a7e5159
Compare
Looking good! And, um, I'm sorry for all the silly conflicts on the ModelLoaders :-/ |
55740ec
to
f31f4e5
Compare
@@ -63,12 +63,12 @@ class Caffe2ModelLoader | |||
/// Loads the caffe2 model that's represented by a network description file, | |||
/// serialized in \p netDescFilename, and weights file, serialized in | |||
/// \p netWeightFilename, and populates the network in \p F. | |||
/// The tensors in \p tensors are stored with the names in the list of names | |||
/// The types in \p types of tensors and a names in the list of names |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
@@ -79,6 +79,21 @@ void glow::updateVariables(Context &ctx, llvm::ArrayRef<Placeholder *> ph, | |||
} | |||
} | |||
|
|||
void glow::updateVariablesbyName(Context &ctx, Module *mod, | |||
llvm::ArrayRef<llvm::StringRef> ph, |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
0068d98
to
a9c4f17
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
@@ -142,14 +144,14 @@ class ProtobufLoader { | |||
/// classification, this single final output is usually the result of the last | |||
/// softmax or regression layer. | |||
/// \pre outputVarsByName_.size() == 1 | |||
Variable *getSingleOutput() { | |||
Placeholder *getSingleOutput() { | |||
assert(outputVarsByName_.size() == 1); | |||
return outputVarsByName_.begin()->second; | |||
} | |||
|
|||
/// \returns the Variable for the external output with \p name. |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
tools/loader/TextTranslator.cpp
Outdated
@@ -329,10 +329,12 @@ int main(int argc, char **argv) { | |||
|
|||
assert(!emittingBundle() && "Bundle mode has not been tested."); | |||
|
|||
Variable *outputTokenBeamList = LD.getOutputByName("output_token_beam_list"); | |||
Variable *outputScoreBeamList = LD.getOutputByName("output_score_beam_list"); | |||
Variable *outputTokenBeamList = |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
@@ -133,7 +135,7 @@ class ProtobufLoader { | |||
/// F. The tensors in \p tensors are stored with the names in the list of |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
lib/Onnxifi/Base.cpp
Outdated
@@ -68,7 +68,7 @@ onnxStatus Graph::initGraph(const void *onnxModel, size_t onnxModelSize, | |||
onnxStatus Graph::run() { | |||
// Copy tensors from the input addresses to the Glow tensors. | |||
llvm::SmallVector<Tensor *, 4> tensors; | |||
llvm::SmallVector<Variable *, 4> vars; | |||
llvm::SmallVector<Placeholder *, 4> vars; |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
tools/loader/ImageClassifier.cpp
Outdated
// Get the Variable that the final expected Softmax writes into at the end of | ||
// image inference. | ||
Variable *SMVar = LD->getSingleOutput(); | ||
Placeholder *SMVar = LD->getSingleOutput(); | ||
Tensor *res = ctx.allocate(SMVar); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
tools/loader/ModelRunner.cpp
Outdated
@@ -42,7 +42,8 @@ int main(int argc, char **argv) { | |||
LD.reset(new ONNXModelLoader(loader.getOnnxModelFilename(), {}, {}, | |||
*loader.getFunction())); | |||
} | |||
Variable *output = LD->getSingleOutput(); | |||
Placeholder *output = LD->getSingleOutput(); | |||
auto *res = ctx.allocate(output); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
@@ -313,13 +313,17 @@ int main(int argc, char **argv) { | |||
constexpr char const *inputNames[5] = {"encoder_inputs", "attn_weights", | |||
"prev_hypos_indices", "prev_scores", | |||
"prev_token"}; | |||
std::vector<Tensor *> inputTensors = { | |||
&encoderInputs, &attnWeights, &prevHyposIndices, &prevScores, &prevToken}; | |||
std::vector<TypeRef> inputTensors = { |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
42a65ce
to
e4f9972
Compare
The textual translator now works: Enter a sentence in English to translate to German: I love pizza . |
9c0ba58
to
a1276ec
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
bc07dd3
to
3ee7930
Compare
3ee7930
to
2a39b3c
Compare
Description: This is a WIP PR. This PR ports the last major piece of code to use Placeholders instead of variables. This PR will be followed by cleanup PRS.
Testing: At one point I was able to run the loader. Some tests are still failing.
Documentation:
#1334