Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initial test for matmul with abstract tensors #40851

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions tensorflow/c/eager/c_api_test_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,18 @@ TFE_TensorHandle* TestMatrixTensorHandle(TFE_Context* ctx) {
return th;
}

TFE_TensorHandle* TestMatrixTensorHandleWithInput(TFE_Context* ctx, float data[], int64_t dims [], int num_dims) {
TF_Status* status = TF_NewStatus();
TF_Tensor* t = TFE_AllocateHostTensor(ctx, TF_FLOAT, &dims[0],
num_dims, status);
memcpy(TF_TensorData(t), &data[0], TF_TensorByteSize(t));
TFE_TensorHandle* th = TFE_NewTensorHandleFromTensor(ctx, t, status);
CHECK_EQ(TF_OK, TF_GetCode(status)) << TF_Message(status);
TF_DeleteTensor(t);
TF_DeleteStatus(status);
return th;
}

TFE_TensorHandle* TestMatrixTensorHandle100x100(TFE_Context* ctx) {
constexpr int64_t dims[] = {100, 100};
constexpr int num_elements = dims[0] * dims[1];
Expand Down
3 changes: 3 additions & 0 deletions tensorflow/c/eager/c_api_test_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ TFE_TensorHandle* DoubleTestMatrixTensorHandle(TFE_Context* ctx);
// Return a tensor handle containing a 2x2 matrix of floats
TFE_TensorHandle* TestMatrixTensorHandle(TFE_Context* ctx);

//Return a tensor handle containing 2D matrix containing given data and dimensions
TFE_TensorHandle* TestMatrixTensorHandleWithInput(TFE_Context* ctx, float data[], int64_t dims [], int num_dims);

// Return a tensor handle containing a 100x100 matrix of floats
TFE_TensorHandle* TestMatrixTensorHandle100x100(TFE_Context* ctx);

Expand Down