umd/core/src/compiler/caffe/CaffeParser.cpp
static bool readBinaryProto(dc::NetParameter* net, const char* file, size_t bufSize)
{
    CHECK_NULL_RET_VAL(net, false);
    CHECK_NULL_RET_VAL(file, false);
    using namespace google::protobuf::io;

    std::ifstream stream(file, std::ios::in | std::ios::binary);
    if (!stream)
    {
        std::cout << "could not open file " << file << std::endl;
        return false;
    }

    IstreamInputStream rawInput(&stream);
    CodedInputStream codedInput(&rawInput);
    codedInput.SetTotalBytesLimit(int(bufSize), -1);

    bool ok = net->ParseFromCodedStream(&codedInput);
    stream.close();

    if (!ok)
    {
        std::cout << "Caffe Parser: could not parse binary model file" << std::endl;
        return false;
    }

    return ok;
}
// There are some challenges associated with importing caffe models. One is that
// a .caffemodel file just consists of layers and doesn't have the specs for its
// input and output blobs.
//
// So we need to read the deploy file to get the input
There are some challenges associated with importing caffe models. One is that
a .caffemodel file just consists of layers and doesn't have the specs for its
input and output blobs.

So we need to read the deploy file to get the input
There are some challenges associated with importing caffe models . One is that a . caffemodel file just consists of layers and doesn ' t have the specs for its input and output blobs . So we need to read the deploy file to get the input
static bool readBinaryProto(dc::NetParameter* net, const char* file, size_t bufSize)
{
    CHECK_NULL_RET_VAL(net, false);
    CHECK_NULL_RET_VAL(file, false);
    using namespace google::protobuf::io;
    std::ifstream stream(file, std::ios::in | std::ios::binary);
    if (!stream)
    {
        std::cout << "could not open file " << file << std::endl;
        return false;
    }
    IstreamInputStream rawInput(&stream);
    CodedInputStream codedInput(&rawInput);
    codedInput.SetTotalBytesLimit(int(bufSize), -1);
    bool ok = net->ParseFromCodedStream(&codedInput);
    stream.close();
    if (!ok)
    {
        std::cout << "Caffe Parser: could not parse binary model file" << std::endl;
        return false;
    }
    return ok;
}
static bool readBinaryProto ( dc :: NetParameter * net , const char * file , size_t bufSize ) { CHECK_NULL_RET_VAL ( net , false ) ; CHECK_NULL_RET_VAL ( file , false ) ; using namespace google :: protobuf :: io ; std :: ifstream stream ( file , std :: ios :: in | std :: ios :: binary ) ; if ( ! stream ) { std :: cout << " " << file << std :: endl ; return false ; } IstreamInputStream rawInput ( & stream ) ; CodedInputStream codedInput ( & rawInput ) ; codedInput . SetTotalBytesLimit ( int ( bufSize ) , -1 ) ; bool ok = net -> ParseFromCodedStream ( & codedInput ) ; stream . close ( ) ; if ( ! ok ) { std :: cout << " " << std :: endl ; return false ; } return ok ; }
There are some challenges associated with importing caffe models.
There are some challenges associated with importing caffe models .