Skip to content

Commit

Permalink
more dummy implemtention
Browse files Browse the repository at this point in the history
  • Loading branch information
chaoqing committed Jan 6, 2025
1 parent 5bf80bc commit 08e3991
Show file tree
Hide file tree
Showing 5 changed files with 655 additions and 113 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ install-cmake:
make install
```

Use following commands to start build and test

```sh
make distclean source-all example-tensorflow TYPE=D USE_LIBTENSORFLOW_CC=0
gdb --tui -q --args ./build/sample/sample --name whole_flow -- ./sample/saved_model/
```

## 🛡 License

[![License](https://img.shields.io/github/license/chaoqing/PyCXpress)](https://github.com/chaoqing/PyCXpress/blob/master/LICENSE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,56 +271,13 @@ class Tensor {
return true;
}

/// \brief Slice this tensor along the 1st dimension.

/// I.e., the returned tensor satisfies
/// returned[i, ...] == this[dim0_start + i, ...].
/// The returned tensor shares the underlying tensor buffer with this
/// tensor.
///
/// NOTE: The returned tensor may not satisfy the same alignment
/// requirement as this tensor depending on the shape. The caller
/// must check the returned tensor's alignment before calling certain
/// methods that have alignment requirement (e.g., `flat()`, `tensor()`).
///
/// NOTE: When fed with an N-dimensional tensor, this method returns a tensor
/// also with N dimensions. If you want to select a sub tensor, see SubSlice.
///
/// REQUIRES: `dims()` >= 1
/// REQUIRES: `0 <= dim0_start <= dim0_limit <= dim_size(0)`
Tensor Slice(int64_t dim0_start, int64_t dim0_limit) const;

/// \brief Select a subslice from this tensor along the 1st dimension.
///
/// When fed with an N-dimensional tensor, this method returns a tensor with
/// N-1 dimensions, where the returned tensor is a subslice of the input
/// tensor along the first dimension. The N-1 dimensions of the returned
/// tensor are the last N-1 dimensions of the input tensor.
///
/// NOTE: The returned tensor may not satisfy the same alignment
/// requirement as this tensor depending on the shape. The caller
/// must check the returned tensor's alignment before calling certain
/// methods that have alignment requirement (e.g., `flat()`, `tensor()`).
///
/// REQUIRES: `dims()` >= 1
/// REQUIRES: `0 <= index < dim_size(0)`
Tensor SubSlice(int64_t index) const;

/// Render the first `max_entries` values in `*this` into a string.
std::string SummarizeValue(int64_t max_entries, bool print_v2 = false) const;

/// A human-readable summary of the tensor suitable for debugging.
// `num_values` is the number of actual data values in the tensor
// included in the message. If the tensor might be resident in
// GPU/TPU memory use DeviceSafeDebugString instead.
std::string DebugString(int num_values) const;
std::string DebugString() const { return DebugString(3); }

// Variant of DebugString() that should be used for possibly non-CPU tensors.
// If the tensor is not resident on CPU, we can't read its values as
// DebugString() does.
std::string DeviceSafeDebugString() const;

/// \brief Returns a `StringPiece` mapping the current tensor's buffer.
///
/// The returned `StringPiece` may point to memory location on devices
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,32 @@ namespace errors {
typedef ::tensorflow::error::Code Code;

} // namespace errors

struct SourceLocation {
uint32_t line;
const char* file_name;

static SourceLocation current(uint32_t line = 0,
const char* file_name = nullptr) {
SourceLocation loc;
loc.line = line;
loc.file_name = file_name;
return loc;
}
};

/// @ingroup core
/// Denotes success or failure of a call in Tensorflow.
class Status {
public:
/// Create a success status.
Status() {}

/// \brief Create a status with the specified error code and msg as a
/// human-readable string containing more detailed information.
Status(error::Code code, std::string_view msg,
SourceLocation loc = SourceLocation::current());

/// Copy the specified status.
Status(const Status& s);
Status& operator=(const Status& s);
Expand Down Expand Up @@ -54,6 +73,9 @@ class Status {
void IgnoreError() const;

private:
error::Code m_code = error::Code::OK;
//std::string_view _msg;
//SourceLocation _loc;
};

// OkStatus()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
#include <string>
#include <vector>

#include "../../core/common_runtime/device_mgr.h"
#include "../../core/framework/tensor.h"
#include "../../core/platform/status.h"
#include "../../core/common_runtime/device_mgr.h"
#include "../../core/public/session_options.h"

// clang-format off
Expand Down
Loading

0 comments on commit 08e3991

Please sign in to comment.