1 #ifndef CAFFE2_OPERATORS_ASSERT_OP_H_ 2 #define CAFFE2_OPERATORS_ASSERT_OP_H_ 4 #include "caffe2/core/context.h" 5 #include "caffe2/core/operator.h" 9 template <
class Context>
15 OperatorBase::GetSingleArgument<std::string>(
"error_msg",
"")) {}
17 USE_OPERATOR_CONTEXT_FUNCTIONS;
20 bool DoRunWithType() {
23 auto* cmp_data = cmp_tensor_.template data<T>();
25 for (TIndex i = 0; i < cmp_tensor_.
size(); ++i) {
26 CAFFE_ENFORCE((
bool)cmp_data[i], [&]() {
28 ss <<
"Assert failed for element " << i
29 <<
" in tensor, value: " << cmp_data[i] <<
"\n";
30 if (!error_msg_.empty()) {
31 ss <<
"Error message: " << error_msg_;
39 bool RunOnDevice()
override {
45 std::string error_msg_;
void CopyFrom(const Tensor< SrcContext > &src, ContextForCopy *context)
Copies the data from a source tensor, with a contex provided to carry out the underlying memcpy opera...
TIndex size() const
Returns the size (i.e.
Workspace is a class that holds all the related objects created during runtime: (1) all blobs...
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...