本文整理汇总了C++中ArrayRef::getCount方法的典型用法代码示例。如果您正苦于以下问题:C++ ArrayRef::getCount方法的具体用法?C++ ArrayRef::getCount怎么用?C++ ArrayRef::getCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArrayRef
的用法示例。
在下文中一共展示了ArrayRef::getCount方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testPynodeInputOutputAccess
void testPynodeInputOutputAccess(Region * level2)
{
// --- input/output access for level 2 (Python py.TestNode) ---
SHOULDFAIL(level2->getOutputData("doesnotexist") );
// getting access via zero-copy
std::cout << "Getting output for zero-copy access" << std::endl;
ArrayRef output = level2->getOutputData("bottomUpOut");
std::cout << "Element count in bottomUpOut is " << output.getCount() << "" << std::endl;
Real64 *data_actual = (Real64*)output.getBuffer();
// set the actual output
data_actual[12] = 54321;
}
示例2: main
int main(int argc, const char * argv[])
{
// Create network
Network net = Network();
// Add VectorFileSensor region to network
Region* region = net.addRegion("region", "VectorFileSensor", "{activeOutputCount: 1}");
// Set region dimensions
Dimensions dims;
dims.push_back(1);
std::cout << "Setting region dimensions" << dims.toString() << std::endl;
region->setDimensions(dims);
// Load data
std::string path = Path::makeAbsolute("../../src/examples/regions/Data.csv");
std::cout << "Loading data from " << path << std::endl;
std::vector<std::string> loadFileArgs;
loadFileArgs.push_back("loadFile");
loadFileArgs.push_back(path);
loadFileArgs.push_back("2");
region->executeCommand(loadFileArgs);
// Initialize network
std::cout << "Initializing network" << std::endl;
net.initialize();
ArrayRef outputArray = region->getOutputData("dataOut");
// Compute
std::cout << "Compute" << std::endl;
region->compute();
// Get output
Real64 *buffer = (Real64*) outputArray.getBuffer();
for (size_t i = 0; i < outputArray.getCount(); i++)
{
std::cout << " " << i << " " << buffer[i] << "" << std::endl;
}
// Serialize
Network net2;
{
std::stringstream ss;
net.write(ss);
net2.read(ss);
}
net2.initialize();
Region* region2 = net2.getRegions().getByName("region");
region2->executeCommand(loadFileArgs);
ArrayRef outputArray2 = region2->getOutputData("dataOut");
Real64 *buffer2 = (Real64*)outputArray2.getBuffer();
net.run(1);
net2.run(1);
NTA_ASSERT(outputArray2.getCount() == outputArray.getCount());
for (size_t i = 0; i < outputArray.getCount(); i++)
{
std::cout << " " << i << " " << buffer[i] << " " << buffer2[i]
<< std::endl;
}
return 0;
}