當前位置: 首頁>>代碼示例>>C++>>正文


C++ CHECK_LE函數代碼示例

本文整理匯總了C++中CHECK_LE函數的典型用法代碼示例。如果您正苦於以下問題:C++ CHECK_LE函數的具體用法?C++ CHECK_LE怎麽用?C++ CHECK_LE使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了CHECK_LE函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: LegacyShape

 inline int LegacyShape(int index) const {
   CHECK_LE(num_axes(), 4)
       << "Cannot use legacy accessors on Blobs with > 4 axes.";
   CHECK_LT(index, 4);
   CHECK_GE(index, -4);
   if (index >= num_axes() || index < -num_axes()) {
     // Axis is out of range, but still in [0, 3] (or [-4, -1] for reverse
     // indexing) -- this special case simulates the one-padding used to fill
     // extraneous axes of legacy blobs.
     return 1;
   }
   return shape(index);
 }
開發者ID:jy9387,項目名稱:mycaffe,代碼行數:13,代碼來源:blob.hpp

示例2: offset

 inline int offset(const vector<int>& indices) const {
   CHECK_LE(indices.size(), num_axes());
   int offset = 0;
   for (int i = 0; i < num_axes(); ++i) {
     offset *= shape(i);
     if (indices.size() > i) {
       CHECK_GE(indices[i], 0);
       CHECK_LT(indices[i], shape(i));
       offset += indices[i];
     }
   }
   return offset;
 }
開發者ID:jy9387,項目名稱:mycaffe,代碼行數:13,代碼來源:blob.hpp

示例3: CHECK_GE

void ThriftServer::CumulativeFailureInjection::set(
    const FailureInjection& fi) {
  CHECK_GE(fi.errorFraction, 0);
  CHECK_GE(fi.dropFraction, 0);
  CHECK_GE(fi.disconnectFraction, 0);
  CHECK_LE(fi.errorFraction + fi.dropFraction + fi.disconnectFraction, 1);

  std::lock_guard<std::mutex> lock(mutex_);
  errorThreshold_ = fi.errorFraction;
  dropThreshold_ = errorThreshold_ + fi.dropFraction;
  disconnectThreshold_ = dropThreshold_ + fi.disconnectFraction;
  empty_.store((disconnectThreshold_ == 0), std::memory_order_relaxed);
}
開發者ID:UIKit0,項目名稱:fbthrift,代碼行數:13,代碼來源:ThriftServer.cpp

示例4: CheckBlobCounts

 /**
  * Called by the parent Layer's SetUp to check that the number of bottom
  * and top Blobs provided as input match the expected numbers specified by
  * the {ExactNum,Min,Max}{Bottom,Top}Blobs() functions.
  */
 virtual void CheckBlobCounts(const vector<Blob<Dtype>*>& bottom,
                              const vector<Blob<Dtype>*>& top) {
   if (ExactNumBottomBlobs() >= 0) {
     CHECK_EQ(ExactNumBottomBlobs(), bottom.size())
         << type() << " Layer takes " << ExactNumBottomBlobs()
         << " bottom blob(s) as input.";
   }
   if (MinBottomBlobs() >= 0) {
     CHECK_LE(MinBottomBlobs(), bottom.size())
         << type() << " Layer takes at least " << MinBottomBlobs()
         << " bottom blob(s) as input.";
   }
   if (MaxBottomBlobs() >= 0) {
     CHECK_GE(MaxBottomBlobs(), bottom.size())
         << type() << " Layer takes at most " << MaxBottomBlobs()
         << " bottom blob(s) as input.";
   }
   if (ExactNumTopBlobs() >= 0) {
     CHECK_EQ(ExactNumTopBlobs(), top.size())
         << type() << " Layer produces " << ExactNumTopBlobs()
         << " top blob(s) as output.";
   }
   if (MinTopBlobs() >= 0) {
     CHECK_LE(MinTopBlobs(), top.size())
         << type() << " Layer produces at least " << MinTopBlobs()
         << " top blob(s) as output.";
   }
   if (MaxTopBlobs() >= 0) {
     CHECK_GE(MaxTopBlobs(), top.size())
         << type() << " Layer produces at most " << MaxTopBlobs()
         << " top blob(s) as output.";
   }
   if (EqualNumBottomTopBlobs()) {
     CHECK_EQ(bottom.size(), top.size())
         << type() << " Layer produces one top blob as output for each "
         << "bottom blob input.";
   }
 }
開發者ID:csuhawk,項目名稱:caffe,代碼行數:43,代碼來源:layer.hpp

示例5: TEST

    TEST(Logging, CheckOpPass)
    {
        int i1 = 1;
        int i2 = 2;
        unsigned u1 = 3;
        unsigned u2 = 4;
        float f1 = 5.5f;
        float f2 = 6.6f;
        int* p1 = &i1;
        int* p2 = &i2;
        char const * message = "message";

        CHECK_EQ(i1, i1) << message;
        CHECK_EQ(u1, u1) << message;
        CHECK_EQ(f1, f1) << message;
        CHECK_EQ(p1, p1) << message;

        CHECK_NE(i1, i2) << message;
        CHECK_NE(u1, u2) << message;
        CHECK_NE(f1, f2) << message;
        CHECK_NE(p1, p2) << message;

        CHECK_LT(i1, i2) << message;
        CHECK_LT(u1, u2) << message;
        CHECK_LT(f1, f2) << message;

        CHECK_LE(i1, i1) << message;
        CHECK_LE(u1, u2) << message;
        CHECK_LE(f1, f1) << message;

        CHECK_GT(i2, i1) << message;
        CHECK_GT(u2, u1) << message;
        CHECK_GT(f2, f1) << message;

        CHECK_GE(i1, i1) << message;
        CHECK_GE(u2, u1) << message;
        CHECK_GE(f1, f1) << message;
    }
開發者ID:BitFunnel,項目名稱:BitFunnel,代碼行數:38,代碼來源:CheckTest.cpp

示例6: CHECK_EQ

void EltwiseAccuracyLayer<Dtype>::Reshape(
  const vector<Blob<Dtype>*>& bottom, const vector<Blob<Dtype>*>& top) {
  CHECK_EQ(bottom[0]->num(), bottom[1]->num())
      << "The data and label should have the same number.";
  CHECK_LE(top_k_, bottom[0]->count() / bottom[0]->num())
      << "top_k must be less than or equal to the number of classes.";
  CHECK_EQ(bottom[1]->channels(), 1)
      << "Label data should have channel 1.";
  CHECK_EQ(bottom[0]->height(), bottom[1]->height())
      << "The data and label should have the same height.";
  CHECK_EQ(bottom[0]->width(), bottom[1]->width())
      << "the data and label should have the same width.";
  top[0]->Reshape(1, 1, 1, 1);
}
開發者ID:573671712,項目名稱:caffe-1,代碼行數:14,代碼來源:eltwise_accuracy_layer.cpp

示例7: CHECK_LE

bool CoverageSet::covers(size_t begin, size_t end) const noexcept {
  CHECK_LE(begin, end)
      << "End of interval must be greater than or equal to begin";
  if (begin == end) {
    return true;
  }

  auto right = set_.upper_bound(Interval{begin, end});
  if (right == set_.begin()) {
    return false;
  }
  auto left = std::prev(right);
  return left->begin <= begin && end <= left->end;
}
開發者ID:facebookexperimental,項目名稱:eden,代碼行數:14,代碼來源:CoverageSet.cpp

示例8: CHECK_LE

void Blob<Dtype>::Reshape(const vector<int>& shape) {
  CHECK_LE(shape.size(), kMaxBlobAxes);
  count_ = 1;
  shape_.resize(shape.size());
  if (!shape_data_ || shape_data_->size() < shape.size() * sizeof(int)) {
    shape_data_.reset(new SyncedMemory(shape.size() * sizeof(int)));
  }
  int* shape_data = static_cast<int*>(shape_data_->mutable_cpu_data());
  for (int i = 0; i < shape.size(); ++i) {
    CHECK_GE(shape[i], 0);
    if (count_ != 0) {
      CHECK_LE(shape[i], INT_MAX / count_) << "blob size exceeds INT_MAX";
    }
    count_ *= shape[i];
    shape_[i] = shape[i];
    shape_data[i] = shape[i];
  }
  if (count_ > capacity_) {
    capacity_ = count_;
    data_.reset(new SyncedMemory(capacity_ * sizeof(Dtype)));
    diff_.reset(new SyncedMemory(capacity_ * sizeof(Dtype)));
  }
}
開發者ID:ArtHacker123,項目名稱:mini-caffe,代碼行數:23,代碼來源:blob.cpp

示例9: source

std::unique_ptr<IOBuf> SnappyCodec::doCompress(const IOBuf* data) {
  IOBufSnappySource source(data);
  auto out =
    IOBuf::create(snappy::MaxCompressedLength(source.Available()));

  snappy::UncheckedByteArraySink sink(reinterpret_cast<char*>(
      out->writableTail()));

  size_t n = snappy::Compress(&source, &sink);

  CHECK_LE(n, out->capacity());
  out->append(n);
  return out;
}
開發者ID:1Hgm,項目名稱:folly,代碼行數:14,代碼來源:Compression.cpp

示例10: read_async

// Asynchronous read on a overlapped int_fd. Returns `Error` on fatal errors,
// `None()` on a successful pending IO operation or number of bytes read on a
// successful IO operation that finished immediately.
inline Result<size_t> read_async(
    const int_fd& fd,
    void* data,
    size_t size,
    OVERLAPPED* overlapped)
{
  CHECK_LE(size, UINT_MAX);

  switch (fd.type()) {
    case WindowsFD::Type::HANDLE: {
      DWORD bytes;
      const bool success =
        ::ReadFile(fd, data, static_cast<DWORD>(size), &bytes, overlapped);

      // On failure, there are two EOF cases for reads:
      //   1) ERROR_BROKEN_PIPE: The write end is closed and there is no data.
      //   2) ERROR_HANDLE_EOF: We hit the EOF for an asynchronous file handle.
      const DWORD errorCode = ::GetLastError();
      if (success == FALSE &&
          (errorCode == ERROR_BROKEN_PIPE || errorCode == ERROR_HANDLE_EOF)) {
        return 0;
      }

      return ::internal::windows::process_async_io_result(success, bytes);
    }
    case WindowsFD::Type::SOCKET: {
      static_assert(
          std::is_same<OVERLAPPED, WSAOVERLAPPED>::value,
          "Expected `WSAOVERLAPPED` to be of type `OVERLAPPED`.");

      // Note that it's okay to allocate this on the stack, since the WinSock
      // providers must copy the WSABUF to their internal buffers. See
      // https://msdn.microsoft.com/en-us/library/windows/desktop/ms741688(v=vs.85).aspx // NOLINT(whitespace/line_length)
      WSABUF buf = {
        static_cast<u_long>(size),
        static_cast<char*>(data)
      };

      DWORD bytes;
      DWORD flags = 0;
      const int result =
        ::WSARecv(fd, &buf, 1, &bytes, &flags, overlapped, nullptr);

      return ::internal::windows::process_async_io_result(result == 0, bytes);
    }
  }

  UNREACHABLE();
}
開發者ID:GrovoLearning,項目名稱:mesos,代碼行數:52,代碼來源:read.hpp

示例11: CHECK_GE

void ArgMaxLayer<Dtype>::LayerSetUp(const vector<Blob<Dtype>*>& bottom,
      vector<Blob<Dtype>*>* top) {
  out_max_val_ = this->layer_param_.argmax_param().out_max_val();
  top_k_ = this->layer_param_.argmax_param().top_k();
  CHECK_GE(top_k_, 1) << " top k must not be less than 1.";
  CHECK_LE(top_k_, bottom[0]->count() / bottom[0]->num())
      << "top_k must be less than or equal to the number of classes.";
  if (out_max_val_) {
    // Produces max_ind and max_val
    (*top)[0]->Reshape(bottom[0]->num(), 2, top_k_, 1);
  } else {
    // Produces only max_ind
    (*top)[0]->Reshape(bottom[0]->num(), 1, top_k_, 1);
  }
}
開發者ID:Amos-zq,項目名稱:caffe-windows-cudnn,代碼行數:15,代碼來源:argmax_layer.cpp

示例12: CHECK_LE

Vector ЧебышёвSeries<Vector>::Evaluate(Instant const& t) const {
    // This formula ensures continuity at the edges by producing -1 or +1 within
    // 2 ulps for |t_min_| and |t_max_|.
    double const scaled_t = ((t - t_max_) + (t - t_min_)) * one_over_duration_;
    // We have to allow |scaled_t| to go slightly out of [-1, 1] because of
    // computation errors.  But if it goes too far, something is broken.
    // TODO(phl): This should use DCHECK but these macros don't work because the
    // Principia projects don't define NDEBUG.
#ifdef _DEBUG
    CHECK_LE(scaled_t, 1.1);
    CHECK_GE(scaled_t, -1.1);
#endif

    return helper_.EvaluateImplementation(scaled_t);
}
開發者ID:pleroy,項目名稱:Principia,代碼行數:15,代碼來源:чебышёв_series_body.hpp

示例13: CHECK_LE

void Blob<Dtype>::Reshape(const vector<int>& shape) {
  CHECK_LE(shape.size(), kMaxBlobAxes);
  count_ = 1;
  shape_.resize(shape.size());
  for (int i = 0; i < shape.size(); ++i) {
    CHECK_GE(shape[i], 0);
    count_ *= shape[i];
    shape_[i] = shape[i];
  }
  if (count_ > capacity_) {
    capacity_ = count_;
    data_.reset(new SyncedMemory(capacity_ * sizeof(Dtype)));
    diff_.reset(new SyncedMemory(capacity_ * sizeof(Dtype)));
  }
}
開發者ID:gaoyongwyl,項目名稱:VmmrAuxLinux,代碼行數:15,代碼來源:blob.cpp

示例14: CHECK_LE

void SegAccuracyLayer<Dtype>::Reshape(
  const vector<Blob<Dtype>*>& bottom, const vector<Blob<Dtype>*>& top) {
  CHECK_LE(1, bottom[0]->channels())
      << "top_k must be less than or equal to the number of channels (classes).";
  CHECK_EQ(bottom[0]->num(), bottom[1]->num())
    << "The data and label should have the same number.";
  CHECK_EQ(bottom[1]->channels(), 1)
    << "The label should have one channel.";
  CHECK_EQ(bottom[0]->height(), bottom[1]->height())
    << "The data should have the same height as label.";
  CHECK_EQ(bottom[0]->width(), bottom[1]->width())
    << "The data should have the same width as label.";
 
  top[0]->Reshape(1, 1, 1, 5);
}
開發者ID:xygorn,項目名稱:caffe,代碼行數:15,代碼來源:seg_accuracy_layer.cpp

示例15: BleApiTest_TestEncodingLongDataExactLength

ReturnValue BleApiTest_TestEncodingLongDataExactLength(pBleDevice dev)
{
	ReturnValue retval;

	U2F_AUTHENTICATE_REQ authReq;
	unsigned char reply[2048];
	unsigned int replyLength = sizeof(reply);
	unsigned char request[256];
	unsigned int requestlen;
	unsigned char replyCmd;

	// pick random challenge and use registered appId.
	for (size_t i = 0; i < sizeof(authReq.nonce); ++i)
		authReq.nonce[i] = rand();
	memcpy(authReq.appId, regReq.appId, sizeof(authReq.appId));
	authReq.keyHandleLen = regRsp.keyHandleLen;
	memcpy(authReq.keyHandle, regRsp.keyHandleCertSig,
	       authReq.keyHandleLen);

	uint64_t t = dev->TimeMs();

	/* prepare register request */
	request[0] = 0x00;
	request[1] = U2F_INS_AUTHENTICATE;
	request[2] = U2F_AUTH_ENFORCE;
	request[3] = 0x00;
	request[4] = 0x00;
	request[5] = 0x00;
	request[6] = U2F_NONCE_SIZE + U2F_APPID_SIZE + 1 + authReq.keyHandleLen;
	memcpy(request + 7, reinterpret_cast < char *>(&authReq), request[6]);
	requestlen = 7 + request[6];
	request[requestlen++] = 0x00;
	/* 1 byte user presence + 4 bytes counter + upto (6 + 33 + 33) bytes signature */
	request[requestlen++] = 0x01 + 0x04 + 0x48;

	/* write command */
	retval =
	    dev->CommandWrite(FIDO_BLE_CMD_MSG, request, requestlen, &replyCmd,
			      reply, &replyLength);
	CHECK_EQ(retval, ReturnValue::BLEAPI_ERROR_SUCCESS);

  CHECK_EQ(replyCmd, FIDO_BLE_CMD_MSG, "Reply is not a FIDO_BLE_CMD_MSG (0x83)");
	CHECK_EQ(FIDO_RESP_SUCCESS, bytes2short(reply, replyLength - 2), "expects FIDO_RESP_SUCCESS (0x9000)");
	CHECK_NE(replyLength, 2);
  CHECK_LE(replyLength - 2, sizeof(U2F_AUTHENTICATE_RESP), "Returned authentication response does not match expected length.");

	return ReturnValue::BLEAPI_ERROR_SUCCESS;
}
開發者ID:fido-alliance,項目名稱:jovasco-u2f-ref-code,代碼行數:48,代碼來源:U2FTests.cpp


注:本文中的CHECK_LE函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。