in tensorflow_fold/loom/weaver.cc [505:558]
std::vector<tensor_idx_t> Weaver::CallOp(tensor_idx_t op_idx,
const std::vector<tensor_idx_t> &args) {
if (!FastBoundsCheck(op_idx, num_ops_)) {
error_string_ = StrCat("Invalid op ID: ", op_idx);
return {};
}
if (op_input_ts_idx_[op_idx].size() != args.size()) {
error_string_ = StrCat(
"Op: ", op_names_[op_idx],
" Invalid number of arguments:", args.size());
return {};
}
for (tensor_idx_t i = 0; i < args.size(); ++i) {
tensor_idx_t arg = args[i];
if (!FastBoundsCheck(arg, loom_results_.size())) {
error_string_ = StrCat(
"Op ", op_names_[op_idx], " Arg ", i,
" was given out of scope ID:", args[i]);
return {};
}
tensor_idx_t expected = op_input_ts_idx_[op_idx][i];
tensor_idx_t got = loom_results_[arg].ts_idx;
if (expected != got) {
error_string_ = StrCat(
"Op ", op_names_[op_idx], " type mismatch at arg ", i,
" Expected: ", type_shapes_[expected].name,
" got: ", type_shapes_[got].name);
return {};
}
}
tensor_idx_t max_arg_depth = 0;
for (tensor_idx_t arg : args) {
if (loom_results_[arg].depth > max_arg_depth) {
max_arg_depth = loom_results_[arg].depth;
}
}
if (max_depth_ != -1) {
if (max_arg_depth >= max_depth_) {
error_string_ = StrCat("Maximum depth ", max_depth_, " exceeded.");
return {};
}
}
std::vector<tensor_idx_t> deepened_args;
for (tensor_idx_t arg : args) {
deepened_args.push_back(Deepen(arg, max_arg_depth));
}
return AlignedCallOp(op_idx, deepened_args);
}