Skip to content

Commit

Permalink
disable eager_op consistent mode (#5647)
Browse files Browse the repository at this point in the history
* disable eager_op consistent mode

* auto format by CI

Co-authored-by: oneflow-ci-bot <69100618+oneflow-ci-bot@users.noreply.github.com>
Co-authored-by: oneflow-ci-bot <ci-bot@oneflow.org>
  • Loading branch information
3 people committed Jul 29, 2021
1 parent 6de3546 commit 059e9e1
Showing 1 changed file with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#include <sstream>
#include "oneflow/core/framework/to_string.h"
#include "oneflow/core/framework/op_interpreter.h"
#include "oneflow/core/framework/op_interpreter/op_interpreter_util.h"
Expand All @@ -28,10 +29,32 @@ limitations under the License.
#include "oneflow/core/job/placement_scope.h"
#include "oneflow/core/eager/foreign_boxing_util.h"
#include "oneflow/core/operator/operator.h"
#include "oneflow/user/kernels/stateful_local_opkernel.h"

namespace oneflow {
namespace one {

namespace {

std::string GetDynamicOpConsistentFailedDebugString(const UserOpExpr& user_op_expr,
const StatefulLocalOpKernel& kernel) {
CHECK(!kernel.output_tuple_indexes4mut2_obns().empty());
std::string plentysuffix = kernel.output_tuple_indexes4mut2_obns().size() == 1 ? "s" : "";
std::stringstream ss;
ss << "operator `" << user_op_expr.op_type_name() << "`"
<< " does not support consistent mode because the shape" << plentysuffix << " of output tensor"
<< plentysuffix << " ";
int i = 0;
for (const auto& out_index : kernel.output_tuple_indexes4mut2_obns()) {
if (i++ > 0) { ss << ", "; }
ss << out_index;
}
ss << " are not infered before op computation.";
return ss.str();
}

} // namespace

Maybe<void> Interpret(const UserOpExpr& user_op_expr, const TensorTuple& inputs,
TensorTuple* outputs, const OpExprInterpContext& ctx) {
CHECK_EQ_OR_RETURN(outputs->size(), user_op_expr.output_size());
Expand All @@ -57,6 +80,8 @@ Maybe<void> Interpret(const UserOpExpr& user_op_expr, const TensorTuple& inputs,
if (!device) { return Maybe<void>::Ok(); }
// Run instruction LocalCallOpKernel
const auto& kernel = JUST(user_op_expr.MutKernel4Device(*device));
CHECK_EQ_OR_RETURN(kernel->output_tuple_indexes4mut2_obns().size(), 0)
<< Error::Unimplemented() << GetDynamicOpConsistentFailedDebugString(user_op_expr, *kernel);
std::shared_ptr<EagerBlobObjectList> input_eager_blob_objects =
std::make_shared<EagerBlobObjectList>(inputs.size());
for (int i = 0; i < inputs.size(); ++i) {
Expand Down

0 comments on commit 059e9e1

Please sign in to comment.